dev-master
9999999-dev https://github.com/LZaplata/CertitradeCertitrade wrapper for Nette Framework.
New BSD
The Requires
by Lukáš Záplata
nette certitrade
Wallogit.com
2017 © Pedro Peláez
Certitrade wrapper for Nette Framework.
This is small Nette Framework wrapper for Certitrade gateway., (*1)
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;
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);
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
}
Certitrade wrapper for Nette Framework.
New BSD
nette certitrade