payment4 / cryptogateway
Payment4 Crypto Payment Gateway for Laravel
v1.0.2
2024-09-03 11:36 UTC
Requires
- php: ^8.0|^8.1|^8.2|^8.3
- guzzlehttp/guzzle: ^7.2
- laravel/framework: ^9.0|^10.0|^11.0
README
Payment4彻底改变了企业交易的方式。无缝接受各种数字货币,确保快速、安全、无国界交易,以赋予您的全球企业更多力量。
- 简化高效
- Promises/A+ 兼容性
- 安全沙盒
安装
您可以通过 composer 安装此包
composer require payment4/cryptogateway
接下来,您应该使用 vendor:publish
Artisan 命令发布配置文件。配置文件将被放置在您的应用程序的 config
目录中。
php artisan vendor:publish --provider="Payment4\CryptoGateway\Payment4ServiceProvider"
要求
- php "^7.2|^8.0|^8.1|^8.2|^8.3"
- laravel-framework "^7.0|^8.0|^9.0|^10.0|^11.0"
- 在 https://payment4.com 注册免费或登录
- 创建新的网关并获取 apiKey
配置
在 Payment4 配置中添加您的 APIKEY。
'apiKey' => env('PAYMENT4_API_KEY', ''),
此外,您还可以将 APIKEY 添加到 .env 文件中,请参考以下示例
PAYMENT4_API_KEY= __YOUR_API_KEY
如果您使用 callbackUrl 作为静态 URL,您可以在此处设置,否则请留空。
'callbackUrl' => env('PAYMENT4_CALLBACK_URL', ''),
如果您使用 webhookUrl 作为静态 URL,您可以在此处设置,否则请留空。
'webhookUrl' => env('PAYMENT4_WEBHOOK_URL', ''),
语言
'language' => 'EN',
支持的语言
- FR
- ES
- AR
- TR
- FA
- EN
注意:对大小写不敏感
货币
'currency' => 'USD',
支持货币
- USD
- EUR
- TRY
- GBP
- AED
- IRT
注意:对大小写不敏感
- 沙盒
激活时设置为 True
'sandBox' => false,
用法
创建 Payment4 实例
示例 1
/** * apiKey and sandBox are optional if already set them to config file. */ $initParams = [ 'apiKey' => '######', 'sandBox' => false, ]; $paymentInstance = Payment4($initParams);
示例 2
$paymentInstance = Payment4();
请求支付
/** * amount is required * callbackParams, webhookParams, webhookUrl, language, currency are optional. * callbackUrl is optional if already set it to config file. * If no language is provided, the default language is set to 'en'. * If no currency is provided, the default currency is set to 'USD'. */ $amount = 10; $options = [ 'callbackUrl' => "https://your-domain.com/callback", 'callbackParams' => [ 'your key' => 'your value', 'your key' => 'your value', ], 'webhookUrl' => "https://your-domain.com/webhook", 'webhookParams' => [ 'your key' => 'your value', 'your key' => 'your value', ], 'language' => 'EN', 'currency' => 'USD', ]; $response = $paymentInstance->requestPayment($amount, $options); if ($createPayment->status) { return responseSuccess( [ 'url' => $createPayment->data->paymentUrl, ] ); } else { return responseError( [ 'message' => $createPayment->message ?? '', ] ); }
验证支付
/** * amount and paymentUid are required */ $paymentUid = ''; $amount = 10; $options = [ 'currency' => 'USD', ]; $response = $paymentInstance->verifyPayment($paymentUid, $amount, $options);
由 Payment4 提供支持