rarashed/payfast-sdk
最新稳定版本:1.0.0
Composer 安装命令:
composer require rarashed/payfast-sdk
包简介
A library for handling payfast payment gateway integration
README 文档
README
The PayFast package allows easy integration with payment gateway in one unified API. It is simple to install, configure, and use.
Installation
You can install the package via Composer:
composer require rarashed/payfast-sdk
#OR
composer require rarashed/payfast-sdk:dev-main
#Code example
use RaRashed\PayFastSdk\PayFast; $payfast = new PayFast( 'merchant_id', // Your Merchant ID 'merchant_name', // Your Merchant Name 'secured_key', // Your Secured Key 'token_api_url', // Your Token API URL 'redirect_url', // Your Redirect URL 'success_url', // Your Success URL 'fail_url', // Your Failure URL 'checkout_url' // Your Checkout URL ); $payment_data = [ 'payment_amount' => 100.50, 'payer_information' => [ 'name' => 'John Doe', 'phone' => '1234567890', 'email' => 'payer@example.com' ], 'created_at' => now(), ]; $response = $payfast->processPayment($payment_data);
#Pay HTML Form Code
$redirectUrl = "https://ipguat.apps.net.pk/Ecommerce/api/Transaction/PostTransaction"; // Test redirect URL <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>PayFast Payment</title> </head> <body> <form action="<?= htmlspecialchars($redirectUrl) ?>" method="post" id="payfast-payment-form"> <?php foreach ($response as $key => $value): ?> <input type="hidden" name="<?= htmlspecialchars($key) ?>" value="<?= htmlspecialchars($value) ?>"> <?php endforeach; ?> </form> <script> // Automatically submit the form when the page is loaded document.getElementById('payfast-payment-form').submit(); </script> </body> </html>
#Token and Redirect URL will be country wise. Test Token URL
https://ipguat.apps.net.pk/Ecommerce/api/Transaction/GetAccessToken
##Test Redirect URL
https://ipguat.apps.net.pk/Ecommerce/api/Transaction/PostTransaction
统计信息
- 总下载量: 11
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-12-01