ajaxy / payment
Ajaxy 支付
v1.0.0
2018-02-26 08:17 UTC
Requires
- php: >=5.4.0
This package is auto-updated.
Last update: 2024-09-13 22:26:24 UTC
README
安装
composer require ajaxy/payment
示例
//using paypal $__URL__ = 'http://www.example.com'; $paypal = new \Ajaxy\Payment\Gateway\Paypal(array( 'email' => '', 'custom' => array('user_id' => ''), 'notify_url' => $__URL__.'/validate_ipn.php', 'return_url' => $__URL__, 'cancel_return' => $__URL__ )); $paypal->addItem('test1', 10, 1); $paypal->addItem('test2', 10, 3); //print the form $paypal->getForm(true); //or echo the url echo '<a href="'.$paypal->getRequestUrl(false).'">Pay</a>'; //using al mashreq bank $__URL__ = "http://www.example.com"; $_SECURE_HASH_ = ''; //should be sent by the bank $_MID_ = ''; //merchant id $_ACCESS_CODE_ = ''; //access code $almashreq = new \Ajaxy\Payment\Gateway\AlMashreq(array( 'notify_url' => $__URL__.'/validate_mh.php', 'return_url' => $__URL__.'/validate_mh.php', 'order_number' => __ORDER__NO__, //pass any order info to the payment, you will receive this back 'custom' => array('test' => 1), //the order total, maximum of 2 decimal places 'total' => '321', //sandbox or live 'mode' => 'sandbox', //merchant details, those details are sent by the bank 'endpoint' => 'https://migs.mastercard.com.au', 'access_code' => $_ACCESS_CODE_, 'merchant' => $_MID_, 'currency_code' => 'AED', 'secure_hash' => $_SECURE_HASH_, )); //print the form $almashreq->getForm(true); //or echo the url echo '<a href="'.$almashreq->getRequestUrl(false, true).'">Pay</a>';
验证
//you will receive the response at the return_url you have set before //al mashreq $response = new \Ajaxy\Payment\Gateway\AlMashreq\Response(_SECURE_HASH_, null); if($response->validate()){ $custom = $response->getCustom(); print_r($custom); echo 'payment is valid'; }else{ $code = $response->getResponseCode(); echo $response->getResultDescription($code); } //paypal $ipn = new \Ajaxy\Payment\Gateway\Paypal\IPN('php://input', true); if($ipn->validate()){ echo "valid"; }else{ echo "failed"; } //you can also pass a psr4 logger to log the response use \Ajaxy\Logger\Logger; use \Ajaxy\Logger\Handler\Stream; $log = new Logger(); $log->addHandler(new Stream(dirname(__FILE__).'/log/')); $ipn = new \Ajaxy\Payment\Gateway\Paypal\IPN('php://input', true, $log); $response = new \Ajaxy\Payment\Gateway\AlMashreq\Response(_SECURE_HASH_, null, $log);
关于
要求
- Ajaxy\Logger 与 PHP 5.6 或更高版本兼容。
提交错误和功能请求
错误和功能请求在 GitHub 上跟踪
作者
Naji Amer - icu090@gmail.com - http://ajaxy.org
许可证
Ajaxy\Payment 使用 MIT 许可证授权 - 详细信息请参阅 LICENSE
文件