A Laravel package to integrate with Gate To Pay (GateToPay) payment service, supporting both Trade API and CMS Open API.
- 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
You can install the package via composer:
composer require asciisd/gate-to-payPublish 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
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 migrateThe Trade API is used for card-related operations like retrieving cards, deposits, and withdrawals.
use ASCIISD\GateToPay\Facades\GateToPay;
$cards = GateToPay::getCustomerCards($customerId);use ASCIISD\GateToPay\Facades\GateToPay;
$response = GateToPay::cardCashOut([
'customerId' => 'customer-id',
'cardId' => 'card-id',
'depositAmount' => 100.00,
'transactionId' => 'unique-transaction-id',
'cardExpiryDate' => '09/25',
]);use ASCIISD\GateToPay\Facades\GateToPay;
$response = GateToPay::cardCashIn([
'customerId' => 'customer-id',
'cardId' => 'card-id',
'withdrawalAmount' => 100.00,
'transactionId' => 'unique-transaction-id',
'cardExpiryDate' => '09/25',
]);The CMS Open API is used for profile management operations.
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'
]);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();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
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 testNote: The phpunit.xml file is gitignored to prevent committing sensitive credentials to your repository.
The MIT License (MIT). Please see License File for more information.