paykun / checkout
PayKun Checkout 库,可用于发起支付
2.0.5
2020-09-09 10:24 UTC
Requires
- php: >=5.3.0
- twig/twig: ^2.0
This package is auto-updated.
Last update: 2024-09-09 18:38:52 UTC
README
安装
- 如果您的项目使用 composer,请运行以下命令
composer require paykun/checkout
- 如果您不使用 composer,请从 版本发布部分 下载最新版本。 您应下载
源代码.zip
文件。之后,将Payment.php
包含到您的应用中,您就可以像通常一样使用 API。
如何生成访问令牌和API密钥
您可以从登录 PayKun 管理面板生成或重新生成访问令牌和 API 密钥,然后前往:设置 -> 安全 -> API 密钥。在那里,如果您之前未生成 API 密钥,您将找到生成按钮。
如果您之前已生成 API 密钥,您将看到 API 密钥生成的日期。由于您将无法检索旧 API 密钥(出于安全原因),我们提供了重新生成选项,因此您可以在丢失旧密钥的情况下重新生成 API 密钥。
注意:一旦您重新生成 API 密钥,旧 API 密钥将立即停止工作。因此,在使用此选项时请谨慎。
使用方法(Composer 项目)
use Paykun\Checkout\Payment; $obj = new Payment('<merchantId>', '<accessToken>', '<encryptionKey>'); // Initializing Order // default currency is 'INR' $obj->initOrder('<orderId>', '<Purpose or ProductName>', "<amount>", '<successUrl.example.com>', '<failUrl.example.com>', 'INR'); // Add Customer $obj->addCustomer('<customerName>', '<customerEmail>', '<customerContactNo>'); // Add Shipping address $obj->addShippingAddress('<country>', '<state>', '<city>', '<postalCode>', '<fullAddress>'); // Add Billing Address $obj->addBillingAddress('<country>', '<state>', '<city>', '<postalCode>', '<fullAddress>'); echo $obj->submit(); /* Check for transaction status * Once your success or failed url called then create an instance of Payment same as above and then call getTransactionInfo like below * $obj = new Payment('merchantUId', 'accessToken', 'encryptionKey'); * $transactionData = $obj->getTransactionInfo(Get payment-id from the success or failed url); * Process $transactionData as per your requirement * * */
使用方法(非 Composer 项目)
require 'src/Payment.php'; require 'src/Validator.php'; require 'src/Crypto.php'; /** * Parameters requires to initialize an object of Payment are as follow. * mid => Merchant Id provided by Paykun * accessToken => Access Token provided by Paykun * encKey => Encryption provided by Paykun * isLive => Set true for production environment and false for sandbox or testing mode * isCustomTemplate => Set true for non composer projects, will disable twig template */ $obj = new \Paykun\Checkout\Payment('<merchantId>', '<accessToken>', '<encryptionKey>', true, true); // Initializing Order // default currency is 'INR' $obj->initOrder('<orderId>', '<Purpose or ProductName>', "<amount>", '<successUrl.example.com>', '<failUrl.example.com>', 'INR'); // Add Customer $obj->addCustomer('<customerName>', '<customerEmail>', '<customerContactNo>'); // Add Shipping address $obj->addShippingAddress('<country>', '<state>', '<city>', '<postalCode>', '<fullAddress>'); // Add Billing Address $obj->addBillingAddress('<country>', '<state>', '<city>', '<postalCode>', '<fullAddress>'); //Render template and submit the form echo $obj->submit(); /* Check for transaction status * Once your success or failed url called then create an instance of Payment same as above and then call getTransactionInfo like below * $obj = new Payment('merchantUId', 'accessToken', 'encryptionKey', true, true); //Second last false if sandbox mode * $transactionData = $obj->getTransactionInfo(Get payment-id from the success or failed url); * Process $transactionData as per your requirement * * */
如需进一步帮助,请参阅我们关于 https://paykun.com/docs 的文档。
许可证
Paykun PHP SDK 在 MIT 许可证下发布。