OpenPayU transfer

Base:

$payU = $payment->online(
    new OpenPayUPayment(
        'posId, as int',
        'md5Key',
        'clientId as int',
        'clientSecret',
        OpenPayUPayment::ENVIRONMENT_SANDBOX or OpenPayUPayment::ENVIRONMENT_PRODUCTION
    )
);
$payU->oauthAuthorize();

Generate payment:

//at first we must declare at least one product:
$payU->setProductName('productName')
    ->setProductQuantity(1)
    ->setProductUnitPrice(15.00)
    ->addProduct();

//required
$payU->setNotifyUrl('https://ipn-url.com');
$payU->setCustomerIp('127.0.0.1');
$payU->setDescription('description');
$payU->setBuyerEmail('email@domain.tld');

//optional
$payU->setBuyerLanguage('pl');
$payU->setBuyerPhone('phone');
$payU->setBuyerFirstname('firstname');
$payU->setBuyerLastname('lastname');
$payU->setCurrencyCode('PLN');
$payU->setExtOrderId('customParam');
$payU->setVisibleDescription('visible description shown on payU checkout page');
$payU->setContinueUrl('https://google.com');

$payUPayment = $payU->generatePayment();
$payUPayment->getTransactionUrl();
$payUPayment->getTransactionId();

Verify notification signature:

$payUHeader = '';
foreach(getallheaders() as $name => $value)
{
    if($name == 'OpenPayu-Signature')
        $payUHeader = $value;
}

$payU->verifySignature($payUHeader, file_get_contents('php://input')); //returns boolean

Last updated