business-mastery/omnipay-mobilpay

MobilPay driver for the Omnipay PHP payment processing library

1.2.0 2015-01-23 07:19 UTC

This package is not auto-updated.

Last update: 2024-03-16 13:15:54 UTC


README

MobilPay driver for the Omnipay PHP payment processing library

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

Installation

Omnipay is installed via Composer. To install, simply add it to your composer.json file:

{
    "require": {
        "business-mastery/omnipay-mobilpay": "~1.0"
    }
}

And run composer to update your dependencies:

$ curl -s http://getcomposer.org/installer | php
$ php composer.phar update

Basic Usage

The following gateways are provided by this package:

  • MobilPay

Initiating payment request

$gateway = Omnipay::create('MobilPay');
$gateway->setMerchantId('1234-5678-9012-3456-7890');
$gateway->setPublicKey('/path/to/public.cer');

$response = $gateway->purchase([
    'amount'     => '10.00',
    'currency'   => 'RON',
    'orderId'    => 1,
    'confirmUrl' => 'http://example.com/ipn',
    'returnUrl'  => 'http://www.google.com',
    'details'    => 'Test payment',
    'testMode'   => true,
    'params'     => [
        'selected_package' => 1
    ]
])->send();

$response->redirect();

Processing IPN requests

$gateway = Omnipay::create('MobilPay');
$gateway->privateKeyPath('/path/to/private.key');

$response = $gateway->completePurchase($_POST)->send();
$response->sendResponse();

switch($response->getMessage())
{
    case 'confirmed_pending': // transaction is pending review. After this is done, a new IPN request will be sent with either confirmation or cancellation

        //update DB, SET status = "pending"

        break;
    case 'paid_pending': // transaction is pending review. After this is done, a new IPN request will be sent with either confirmation or cancellation

        //update DB, SET status = "pending"

        break;
    case 'paid': // transaction is pending authorization. After this is done, a new IPN request will be sent with either confirmation or cancellation

        //update DB, SET status = "open/preauthorized"

        break;
    case 'confirmed': // transaction is finalized, the money have been captured from the customer's account

        //update DB, SET status = "confirmed/captured"

        break;
    case 'canceled': // transaction is canceled

        //update DB, SET status = "canceled"

        break;
    case 'credit': // transaction has been refunded

        //update DB, SET status = "refunded"

        break;
}

For general usage instructions, please see the main Omnipay repository.

Support

If you are having general issues with Omnipay, we suggest posting on Stack Overflow. Be sure to add the omnipay tag so it can be easily found.

If you want to keep up to date with release anouncements, discuss ideas for the project, or ask more detailed questions, there is also a mailing list which you can subscribe to.

If you believe you have found a bug, please report it using the GitHub issue tracker, or better yet, fork the library and submit a pull request.