PHPackages                             basgate/laravel-payment-sdk - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Payment Processing](/categories/payments)
4. /
5. basgate/laravel-payment-sdk

ActiveLibrary[Payment Processing](/categories/payments)

basgate/laravel-payment-sdk
===========================

Laravel Payment Gateway SDK for BAS Platform - API-only payment integration

v1.0.2(7mo ago)13851MITPHP

Since Nov 11Pushed 7mo agoCompare

[ Source](https://github.com/basgate/laravel-payment-sdk)[ Packagist](https://packagist.org/packages/basgate/laravel-payment-sdk)[ RSS](/packages/basgate-laravel-payment-sdk/feed)WikiDiscussions main Synced 3w ago

READMEChangelogDependenciesVersions (4)Used By (0)

Laravel Payment Gateway SDK for BAS Platform
============================================

[](#laravel-payment-gateway-sdk-for-bas-platform)

This SDK provides API-only payment integration with the BAS Super App platform for Laravel applications. It allows merchants to accept payments through BAS wallet and various payment methods supported by the BAS platform without requiring a Mini App implementation.

Features
--------

[](#features)

- ✅ Payment Initiation - Start payment transactions
- ✅ Transaction Status - Check payment status
- ✅ Refund Processing - Process refunds
- ✅ Token Authentication - Automatic bearer token management
- ✅ Signature Verification - Secure API communication with AES-256-CBC encryption
- ✅ API-Only - No UI, routes, or controllers (pure backend SDK)

Installation
------------

[](#installation)

1. **Require the package via Composer:**

    ```
    composer require basgate/laravel-payment-sdk
    ```
2. **The service provider will be automatically registered via Laravel's package auto-discovery.**

Requirements
------------

[](#requirements)

- **PHP**: 8.1, 8.2, or 8.3
- **Laravel**: 10.x, 11.x, or 12.x
- **PHP Extensions**: OpenSSL, JSON

This package uses modern PHP features including typed properties, union types, and return type declarations.

Configuration
-------------

[](#configuration)

1. **Add your BAS credentials to your `.env` file:**

    ```
    BAS_BASE_URL=https://api.basgate.com
    BAS_CLIENT_ID=your_client_id
    BAS_CLIENT_SECRET=your_client_secret
    BAS_APP_ID=your_app_id
    BAS_MERCHANT_KEY=your_merchant_key
    BAS_ENVIRONMENT=production  # or staging
    ```
2. **Environment Variable Descriptions:**

    - **`BAS_BASE_URL`**: The base URL for the BAS API platform
        - Staging: `https://staging-api.basgate.com`
        - Production: `https://api.basgate.com`
    - **`BAS_CLIENT_ID`**: Your Client ID provided by BAS
    - **`BAS_CLIENT_SECRET`**: Your Client Secret (keep this secure)
    - **`BAS_APP_ID`**: Your App ID provided by BAS
    - **`BAS_MERCHANT_KEY`**: Merchant Key for signature generation
    - **`BAS_IV`**: (Optional) 16-byte Initialization Vector - uses BAS default if not set
    - **`BAS_ENVIRONMENT`**: Set to `staging` or `production`

    **Security Notes:**

    - Never hardcode credentials in your code
    - Keep your merchant key secure and never commit it to version control
    - The IV uses a default constant provided by BAS - only override if instructed by BAS support
    - Keep `BAS_CLIENT_SECRET` and `BAS_MERCHANT_KEY` secure
    - Do not commit credentials to version control

Usage
-----

[](#usage)

### Using the Facade

[](#using-the-facade)

```
use Bas\LaravelPayment\Facades\BasPaymentFacade as BasPayment;

// Initiate a payment transaction
$orderId = 'ORDER_' . time();
$amount = 100.00;
$currency = 'YER';

$payment = BasPayment::initiateTransaction($orderId, $amount, $currency);

if ($payment['status'] === 1 && $payment['code'] === '1111') {
    $trxToken = $payment['body']['trxToken'];
    // Store trxToken for later reference
}
```

### Check Transaction Status

[](#check-transaction-status)

```
use Bas\LaravelPayment\Facades\BasPaymentFacade as BasPayment;

$orderId = 'ORDER_123';
$status = BasPayment::checkTransactionStatus($orderId);

if ($status['body']['transaction_status'] === 'SUCCESS') {
    // Payment successful - update order status
} elseif ($status['body']['transaction_status'] === 'FAILED') {
    // Payment failed - handle accordingly
}
```

### Process Refund

[](#process-refund)

```
use Bas\LaravelPayment\Facades\BasPaymentFacade as BasPayment;

$trxToken = 'your_transaction_token';
$reason = 'Customer requested refund';

$refund = BasPayment::refund($trxToken, $reason);

if ($refund['status'] === 1) {
    // Refund processed successfully
}
```

### Send Notification

[](#send-notification)

```
use Bas\LaravelPayment\Facades\BasPaymentFacade as BasPayment;

$orderId = 'ORDER_123';
$message = 'Your payment has been received successfully';
```

API Methods
-----------

[](#api-methods)

### `initiateTransaction($orderId, $amount, $currency)`

[](#initiatetransactionorderid-amount-currency)

Initiates a new payment transaction.

**Parameters:**

- `$orderId` (string): Unique order identifier
- `$amount` (float): Payment amount
- `$currency` (string): Currency code (e.g., 'YER', 'USD')

**Returns:** Array with transaction details including `trxToken`

### `checkTransactionStatus($orderId)`

[](#checktransactionstatusorderid)

Checks the status of a payment transaction.

**Parameters:**

- `$orderId` (string): Order identifier

**Returns:** Array with transaction status

### `refund($trxToken, $reason = 'test')`

[](#refundtrxtoken-reason--test)

Processes a refund for a completed transaction.

**Parameters:**

- `$trxToken` (string): Transaction token from initiate response
- `$reason` (string): Reason for refund (optional)

**Returns:** Array with refund status

Response Format
---------------

[](#response-format)

All API responses follow this structure:

```
[
    'status' => 1,  // 1 = success, 0 = failure
    'code' => '1111',  // Response code
    'head' => [
        'responseCode' => 'string',
        'responseMessage' => 'string',
        'signature' => 'string',  // For secured endpoints
    ],
    'body' => [
        // Response data
    ]
]
```

Complete Example
----------------

[](#complete-example)

```
