cashpayyy/sdk
Composer 安装命令:
composer require cashpayyy/sdk
包简介
Official CashPay Payment Gateway SDK for PHP
README 文档
README
Official PHP SDK for integrating with CashPay Payment Gateway.
Installation
Via Composer (Recommended)
You can install the SDK via Composer:
composer require cashpayyy/sdk
Via GitHub VCS
If you prefer to use the latest version directly from our repository, add this to your composer.json:
{
"require": {
"cashpayyy/sdk": "dev-main"
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/Annesbadusha/cashpay-php-sdk.git"
}
]
}
Manual Installation
Alternatively, clone the repository into your project and configure path-based loading.
Quick Start
<?php require_once 'vendor/autoload.php'; use CashPay\CashPay; $cashpay = new CashPay( apiKey: 'cpk_live_xxx', apiSecret: 'cps_live_xxx', environment: 'production' // or 'sandbox' );
Usage Examples
Check Balance
// Get unified balance $balance = $cashpay->balance->get(); echo "Total Balance: ₹" . ($balance['totalBalance'] / 100); // Get settlement balance $settlement = $cashpay->balance->getSettlement(); echo "Available for withdrawal: ₹" . ($settlement['availableWithdrawalAmount'] / 100); // Get payout balance $payout = $cashpay->balance->getPayout(); echo "Payout Balance: ₹" . ($payout['payoutBalance'] / 100);
Payins
// 1. Create a Hosted Payment Page (Direct Redirect Flow) $page = $cashpay->payins->createPaymentPage([ 'amount' => 10000, // ₹100 'orderId' => 'ORDER_123', 'customerName' => 'John Doe', 'customerEmail' => 'john@example.com', 'customerPhone' => '9876543210', 'returnUrl' => 'https://yoursite.com/payment/result' ]); echo "Payment URL: " . $page['paymentUrl']; // 2. Create UPI Intent (Minimal) $intent = $cashpay->payins->createIntent([ 'amount' => 1000, 'orderId' => 'ORDER_124' ]); echo "UPI DeepLink: " . $intent['intentUrl']; // 3. Create Card Payment $card = $cashpay->payins->createCard([ 'amount' => 10000, 'orderId' => 'ORDER_125', 'cardNumber' => '4111111111111111', 'expiryMonth' => '12', 'expiryYear' => '2025', 'cvv' => '123' ]); // 4. Create NetBanking $nb = $cashpay->payins->createNetBanking([ 'amount' => 10000, 'orderId' => 'ORDER_126', 'bankCode' => 'HDFC', 'returnUrl' => 'https://yoursite.com/callback' ]); // Get payin status by payment ID $status = $cashpay->payins->getStatus('payment-uuid'); // Get payin by order ID $payin = $cashpay->payins->getByOrderId('ORDER_124'); echo "Status: {$payin['status']}, UTR: {$payin['utr']}";
Payment Links
// Create a shareable payment link or QR $link = $cashpay->paymentLinks->create([ 'amount' => 50000, 'description' => 'Invoice #001', 'type' => 'one-time', // or 'reusable' 'outputType' => 'link' // or 'qr' ]); echo "Short URL: " . $link['shortUrl']; // List payment links $links = $cashpay->paymentLinks->list(page: 1, limit: 10, status: 'active'); // Deactivate a link $cashpay->paymentLinks->deactivate('link-uuid');
Beneficiaries & Bank Accounts
// Add a beneficiary for payouts $beneficiary = $cashpay->beneficiaries->create([ 'name' => 'John Doe', 'accountNumber' => '50100123456789', 'ifsc' => 'HDFC0001234' ]); // Add a merchant bank account for settlements $bank = $cashpay->bankAccounts->create([ 'accountNumber' => '50100123456789', 'ifsc' => 'HDFC0001234', 'accountHolderName' => 'My Business' ]);
Payouts
// Create a payout $payout = $cashpay->payouts->create( beneficiaryId: 'ben_xxx', amount: 10000, // ₹100 in paise referenceId: 'PAY-001', narration: 'Salary payment', mode: 'IMPS', idempotencyKey: 'unique-key' ); echo "Payout ID: {$payout['id']}, Status: {$payout['status']}"; // Create bulk payouts (max 100) $bulkResult = $cashpay->payouts->createBulk([ ['beneficiaryId' => 'ben_1', 'amount' => 10000, 'referenceId' => 'PAY-001'], ['beneficiaryId' => 'ben_2', 'amount' => 20000, 'referenceId' => 'PAY-002'], ], 'bulk-key'); echo "Success: {$bulkResult['successCount']}, Failed: {$bulkResult['failureCount']}"; // List payouts $payouts = $cashpay->payouts->list(page: 1, limit: 20, status: 'COMPLETED'); // Get payout by ID $payoutDetails = $cashpay->payouts->get('payout-uuid'); // Get payout by reference ID $payoutByRef = $cashpay->payouts->getByReferenceId('PAY-001'); // Cancel payout $cancelled = $cashpay->payouts->cancel('payout-uuid');
Settlements
// Create settlement with saved bank account $settlement = $cashpay->settlements->create( amount: 100000, // ₹1000 in paise bankAccountId: 'bank_xxx', referenceId: 'SET-001', idempotencyKey: 'unique-key' ); // Create settlement with direct bank details $directSettlement = $cashpay->settlements->create( amount: 100000, accountNumber: '50100123456789', ifsc: 'HDFC0001234', accountHolderName: 'John Doe', referenceId: 'SET-002' ); // Create bulk settlements $bulkSettlements = $cashpay->settlements->createBulk([ ['amount' => 50000, 'bankAccountId' => 'bank_1', 'referenceId' => 'SET-001'], ['amount' => 75000, 'bankAccountId' => 'bank_2', 'referenceId' => 'SET-002'], ]); // List settlements $settlements = $cashpay->settlements->list(status: 'COMPLETED'); // Get settlement by ID $settlementDetails = $cashpay->settlements->get('settlement-uuid'); // Cancel settlement $cancelledSettlement = $cashpay->settlements->cancel('settlement-uuid');
Webhook Verification
<?php // webhook.php require_once 'vendor/autoload.php'; use CashPay\CashPay; $cashpay = new CashPay('cpk_live_xxx', 'cps_live_xxx'); $payload = file_get_contents('php://input'); $signature = $_SERVER['HTTP_X_WEBHOOK_SIGNATURE'] ?? ''; $isValid = $cashpay->verifyWebhook($payload, $signature, 'your-webhook-secret'); if (!$isValid) { http_response_code(401); echo 'Invalid signature'; exit; } $event = json_decode($payload, true); switch ($event['type']) { case 'payin.completed': // Handle payment completed break; case 'payout.completed': // Handle payout completed break; case 'settlement.completed': // Handle settlement completed break; } http_response_code(200); echo 'OK';
Error Handling
use CashPay\CashPay; use CashPay\CashPayException; try { $payout = $cashpay->payouts->create( beneficiaryId: 'invalid-id', amount: 10000 ); } catch (CashPayException $e) { echo "Error: {$e->getMessage()}\n"; echo "Status: {$e->statusCode}\n"; echo "Code: {$e->errorCode}\n"; print_r($e->details); }
Configuration Options
| Option | Type | Default | Description |
|---|---|---|---|
apiKey |
string | required | Your API key |
apiSecret |
string | required | Your API secret |
environment |
string | 'production' | 'sandbox' or 'production' |
baseUrl |
string | auto | Custom API base URL |
timeout |
int | 30 | Request timeout in seconds |
Requirements
- PHP >= 7.4
- Guzzle HTTP Client >= 7.0
Support
- Documentation: https://docs.cashpay.com
- Email: support@cashpay.com
- GitHub Issues: https://github.com/cashpay/cashpay-php-sdk/issues
cashpayyy/sdk 适用场景与选型建议
cashpayyy/sdk 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 02 月 20 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「payment」 「gateway」 「india」 「settlement」 「payout」 「upi」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 cashpayyy/sdk 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 cashpayyy/sdk 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 cashpayyy/sdk 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
repository php library
Payyo Gateway for the Omnipay payment processing library
Payment Integration with Paytm.
Razorpay Omnipay 3.0 plugin for accepting payments
Razorpay Magento 2.3 plugin for accepting payments.
Client library to send SMS using Comilio SMS Gateway API (https://www.comilio.it)
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 26
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-02-20