Giter VIP home page Giter VIP logo

omnipay-easypaisa's Introduction

Omnipay: Easypaisa

Telenor Easypaisa gateway for the Omnipay PHP payment processing library

Omnipay is a framework agnostic, multi-gateway payment processing library for PHP 5.3+. This package implements easypaisa support for Omnipay.

Install

Via Composer

$ composer require moeen-basra/omnipay-easypaisa

Usage

This gateway provides seamless integration with easypaisa rest API integration.

Purchase Request

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);
}

Inquiry Request

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);
}

NOTE: You can check the tests Mock for sample response data.

License

This package is released under the MIT License. See the LICENSE file for details.

Contact

You can reach me here [email protected]

omnipay-easypaisa's People

Contributors

moeen-basra avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.