asciisd/gate-to-pay
Composer 安装命令:
composer require asciisd/gate-to-pay
包简介
Laravel package to integrate with Gate To Pay payment service
README 文档
README
A Laravel package to integrate with Gate To Pay (GateToPay) payment service, supporting both Trade API and CMS Open API.
Features
- Retrieve a list of cards
- Perform Cash Out transactions with internal OTP handling
- Perform Cash In transactions
- Create customer profiles via CMS Open API
- Handle request signature generation securely
- Log all request/response data for auditing
Installation
You can install the package via composer:
composer require asciisd/gate-to-pay
Configuration
Publish the config file with:
php artisan vendor:publish --provider="ASCIISD\GateToPay\GateToPayServiceProvider"
Then set up your environment variables in .env:
# Trade API Configuration
GATE_TO_PAY_TRADE_API_KEY=your-trade-api-key
GATE_TO_PAY_TRADE_USERNAME=your-username
GATE_TO_PAY_TRADE_PASSWORD=your-password
GATE_TO_PAY_TRADE_BASE_URL=https://tradetest.gatetopay.com
GATE_TO_PAY_TRADE_CURRENCY=USD
# CMS Open API Configuration
GATE_TO_PAY_CMS_API_KEY=your-cms-api-key
GATE_TO_PAY_CMS_BASE_URL=https://cmsopenapitest.gatetopay.com
Migrations
This package includes migrations to:
- Add a
gate_to_pay_customer_idcolumn to your users table - Create a
gate_to_pay_cardstable to store customer card information
To publish the migrations:
php artisan vendor:publish --provider="ASCIISD\GateToPay\GateToPayServiceProvider" --tag="migrations"
Then run the migrations:
php artisan migrate
Usage
Trade API Operations
The Trade API is used for card-related operations like retrieving cards, deposits, and withdrawals.
Get Customer Cards
use ASCIISD\GateToPay\Facades\GateToPay; $cards = GateToPay::getCustomerCards($customerId);
Card Cash Out (Deposit)
use ASCIISD\GateToPay\Facades\GateToPay; $response = GateToPay::cardCashOut([ 'customerId' => 'customer-id', 'cardId' => 'card-id', 'depositAmount' => 100.00, 'transactionId' => 'unique-transaction-id', 'cardExpiryDate' => '09/25', ]);
Card Cash In (Withdrawal)
use ASCIISD\GateToPay\Facades\GateToPay; $response = GateToPay::cardCashIn([ 'customerId' => 'customer-id', 'cardId' => 'card-id', 'withdrawalAmount' => 100.00, 'transactionId' => 'unique-transaction-id', 'cardExpiryDate' => '09/25', ]);
CMS Open API Operations
The CMS Open API is used for profile management operations.
Create a New Customer Profile
use ASCIISD\GateToPay\Facades\GateToPayCMS; $response = GateToPayCMS::createNewProfile([ 'gender' => 'M', 'firstName' => 'John', 'lastName' => 'Doe', 'birthDate' => '1990-01-01', 'nationalNumberOrPassport' => 'AB123456', 'cardType' => 'VISA', 'nationality' => 'US', 'address' => '123 Main St, New York, NY', 'phoneNumber' => '+1234567890', 'nameOnCard' => 'JOHN DOE', 'email' => 'john.doe@example.com' ]);
Generate a Customer ID
use ASCIISD\GateToPay\Facades\GateToPayCMS; $customerId = GateToPayCMS::generateCustomerId();
For backward compatibility, you can still use the original GateToPay facade for CMS operations:
use ASCIISD\GateToPay\Facades\GateToPay; // These methods delegate to the CMSApiService internally $response = GateToPay::createNewProfile([/* ... */]); $customerId = GateToPay::generateCustomerId();
Architecture
This package uses a clean architecture with separation of concerns:
- ApiClient: Handles HTTP requests, responses, and logging
- GateToPayService: Manages Trade API business logic
- CMSApiService: Manages CMS API business logic
- SignatureService: Handles secure signature generation
Testing
This package includes a comprehensive test suite. To run the tests, you need to set up the testing environment first:
- Copy the phpunit.xml.dist file to phpunit.xml:
cp phpunit.xml.dist phpunit.xml
- Update the phpunit.xml file with your test credentials:
<!-- Trade API Credentials --> <env name="GATE_TO_PAY_TRADE_API_KEY" value="your-trade-api-key-here"/> <env name="GATE_TO_PAY_TRADE_USERNAME" value="your-username-here"/> <env name="GATE_TO_PAY_TRADE_PASSWORD" value="your-password-here"/> <!-- CMS API Credentials --> <env name="GATE_TO_PAY_CMS_API_KEY" value="your-cms-api-key-here"/> <!-- Test Data --> <env name="GATE_TO_PAY_CUSTOMER_ID" value="your-customer-id-here"/>
- Run the tests:
composer test
Note: The phpunit.xml file is gitignored to prevent committing sensitive credentials to your repository.
License
The MIT License (MIT). Please see License File for more information.
asciisd/gate-to-pay 适用场景与选型建议
asciisd/gate-to-pay 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 23 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 04 月 26 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 asciisd/gate-to-pay 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 asciisd/gate-to-pay 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 23
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 14
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-04-26