PHP code example of devsdmf / payu-php-sdk
1. Go to this page and download the library: Download devsdmf/payu-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/ */
devsdmf / payu-php-sdk example snippets
// importing the libraries
use PayU\PayU,
PayU\Merchant\Credentials,
PayU\Transaction\Transaction;
// creating a credentials instance
$credentials = Credentials::factory('myKey','myLogin');
// creating a new PayU client instance
$payU = PayU::factory(PayU::LANGUAGE_ENGLISH);
// configuring the client
$payU->setCredentials($credentials);
$payU->setMerchantId('myMerchantId');
$payU->setNotifyUrl('http://foo.bar/notifications/payu');
$transaction = new Transaction();
// ... configuring the transaction object
// performing the transaction
$response = $payU->doPayment($transaction);
// check if the payment was approved
$response->isApproved();
// getting order status
$response = $payU->getOrderById('orderId');
// getting the response payload
$data = $response->getPayload();
$ composer