2017 © Pedro Peláez
 

library payumoney-php-sdk

PayUMoney library for PHP

image

razzbee/payumoney-php-sdk

PayUMoney library for PHP

  • Sunday, July 23, 2017
  • by razzbee
  • Repository
  • 1 Watchers
  • 0 Stars
  • 33 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 4 Versions
  • 3 % Grown

The README.md

StyleCI, (*1)

PayUMoney API for PHP

Simple library for accepting payments via PayUMoney., (*2)

Installation

To add this library to your project, simply add a dependency on razzbee/payumoney-php-sdk to your project's composer.json file. Here is a minimal example of a composer.json file:, (*3)

{
    "require": {
        "razzbee/payumoney-php-sdk": "1.*"
    }
}

Usage

You'll find a minimal usage example below., (*4)

Initialize purchase

<?php
// purchase.php

use Razzbee\PayUMoney\PayUMoney;

require 'vendor/autoload.php';

$payumoney = new PayUMoney([
    'merchantId' => 'YOUR_MERCHANT_ID',
    'secretKey'  => 'YOUR_SECRET_KEY',
    'salt'       =>  'YOUR_SALT',
    'testMode'   => true
]);

// All of these parameters are required!
$params = [
    'txnid'       => 'A_UNIQUE_TRANSACTION_ID',
    'amount'      => 10.50,
    'productinfo' => 'A book',
    'firstname'   => 'Peter',
    'email'       => 'abc@example.com',
    'phone'       => '1234567890',
    'surl'        => 'http://localhost/payumoney-php/return.php',
    'furl'        => 'http://localhost/payumoney-php/return.php',
];

// Redirects to PayUMoney
$payumoney->initializePurchase($params)->send();

Finalize purchase

<?php
// return.php

use Razzbee\PayUMoney\PayUMoney;

require 'vendor/autoload.php';

$payumoney = new PayUMoney([
    'merchantId' => 'YOUR_MERCHANT_ID',
    'secretKey'  => 'YOUR_SECRET_KEY',
    'salt'       =>  'YOUR_SALT',
    'testMode'   => true
]);

$result = $payumoney->completePurchase($_POST);

if ($result->checksumIsValid() && $result->getStatus() === PayUMoney::STATUS_COMPLETED) {
  print 'Payment was successful.';
} else {
  print 'Payment was not successful.';
}

The PurchaseResult has a few more methods that might be useful:, (*5)

$result = $payumoney->completePurchase($_POST);

// Returns Complete, Pending, Failed or Tampered
$result->getStatus(); 

// Returns an array of all the parameters of the transaction
$result->getParams();

// Returns the ID of the transaction
$result->getTransactionId();

// Returns true if the checksum is correct
$result->checksumIsValid();

The Versions

23/07 2017
05/10 2016
22/04 2016