1. Go to this page and download the library: Download dpayglobal/dpay-php-sdk 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/ */
dpayglobal / dpay-php-sdk example snippets
use DPay\DPayClient;
use DPay\Money;
use DPay\Payment\RegisterPaymentRequest;
use DPay\Payment\ReturnUrls;
use DPay\Payment\TransactionType;
$dpay = new DPayClient([
'service' => 'nazwa_serwisu',
'secret_hash' => 'twoj_secret_hash',
]);
$payment = $dpay->payments->register(
RegisterPaymentRequest::create(
Money::pln(1050),
TransactionType::TRANSFERS,
new ReturnUrls(
'https://twojsklep.pl/sukces',
'https://twojsklep.pl/blad',
'https://twojsklep.pl/ipn'
)
)
->withDescription('Zamówienie #1234')
->withCustom('order-1234')
);
if ($payment->getRedirectUrl() !== null) {
header('Location: ' . $payment->getRedirectUrl());
exit;
}
use DPay\Exception\SignatureVerificationException;
use DPay\Ipn\IpnEvent;
use DPay\Ipn\IpnVerifier;
try {
$event = IpnVerifier::constructEvent(
(string) file_get_contents('php://input'),
'twoj_secret_hash'
);
if ($event->isTransfer() || $event->isCapture()) {
markOrderAsPaid($event->getId(), $event->getAmount());
}
http_response_code(200);
echo IpnEvent::ACK;
} catch (SignatureVerificationException $exception) {
http_response_code(400);
echo 'Invalid signature';
}
use DPay\Money;
$dpay->refunds->create('identyfikator-transakcji');
$dpay->refunds->create('identyfikator-transakcji', Money::pln(500), 'reklamacja');
$availability = $dpay->refunds->checkAvailability('identyfikator-transakcji');
if ($availability->isAvailable()) {
// ...
}