PHP code example of nattreid / paygol
1. Go to this page and download the library: Download nattreid/paygol library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
nattreid / paygol example snippets
/** @var \NAttreid\Paygol\IPaygolClientFactory @inject */
public $paygolClientFactory;
public function payment() {
$payment = $this->createPayment();
$payment->identifier = 12345678;
$payment->currency = 'EUR';
$payment->price = 100;
$payer = new Payer();
$payer->identifier = 123456789;
$payer->country = 'GB';
$payer->language = 'EUR';
$payer->email = '[email protected]';
$payer->firstName = 'John';
$payer->lastName = 'Doe';
$payer->ip = '123.123.123.123';
$paygolClient = $this->paygolClientFactory->create();
$paygolClient->setSuccessUrl('//domain.com/success');
$paygolClient->setErrorUrl('//domain.com/error');
$response = $paygolClient->payment($payment, $payer);
$this->order->setPaygolTransactionId($response->transactionId);
$presenter->sendResponse($response->response);
}
public function paygolCheckPayment(): void
{
$paygol = $this->paygolClientFactory->create();
$status = $paygol->checkout($paygolTransactionId);
if ($status->completed) {
} elseif ($status->rejected) {
}
}