iyzipay php
iyzipay-php 2.0.58
您可以在 https://iyzico.com 註冊 iyzico 帳戶
PHP 7.4 及更高版本。
2018 年 3 月後將支援最低 TLS v1.2。如果您有任何疑問,請在 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
測試檔案正在測試...