2017 © Pedro Peláez
 

library certitrade

Certitrade wrapper for Nette Framework.

image

lzaplata/certitrade

Certitrade wrapper for Nette Framework.

  • Monday, February 5, 2018
  • by Zap
  • Repository
  • 1 Watchers
  • 0 Stars
  • 3 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Certitrade

This is small Nette Framework wrapper for Certitrade gateway., (*1)

Installation

The easiest way to install library is via Composer., (*2)

$ composer require lzaplata/certitrade: dev-master

or edit composer.json in your project, (*3)

"require": {
        "lzaplata/certitrade": "dev-master"
}

You have to register the library as extension in config.neon file., (*4)

extensions:
        payu: LZaplata\Certitrade\DI\Extension

Now you can set parameters..., (*5)

certitrade:
        merchantId      : *
        apiKey          : *
        sandbox         : true
        language        : en        // must be 2 digits language code
        currency        : SEK       // must be 3 digits uppercase currency code

...and autowire library to presenter, (*6)

use LZaplata\Certitrade\Service;

/** @var Service @inject */
public $certitrade;

Usage

Before payment

In first step you must create new payment., (*7)

$payment = $this->certitrade->createOrder([
        "description" => $description,           
        "amount" => $price,                         // order price in lowest currency unit (1 CZK = 100)
        "reference" => $id,                         // eshop unique id
        "return_url" => $returnUrl,                 // return url from gateway (no matter of payment result)
        "callback_url" => $callbackUrl,             // url to report back via POST call while payment is under way
]);

Second step decides if creating order is successful..., (*8)

try {
        $response = $this->certitrade->pay($payment);
} catch (\Exception $e) {
        print $e->getMessage();
}

...before redirecting to gateway you can get Certitrade ID and merge it with your order, (*9)

$certitradeId = $response->id;

// updates order
$this->updateOrder($certitradeId);

...and finally you can redirect to gateway., (*10)

$this->sendResponse($response);

After payment

You can get payment via Certitrade ID..., (*11)

$payment = $this->certitrade->getPayment($certitradeId);

...end decide if payment has been payed., (*12)

if ($this->certitrade->isPaid($payment)) {
    // do something
} else {
    // otherwise do something else
}

The Versions

05/02 2018

dev-master

9999999-dev https://github.com/LZaplata/Certitrade

Certitrade wrapper for Nette Framework.

  Sources   Download

New BSD

The Requires

 

by Lukáš Záplata

nette certitrade