inverseschool / omnipay-saman
v1.1.2
2024-05-28 05:33 UTC
Requires
- php: ^7.3
- ext-json: *
- ext-mbstring: *
- omnipay/common: ^3
- php-http/guzzle7-adapter: ^1
- symfony/http-client: ^5
Requires (Dev)
- http-interop/http-factory-guzzle: ^1.2
- omnipay/tests: 4.1.1
- phpstan/phpstan: ^1.8
- squizlabs/php_codesniffer: ^3
README
composer require inverseschool/omnipay-saman
示例
购买
结果将重定向到网关或银行。
$gateway->setTerminalId('xxxxxxxxxxxx'); $response = $gateway->purchase([ 'amount' => $amount, 'transactionId' => 'Merchant-Ref-X', 'returnUrl' => 'https://www.example.com/return', ])->send(); // Process response if ($response->isSuccessful() && $response->isRedirect()) { // store the transaction reference to use in completePurchase() $transactionReference = $response->getTransactionReference(); // Redirect to offsite payment gateway $response->redirect(); } else { // Payment failed: display message to customer echo $response->getMessage(); }
完成购买(验证)
通过 交易参考号
验证订单
// Send purchase complete request $response = $gateway->completePurchase([ 'transactionReference' => $refNum, ])->send(); if (!$response->isSuccessful() || $response->isCancelled()) { // Payment failed: display message to customer echo $response->getMessage(); } else { // Payment was successful print_r($response); }
退款订单
通过 交易参考号
退款订单
$response = $gateway->refund([ 'transactionReference' => $refNum, ])->send(); if ($response->isSuccessful()) { // Refund was successful print_r($response); } else { // Refund failed echo $response->getMessage(); }