osinakayah / kurepay-gateway
帮助您调用 Kurepay API
dev-master
2019-03-08 06:26 UTC
Requires
- php: >=5.3.0
This package is not auto-updated.
Last update: 2024-09-29 08:57:02 UTC
README
要求
PHP 5.3.0 或更高版本
安装
composer require osinakayah/kurepay-gateway
用法
在调用 getTransactionUrl 后返回一个 URL,支付成功后重定向到该 URL,用户将被重定向回管理员仪表板上提供的 URL
演示
<?php /** * User: osinakayah * Date: 08/03/2019 * Time: 7:02 AM */ $kurepay = new \Kurepay\KurepayGateway(PUBLIC_KEY); $redirectUrl = ''; try { $redirectUrl = $kurepay->getTransactionUrl($email, $amount, $reference, $fullname, $phoneNumber, ['item' => "Extra meta data"]); } catch (\Exception $exception){ die($e->getMessage()); } //Takes the user to payment page. header('Location: ' . $redirectUrl);
验证交易
<?php /** * User: osinakayah * Date: 08/03/2019 * Time: 7:02 AM */ $kurepay = new \Kurepay\KurepayGateway(PUBLIC_KEY); $wasPaymentSuccessful = false; try { $wasPaymentSuccessful = $kurepay->getTransactionStatus($reference); } catch (\Exception $exception){ die($e->getMessage()); } if ($wasPaymentSuccessful) { echo 'Payment was successful'; } else { echo 'Nah, it was not successful'; }