mehedi / payumoney-php-sdk
PHP的PayUMoney库
1.3
2019-07-07 17:53 UTC
Requires
- php: >=5.5.0
- symfony/http-foundation: ~2.6|~3.0|~4.0
- symfony/options-resolver: ~2.6|~3.0|~4.0
This package is auto-updated.
Last update: 2024-09-08 05:08:56 UTC
README
PHP的PayUMoney API
一个简单的库,用于通过PayUMoney接受支付。
安装
要将此库添加到您的项目,请运行以下命令:composer require mehedi/payumoney-php-sdk:dev-master
。
使用方法
以下是一个最小使用示例。
初始化购买
<?php // purchase.php use Mehedi\PayUMoney\PayUMoney; require 'vendor/autoload.php'; $payumoney = new PayUMoney([ 'merchantId' => 'YOUR_MERCHANT_ID', 'secretKey' => 'YOUR_SECRET_KEY', 'salt' => 'YOUR_SALT', 'testMode' => true ]); // All of these parameters are required! $params = [ 'txnid' => 'A_UNIQUE_TRANSACTION_ID', 'amount' => 10.50, 'productinfo' => 'A book', 'firstname' => 'Peter', 'email' => 'abc@example.com', 'phone' => '1234567890', 'surl' => 'https:///payumoney-php/return.php', 'furl' => 'https:///payumoney-php/return.php', ]; // Redirects to PayUMoney $payumoney->initializePurchase($params)->send();
完成购买
<?php // return.php use Razzbee\PayUMoney\PayUMoney; require 'vendor/autoload.php'; $payumoney = new PayUMoney([ 'merchantId' => 'YOUR_MERCHANT_ID', 'secretKey' => 'YOUR_SECRET_KEY', 'salt' => 'YOUR_SALT', 'testMode' => true ]); $result = $payumoney->completePurchase($_POST); if ($result->checksumIsValid() && $result->getStatus() === PayUMoney::STATUS_COMPLETED) { print 'Payment was successful.'; } else { print 'Payment was not successful.'; }
PurchaseResult
还有一些可能很有用的方法
$result = $payumoney->completePurchase($_POST); // Returns Complete, Pending, Failed or Tampered $result->getStatus(); // Returns an array of all the parameters of the transaction $result->getParams(); // Returns the ID of the transaction $result->getTransactionId(); // Returns true if the checksum is correct $result->checksumIsValid();