webimpian / bayarcash-php-sdk
Bayarcash支付网关PHP SDK。
1.2.0
2024-09-24 21:49 UTC
Requires
- php: ^7.4|^8.0|^8.1
- ext-json: *
- guzzlehttp/guzzle: ^6.3.1|^7.0
Requires (Dev)
- illuminate/support: ^7.0|^8.0|^9.0|^10.0|^11.0
- psr/simple-cache: ^2.0
README
简介
The Bayarcash SDK提供了一个与Bayarcash API交互的直观接口。
官方文档
安装
要在您的项目中安装SDK,您需要通过composer要求此包
composer require webimpian/bayarcash-php-sdk
基本用法
您可以这样创建SDK的实例
$bayarcash = new Webimpian\BayarcashSdk\Bayarcash(TOKEN_HERE); $bayarcash->useSandbox(); // call this method to switch to use sandbox
对于Laravel用户
// set value for BAYARCASH_API_TOKEN and BAYARCASH_API_SECRET_KEY in the .env file BAYARCASH_API_TOKEN= BAYARCASH_API_SECRET_KEY=
$bayarcash = app(\Webimpian\BayarcashSdk\Bayarcash::class); $bayarcash->useSandbox(); // call this method to switch to use sandbox
您可以使用以下方法为您的支付请求创建校验值
$paymentIntentRequestChecksum = $bayarcash->createPaymentIntenChecksumValue(API_SECRET_KEY, REQUEST_DATA); // append checksum value to your REQUEST_DATA // $data['checksum'] = $paymentIntentRequestChecksum
注意:校验值和校验验证是可选的,但为了增强安全性,建议使用。
使用以下方法发送您的支付请求
$response = $bayarcash->createPaymentIntent(REQUEST_DATA); header("Location: " . $response->url); // redirect payer to Bayarcash checkout page.
使用以下方法验证回调
// pre-transaction callback $validResponse = $bayarcash->verifyPreTransactionCallbackData(CALLBACK_DATA, API_SECRET_KEY); // transaction callback $validResponse = $bayarcash->verifyTransactionCallbackData(CALLBACK_DATA, API_SECRET_KEY);
FPX直接借记
1. FPX直接借记注册
$enrolmentRequestChecksum = $bayarcash->createFpxDIrectDebitEnrolmentChecksumValue(API_SECRET_KEY, REQUEST_DATA); // append checksum value to your REQUEST_DATA // $data['checksum'] = $enrolmentRequestChecksum $response = $this->bayarcashSdk->createFpxDirectDebitEnrollmentIntent($data); header("Location: " . $response->url); // redirect payer to Bayarcash Fpx Direct Debit enrolment page.
2. FPX直接借记维护
$maintenanceRequestChecksum = $bayarcash->createFpxDIrectDebitMaintenanceChecksumValue(API_SECRET_KEY, REQUEST_DATA); // append checksum value to your REQUEST_DATA // $data['checksum'] = $maintenanceRequestChecksum $response = $this->bayarcashSdk->createFpxDirectDebitMaintenanceIntent($data); header("Location: " . $response->url); // redirect payer to Bayarcash Fpx Direct Debit maintenance page.
3. FPX直接借记终止
$response = $this->bayarcashSdk->createFpxDirectDebitTerminationIntent($data); header("Location: " . $response->url); // redirect payer to Bayarcash Fpx Direct Debit termination page.
官方API文档
请参阅官方Bayarcash API文档以获取有关我们API的详细信息。
变更日志
请参阅变更日志以获取有关最近更改的更多信息。