iyzipay php
iyzipay-php 2.0.58
您可以在 https://iyzico.com 注册 iyzico 帐户
PHP 7.4 及更高版本。
2018 年 3 月后将支持最低 TLS v1.2。请将您的 openssl 版本至少升级到 1.0.1。如果您有任何疑问,请在 Github 上提出问题或通过 [email protected] 联系我们。
您可以通过 Composer 安装绑定。运行以下命令:
composer require iyzico/iyzipay-php
要使用绑定,请使用 Composer 的自动加载:
require_once ( ' vendor/autoload.php ' );
如果您不想使用 Composer,可以下载最新版本。然后,要使用绑定,请包含IyzipayBootstrap.php
文件。
require_once ( ' /path/to/iyzipay-php/IyzipayBootstrap.php ' );
$ options = new Iyzipay Options ();
$ options -> setApiKey ( " your api key " );
$ options -> setSecretKey ( " your secret key " );
$ options -> setBaseUrl ( " https://sandbox-api.iyzipay.com " );
$ request = new Iyzipay Request CreatePaymentRequest ();
$ request -> setLocale ( Iyzipay Model Locale:: TR );
$ request -> setConversationId ( " 123456789 " );
$ request -> setPrice ( " 1 " );
$ request -> setPaidPrice ( " 1.2 " );
$ request -> setCurrency ( Iyzipay Model Currency:: TL );
$ request -> setInstallment ( 1 );
$ request -> setBasketId ( " B67832 " );
$ request -> setPaymentChannel ( Iyzipay Model PaymentChannel:: WEB );
$ request -> setPaymentGroup ( Iyzipay Model PaymentGroup:: PRODUCT );
$ paymentCard = new Iyzipay Model PaymentCard ();
$ paymentCard -> setCardHolderName ( " John Doe " );
$ paymentCard -> setCardNumber ( " 5528790000000008 " );
$ paymentCard -> setExpireMonth ( " 12 " );
$ paymentCard -> setExpireYear ( " 2030 " );
$ paymentCard -> setCvc ( " 123 " );
$ paymentCard -> setRegisterCard ( 0 );
$ request -> setPaymentCard ( $ paymentCard );
$ buyer = new Iyzipay Model Buyer ();
$ buyer -> setId ( " BY789 " );
$ buyer -> setName ( " John " );
$ buyer -> setSurname ( " Doe " );
$ buyer -> setGsmNumber ( " +905350000000 " );
$ buyer -> setEmail ( " [email protected] " );
$ buyer -> setIdentityNumber ( " 74300864791 " );
$ buyer -> setLastLoginDate ( " 2015-10-05 12:43:35 " );
$ buyer -> setRegistrationDate ( " 2013-04-21 15:12:09 " );
$ buyer -> setRegistrationAddress ( " Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1 " );
$ buyer -> setIp ( " 85.34.78.112 " );
$ buyer -> setCity ( " Istanbul " );
$ buyer -> setCountry ( " Turkey " );
$ buyer -> setZipCode ( " 34732 " );
$ request -> setBuyer ( $ buyer );
$ shippingAddress = new Iyzipay Model Address ();
$ shippingAddress -> setContactName ( " Jane Doe " );
$ shippingAddress -> setCity ( " Istanbul " );
$ shippingAddress -> setCountry ( " Turkey " );
$ shippingAddress -> setAddress ( " Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1 " );
$ shippingAddress -> setZipCode ( " 34742 " );
$ request -> setShippingAddress ( $ shippingAddress );
$ billingAddress = new Iyzipay Model Address ();
$ billingAddress -> setContactName ( " Jane Doe " );
$ billingAddress -> setCity ( " Istanbul " );
$ billingAddress -> setCountry ( " Turkey " );
$ billingAddress -> setAddress ( " Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1 " );
$ billingAddress -> setZipCode ( " 34742 " );
$ request -> setBillingAddress ( $ billingAddress );
$ basketItems = array ();
$ firstBasketItem = new Iyzipay Model BasketItem ();
$ firstBasketItem -> setId ( " BI101 " );
$ firstBasketItem -> setName ( " Binocular " );
$ firstBasketItem -> setCategory1 ( " Collectibles " );
$ firstBasketItem -> setCategory2 ( " Accessories " );
$ firstBasketItem -> setItemType ( Iyzipay Model BasketItemType:: PHYSICAL );
$ firstBasketItem -> setPrice ( " 0.3 " );
$ basketItems [ 0 ] = $ firstBasketItem ;
$ secondBasketItem = new Iyzipay Model BasketItem ();
$ secondBasketItem -> setId ( " BI102 " );
$ secondBasketItem -> setName ( " Game code " );
$ secondBasketItem -> setCategory1 ( " Game " );
$ secondBasketItem -> setCategory2 ( " Online Game Items " );
$ secondBasketItem -> setItemType ( Iyzipay Model BasketItemType:: VIRTUAL );
$ secondBasketItem -> setPrice ( " 0.5 " );
$ basketItems [ 1 ] = $ secondBasketItem ;
$ thirdBasketItem = new Iyzipay Model BasketItem ();
$ thirdBasketItem -> setId ( " BI103 " );
$ thirdBasketItem -> setName ( " Usb " );
$ thirdBasketItem -> setCategory1 ( " Electronics " );
$ thirdBasketItem -> setCategory2 ( " Usb / Cable " );
$ thirdBasketItem -> setItemType ( Iyzipay Model BasketItemType:: PHYSICAL );
$ thirdBasketItem -> setPrice ( " 0.2 " );
$ basketItems [ 2 ] = $ thirdBasketItem ;
$ request -> setBasketItems ( $ basketItems );
$ payment = Iyzipay Model Payment:: create ( $ request , $ options );
请参阅示例目录下的其他示例。
安装依赖项:
composer install
可用于模拟成功支付的测试卡:
卡号 | 银行 | 卡类型 |
---|---|---|
5890040000000016 | 阿克银行 | 万事达卡(借记卡) |
5526080000000006 | 阿克银行 | 万事达卡(信用卡) |
4766620000000001 | 德尼兹银行 | 签证(借记卡) |
4603450000000000 | 德尼兹银行 | 签证(信用证) |
4729150000000005 | Denizbank 奖金 | 签证(信用证) |
4987490000000002 | 金融银行 | 签证(借记卡) |
5311570000000005 | 金融银行 | 万事达卡(信用卡) |
9792020000000001 | 金融银行 | 特洛伊(借方) |
9792030000000000 | 金融银行 | 特洛伊(来源) |
5170410000000004 | 加兰蒂银行 | 万事达卡(借记卡) |
5400360000000003 | 加兰蒂银行 | 万事达卡(信用卡) |
374427000000003 | 加兰蒂银行 | 美国运通 |
4475050000000003 | 哈尔克银行 | 签证(借记卡) |
5528790000000008 | 哈尔克银行 | 万事达卡(信用卡) |
4059030000000009 | 汇丰银行 | 签证(借记卡) |
5504720000000003 | 汇丰银行 | 万事达卡(信用卡) |
5892830000000000 | 土耳其银行 | 万事达卡(借记卡) |
4543590000000006 | 土耳其银行 | 签证(信用证) |
4910050000000006 | 瓦基夫银行 | 签证(借记卡) |
4157920000000002 | 瓦基夫银行 | 签证(信用证) |
5168880000000002 | 亚皮和克雷迪银行 | 万事达卡(借记卡) |
5451030000000000 | 亚皮和克雷迪银行 | 万事达卡(信用卡) |
跨境测试卡:
卡号 | 国家 |
---|---|
4054180000000007 | 非土耳其语(借方) |
5400010000000004 | 非土耳其语(学分) |
测试卡以获取特定错误代码:
卡号 | 描述 |
---|---|
5406670000000009 | 成功但不可取消、退款或授权后 |
4111111111111129 | 资金不足 |
4129111111111111 | 不尊重 |
4128111111111112 | 无效交易 |
4127111111111113 | 遗失卡 |
4126111111111114 | 卡被盗 |
4125111111111115 | 过期卡 |
4124111111111116 | 无效的 cvc2 |
4123111111111117 | 持卡人不允许 |
4122111111111118 | 不允许终端 |
4121111111111119 | 诈骗嫌疑人 |
4120111111111110 | 取货卡 |
4130111111111118 | 一般错误 |
4131111111111117 | 成功但 mdStatus 为 0 |
4141111111111115 | 成功但 mdStatus 为 4 |
4151111111111112 | 3dsecure 初始化失败 |
可用于模拟使用替代付款方式进行付款的模拟 APM 帐户:
账户持有人姓名 | 描述 |
---|---|
成功 | 初始化成功后支付成功 |
初始化后失败 | 初始化成功后支付失败 |
错误 | 初始化失败 |
如上所述安装依赖项(这将解析 PHPUnit),然后您可以运行测试套件:
./vendor/bin/phpunit
或者运行单独的测试文件:
./vendor/bin/phpunit tests/Iyzipay/Tests/Model/PaymentTest.php
测试文件正在测试...