1. Go to this page and download the library: Download gopay/payments-sdk-php 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/ */
$response = $gopay->createPayment([/* define your payment */]);
if ($response->hasSucceed()) {
echo "hooray, API returned {$response}";
return $response->json['gw_url']; // url for initiation of gateway
} else {
// errors format: https://doc.gopay.com/en/?shell#http-result-codes
echo "oops, API returned {$response->statusCode}: {$response}";
}
// create payment and pass url to template
$response = $gopay->createPayment([/* define your payment */]);
if ($response->hasSucceed()) {
$gatewayUrl => $response->json['gw_url'],
$embedJs => $gopay->urlToEmbedJs()
// render template
}
<form action="<?= $gatewayUrl
<form action="<?= $gatewayUrl
// register cache in optional service configuration
$gopay = GoPay\payments(
[/* your config */],
['cache' => new PrimitiveFileCache()]
);
use GoPay\Token\TokenCache;
use GoPay\Token\AccessToken;
class PrimitiveFileCache implements TokenCache
{
public function setAccessToken($client, AccessToken $t)
{
file_put_contents(__DIR__ . "/{$client}", serialize($t));
}
public function getAccessToken($client)
{
$file = __DIR__ . "/{$client}";
if (file_exists($file)) {
return unserialize(file_get_contents($file));
}
return null;
}
}
// register logger in optional service configuration
$gopay = GoPay\payments(
[/* your config */],
['logger' => new GoPay\Http\Log\PrintHttpRequest()]
);
bash
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.