webimpian/bayarcash-php-sdk
Composer 安装命令:
composer require webimpian/bayarcash-php-sdk
包简介
Bayarcash payment gateway PHP Sdk.
README 文档
README
Introduction
The Bayarcash SDK provides an expressive interface for interacting with Bayarcash's Payment Gateway API. This SDK supports both API v2 and v3, with enhanced features available in v3.
Official Documentation
Installation
To install the SDK in your project you need to require the package via composer:
composer require webimpian/bayarcash-php-sdk
Basic Usage
You can create an instance of the SDK like so:
$bayarcash = new Webimpian\BayarcashSdk\Bayarcash(TOKEN_HERE); $bayarcash->useSandbox(); // call this method to switch to use sandbox
For Laravel user:
// 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
Configuration Options
// Optional: Set API version (default is 'v2') $bayarcash->setApiVersion('v3');
Available Payment Channels
The SDK supports multiple payment channels:
Bayarcash::FPX // FPX Online Banking Bayarcash::MANUAL_TRANSFER // Manual Bank Transfer Bayarcash::FPX_DIRECT_DEBIT // FPX Direct Debit Bayarcash::FPX_LINE_OF_CREDIT // FPX Line of Credit Bayarcash::DUITNOW_DOBW // DuitNow Online Banking Bayarcash::DUITNOW_QR // DuitNow QR Bayarcash::SPAYLATER // ShopeePayLater Bayarcash::BOOST_PAYFLEX // Boost PayFlex Bayarcash::QRISOB // QRIS Online Banking Bayarcash::QRISWALLET // QRIS Wallet Bayarcash::NETS // NETS Bayarcash::CREDIT_CARD // Credit Card Bayarcash::ALIPAY // Alipay Bayarcash::WECHATPAY // WeChat Pay Bayarcash::PROMPTPAY // PromptPay Bayarcash::TOUCH_N_GO // Touch 'n Go eWallet Bayarcash::BOOST_WALLET // Boost Wallet Bayarcash::GRABPAY // GrabPay Bayarcash::GRABPL // Grab PayLater Bayarcash::SHOPEE_PAY // ShopeePay
Core Features
Portal Management
// Get all available portals $portals = $bayarcash->getPortals(); // Get available payment channels for a specific portal $channels = $bayarcash->getChannels('your_portal_key');
FPX Bank Integration
// Get list of available FPX banks $banks = $bayarcash->fpxBanksList();
Payment Processing
Note: The checksum value and checksum validation are optional, but it is recommended for enhanced security.
// Generate checksum for payment intent $paymentIntentRequestChecksum = $bayarcash->createPaymentIntenChecksumValue(API_SECRET_KEY, REQUEST_DATA); // append checksum value to your REQUEST_DATA $data['checksum'] = $paymentIntentRequestChecksum; // Send payment request $response = $bayarcash->createPaymentIntent(REQUEST_DATA); header("Location: " . $response->url); // redirect payer to Bayarcash checkout page.
Callback Verification
// Verify callbacks // pre-transaction callback $validPreTransaction = $bayarcash->verifyPreTransactionCallbackData(CALLBACK_DATA, API_SECRET_KEY); // transaction callback $validTransaction = $bayarcash->verifyTransactionCallbackData(CALLBACK_DATA, API_SECRET_KEY); // return URL callback $validReturnUrl = $bayarcash->verifyReturnUrlCallbackData(CALLBACK_DATA, API_SECRET_KEY);
Payment Intent Management
// Get payment intent details (V3 API only) $paymentIntent = $bayarcash->getPaymentIntent('payment_intent_id');
Transaction Management
// Get single transaction $transaction = $bayarcash->getTransaction('transaction_id'); // V3 API Features if ($bayarcash->getApiVersion() === 'v3') { // Get all transactions with filters $transactions = $bayarcash->getAllTransactions([ 'order_number' => 'ORDER123', 'status' => '3', 'payment_channel' => Bayarcash::FPX, 'exchange_reference_number' => 'REF123', 'payer_email' => 'customer@example.com' ]); // Specialized transaction queries $orderTransactions = $bayarcash->getTransactionByOrderNumber('ORDER123'); $emailTransactions = $bayarcash->getTransactionsByPayerEmail('customer@example.com'); $statusTransactions = $bayarcash->getTransactionsByStatus('3'); $channelTransactions = $bayarcash->getTransactionsByPaymentChannel(Bayarcash::FPX); $refTransaction = $bayarcash->getTransactionByReferenceNumber('REF123'); }
FPX Direct Debit Features
1. FPX Direct Debit Enrolment
$enrolmentRequestChecksum = $bayarcash->createFpxDirectDebitEnrolmentChecksumValue(API_SECRET_KEY, REQUEST_DATA); // append checksum value to your REQUEST_DATA $data['checksum'] = $enrolmentRequestChecksum; $response = $bayarcash->createFpxDirectDebitEnrollmentIntent($data); header("Location: " . $response->url); // redirect payer to Bayarcash Fpx Direct Debit enrolment page.
2. FPX Direct Debit Maintenance
$maintenanceRequestChecksum = $bayarcash->createFpxDirectDebitMaintenanceChecksumValue(API_SECRET_KEY, REQUEST_DATA); // append checksum value to your REQUEST_DATA $data['checksum'] = $maintenanceRequestChecksum; $response = $bayarcash->createFpxDirectDebitMaintenanceIntent($data); header("Location: " . $response->url); // redirect payer to Bayarcash Fpx Direct Debit maintenance page.
3. FPX Direct Debit Termination
$response = $bayarcash->createFpxDirectDebitTerminationIntent($data); header("Location: " . $response->url); // redirect payer to Bayarcash Fpx Direct Debit termination page.
Security Recommendations
- Always use checksums for payment requests when possible
- Verify all callbacks using the provided verification methods
- Store and validate transaction IDs to prevent duplicate processing
- Use HTTPS for all API communications
- Keep your API tokens and secret keys secure
API Documentation
Please refer to the Official Bayarcash API Documentation for detailed information about our API.
Support
For support questions, please contact Bayarcash support or raise an issue in the repository.
Changelog
Please see CHANGELOG for version update history.
License
This SDK is open-sourced software licensed under the MIT license.
webimpian/bayarcash-php-sdk 适用场景与选型建议
webimpian/bayarcash-php-sdk 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 8.28k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2024 年 08 月 30 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 webimpian/bayarcash-php-sdk 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 webimpian/bayarcash-php-sdk 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 8.28k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 5
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-08-30