moeen-basra/omnipay-easypaisa

Easypaisa 驱动程序,用于 Omnipay PHP 支付处理库

1.0.2 2023-10-21 17:49 UTC

This package is auto-updated.

Last update: 2024-09-21 19:43:09 UTC


README

Telenor Easypaisa 网关,用于 Omnipay PHP 支付处理库

Omnipay 是一个框架无关的多网关支付处理库,适用于 PHP 5.3+。此包实现了 Omnipay 对 easypaisa 的支持。

安装

通过 Composer

$ composer require moeen-basra/omnipay-easypaisa

使用方法

此网关提供与 easypaisa REST API 无缝集成的功能。

购买请求

use Omnipay\Omnipay;

$gateway = Omnipay::create('Easypaisa');

// initialize with array
$gateway->initialize([
    'storeId' => 'your-store-id',
    'username' => 'your-username',
    'password' => 'your-password',
    'accountNum' => 'your-account-number',
]);

// or individual properties setter

$gateway->setAcountId('your-store-id')
    ->setUsername('your-username')
    ->setPassword('your-password')
    ->setAccountNum('your-account-number');

// set the test mode if needed
$gateway->setTestMode(true);

try {
    $parameters = [
        'transactionId' => '<transId>',
        'amount' => '<amount>', // float
        'paymentMethod' => 'OTC', // OTC or MA
        'emailAddress' => 'customer-email',
        'mobileNumber' => 'customer-phone', // 10 digits phone 03xxxxxxxxx
        'tokenExpiry' => (30 * 60), // 30 minutes
        'extra' => [
            'field_1' => 'value_1',
            'field_2' => 'value_2',
            'field_3' => 'value_3',
            'field_4' => 'value_4',
            'field_5' => 'value_5'
        ],
    ];
    
    $response = $gateway->purchase($parameters)->send();
    
    // var_dump($response->getData());
    
    if ($response->isSuccessful()) {
     // handle success response
    } else {
    // handle failed response
    }
} catch (\Throwable $exception) {
    var_dump($exception);
}

查询请求

use Omnipay\Omnipay;

$gateway = Omnipay::create('Easypaisa');

// initialize with array
$gateway->initialize([
    'storeId' => 'your-store-id',
    'username' => 'your-username',
    'password' => 'your-password',
    'accountNum' => 'your-account-number',
]);

// set the test mode if needed
$gateway->setTestMode(true);

try {
    $parameters = [
        'transactionId' => '<transId>',
    ];
    
    $response = $gateway->fetchTransaction($parameters)->send();
    
    // var_dump($response->getData());
    
    if ($response->isSuccessful()) {
     // handle success response
    } else {
    // handle failed response
    }
} catch (\Throwable $exception) {
    var_dump($exception);
}

注意:您可以检查测试 Mock 以获取示例响应数据。

许可证

此软件包在 MIT 许可证 下发布。有关详细信息,请参阅 LICENSE 文件。

联系方式

您可以通过 moeen.basra@gamil.com 联系我