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 |