2017 © Pedro Peláez
 

library omnipay-instamojo

Instamojo API v1.1 driver for the Omnipay PHP payment processing library

image

gentor/omnipay-instamojo

Instamojo API v1.1 driver for the Omnipay PHP payment processing library

  • Wednesday, May 10, 2017
  • by gentor
  • Repository
  • 1 Watchers
  • 0 Stars
  • 646 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 1 Versions
  • 24 % Grown

The README.md

Omnipay: Instamojo

Instamojo driver for the Omnipay PHP payment processing library, (*1)

Omnipay is a framework agnostic, multi-gateway payment processing library for PHP 5.3+. This package implements Instamojo Payments API v1.1., (*2)

Installation

Omnipay is installed via Composer. To install, simply run:, (*3)

composer require gentor/omnipay-instamojo

Purchase

use Omnipay\Omnipay;

// Setup payment gateway
$gateway = Omnipay::create('Instamojo');
$gateway->setApiKey('abc123');
$gateway->setAuthToken('abc123');

// Send purchase request
$response = $gateway->purchase(
    [
        'amount' => '10.00',
        'purpose' => 'Instamojo Payment'
    ]
)->send();

// Process response
if ($response->isSuccessful() && $response->isRedirect()) {

    // Redirect to offsite payment gateway
    // print_r($response->getData());
    // echo $response->getTransactionStatus();
    $response->redirect();

} else {

    // Request failed
    echo $response->getMessage();
}

Complete Purchase

// Send complete purchase request
$response = $gateway->completePurchase(
    [
        'transactionReference' => $_GET['payment_id'],
    ]
)->send();

// Process response
if ($response->isSuccessful()) {

    // Request was successful
    print_r($response->getData());
    echo $response->getTransactionStatus();

} else {

    // Request failed
    echo $response->getMessage();
}

Refund

// Send refund request
$response = $gateway->refund(
    [
        'transactionReference' => $payment_id,
    ]
)->send();

// Process response
if ($response->isSuccessful()) {

    // Request was successful
    print_r($response->getData());
    echo $response->getTransactionStatus();

} else {

    // Request failed
    echo $response->getMessage();
}

Fetch Payment Request

// Send fetch payment request
$response = $gateway->fetchPaymentRequest(
    [
        'transactionReference' => $payment_request_id,
    ]
)->send();

// Process response
if ($response->isSuccessful()) {

    // Request was successful
    print_r($response->getData());
    echo $response->getTransactionStatus();

} else {

    // Request failed
    echo $response->getMessage();
}

Webhook

use Omnipay\Omnipay;

// Setup payment gateway
$gateway = Omnipay::create('Instamojo');
$gateway->setSalt('abc123');

// Payment notification request
$response = $gateway->acceptNotification()->send();

// Process response
if ($response->isSuccessful()) {

    // Request was successful
    print_r($response->getData());
    echo $response->getTransactionReference();
    echo $response->getTransactionStatus();

} else {

    // Request failed
    echo $response->getMessage();
}

Instamojo API v1.1 Documentation

The Versions

10/05 2017

dev-master

9999999-dev https://github.com/gentor/omnipay-instamojo

Instamojo API v1.1 driver for the Omnipay PHP payment processing library

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

payment pay gateway merchant purchase omnipay instamojo