myfatoorah php
1.0.0
安裝此庫的首選方法是通過作曲家。
要么運行
$ composer require bawes/myfatoorah-php或添加
"bawes/myfatoorah-php" : " ^1.0 "要為您應用程序的composer.json文件的要求部分。
首先,我們需要確定要使用的環境
<?php
use bawes/myfatoorah/ MyFatoorah ;
$ my = MyFatoorah:: test (); <?php
use bawes/myfatoorah/ MyFatoorah ;
$ merchantCode = " [Your merchant code here] " ;
$ username = " [Your merchant username here] " ;
$ password = " [Your merchant password here] " ;
$ my = MyFatoorah:: live ( $ merchantCode , $ username , $ password ); <?php
use bawes/myfatoorah/ MyFatoorah ;
$ merchantCode = " [Your merchant code here] " ;
$ username = " [Your merchant username here] " ;
$ password = " [Your merchant password here] " ;
$ my = MyFatoorah:: live ( $ merchantCode , $ username , $ password );
$ my -> setPaymentMode (MyFatoorah:: GATEWAY_ALL )
-> setReturnUrl ( " https://google.com " )
-> setErrorReturnUrl ( " https://google.com " )
-> setCustomer ( " Khalid " , " [email protected] " , " 97738271 " )
-> setReferenceId () //Pass unique order number or leave empty to use time()
-> addProduct ( " iPhone " , 5.350 , 3 )
-> addProduct ( " Samsung " , 12.000 , 1 )
-> getPaymentLinkAndReference ();
$ paymentUrl = $ my [ ' paymentUrl ' ];
$ myfatoorahRefId = $ my [ ' paymentRef ' ]; //good idea to store this for later status checks
// Redirect to payment url
header ( " Location: $ paymentUrl " );
die ();使用MyFatoorah::getOrderStatus($referenceId)獲取付款狀態的更新。在收到Myfatoorah的returnUrl或Errorterturnurl的回調後,最好將這一點。如果您本地存儲參考ID,也可以在間隔後手動調用此功能。
<?php
use bawes/myfatoorah/ MyFatoorah ;
// Example Ref ID
$ myfatoorahRefId = $ _GET [ ' id ' ];
// Order status on Test environment
$ orderStatus = MyFatoorah:: test ()
-> getOrderStatus ( $ myfatoorahRefId );
// Order status on Live environment
$ merchantCode = " [Your merchant code here] " ;
$ username = " [Your merchant username here] " ;
$ password = " [Your merchant password here] " ;
$ orderStatus = MyFatoorah:: live ( $ merchantCode , $ username , $ password )
-> getOrderStatus ( $ myfatoorahRefId ); <?php
$ orderStatus = [
' responseCode ' => ' 0 ' , //MyFatoorah::REQUEST_SUCCESSFUL
' responseMessage ' => ' SUCCESS ' ,
' result ' => ' CAPTURED ' ,
// Successful payment fields
' payMode ' => ' KNET ' ,
' orderId ' => ' 1085183 ' ,
' payTransactionId ' => ' 673386261283050 ' ,
' grossAmountPaid ' => ' 32.500 ' ,
' netAmountToBeDeposited ' => ' 32.300 ' ,
// User defined fields
' udf1 ' => '' ,
' udf2 ' => '' ,
' udf3 ' => '' ,
' udf4 ' => '' ,
' udf5 ' => ''
] <?php
$ orderStatus = [
' responseCode ' => ' 2009 ' ,
' responseMessage ' => ' Transaction Failed Messages ' ,
' result ' => ' Payment Server detected an error ' ,
// User defined fields
' udf1 ' => '' ,
' udf2 ' => '' ,
' udf3 ' => '' ,
' udf4 ' => '' ,
' udf5 ' => ''
]通過將MyFatoorah類上可用的網關常數傳遞到MyFatoorah::setPaymentMode來配置您希望使用的網關。
MyFatoorah::GATEWAY_ALL生成的鏈接通過所有付款方式發送到myfatoorah頁面MyFatoorah::GATEWAY_KNET生成的鏈接直接將用戶發送到Knet PortalMyFatoorah::GATEWAY_VISA_MASTERCARD生成的鏈接直接將用戶發送到Visa/Master PortalMyFatoorah::GATEWAY_SAUDI_SADAD生成的鏈接直接將用戶發送到Sadad Saudi PortalMyFatoorah::GATEWAY_BAHRAIN_BENEFIT生成的鏈接直接發送用戶以使Bahrain Portal受益MyFatoorah::GATEWAY_QATAR_QPAY生成的鏈接直接將用戶發送到qpay qpay Qatar PortalMyFatoorah::GATEWAY_UAECC生成的鏈接直接將用戶發送到阿聯酋借記卡門戶網站用法示例:
<?php
use bawes/myfatoorah/ MyFatoorah ;
$ my = MyFatoorah:: live ( $ merchantCode , $ username , $ password );
$ my -> setPaymentMode (MyFatoorah:: GATEWAY_ALL )這些卡只有在使用MyFatoorah::test()環境初始化時才能起作用。
| 卡號 | 銷/到期 | 結果 |
|---|---|---|
| 88888880000000001 | 任何事物 | 被捕獲 |
| 88888880000000002 | 任何事物 | 沒有被捕獲 |
| 卡號 | 到期日 | 別針 | 結果 |
|---|---|---|---|
| 2222220123456789 | 12/27 | 1234 | 被捕獲 |
| 7777770123456789 | 12/27 | 1234 | 沒有被捕獲 |
| 1111110123456789 | 12/27 | 1234 | 沒有被捕獲 |
| 卡號 | 到期日 | CVV |
|---|---|---|
| 4005550000000001 | 05/18 | 123 |
| 4557012345678902 | 05/18 | 123 |
| 卡號 | 到期日 | CVV |
|---|---|---|
| 5123456789012346 | 05/18 | 123 |
| 5313581000123430 | 05/18 | 123 |
| 卡號 | 到期日 | 別針 |
|---|---|---|
| 345678901234564 | 05/17 | 1234 |
| 付款方式 | 卡號 | 到期日 | CVV |
|---|---|---|---|
| 萬事達 | 5271045423029111 | 任何事物 | 任何事物 |
| 簽證 | 4012001037141112 | 01/2022 | 684 |
| 付款方式 | 帳戶ID | 密碼 |
|---|---|---|
| Sadad帳戶 | Arun123 | AA123456 |