bileto / omnipay-payu
PayU gateway for Omnipay payment processing library
Installs: 17 549
Dependents: 1
Suggesters: 0
Security: 0
Stars: 5
Watchers: 10
Forks: 17
Open Issues: 1
Requires
- php: ^7.2|^8
- ext-curl: *
- ext-json: *
- omnipay/common: ^3
- openpayu/openpayu_php_sdk: ^2.2
Requires (Dev)
- mockery/mockery: ^1.4
- omnipay/tests: ^4.1
- php-http/guzzle7-adapter: ^1.0
- phpstan/phpstan: ^0.12.9
- phpunit/phpunit: ^9
- symfony/var-dumper: ^5.3
- vlucas/phpdotenv: ^5.3
README
PayU driver for the Omnipay PHP payment processing library
Omnipay is a framework agnostic, multi-gateway payment processing library for PHP 5.3+. This package implements PayU Online Payment Gateway support for Omnipay.
PayU REST API 2.1 documentation
This implementation uses OAuth 2
Installation
Omnipay is installed via Composer. To install, simply add it
to your composer.json
file:
{ "require": { "bileto/omnipay-payu": "~0.1.1" } }
TL;DR
<?php require 'vendor/autoload.php'; use Omnipay\PayU\GatewayFactory; $dotenv = new Dotenv\Dotenv(__DIR__); $dotenv->load(); // default is official sandbox $posId = isset($_ENV['POS_ID']) ? $_ENV['POS_ID'] : '300046'; $secondKey = isset($_ENV['SECOND_KEY']) ? $_ENV['SECOND_KEY'] : '0c017495773278c50c7b35434017b2ca'; $oAuthClientSecret = isset($_ENV['OAUTH_CLIENT_SECRET']) ? $_ENV['OAUTH_CLIENT_SECRET'] : 'c8d4b7ac61758704f38ed5564d8c0ae0'; $gateway = GatewayFactory::createInstance($posId, $secondKey, $oAuthClientSecret, true); try { $orderNo = '12345677'; $returnUrl = 'http://localhost:8000/gateway-return.php'; $description = 'Shopping at myStore.com'; $purchaseRequest = [ 'customerIp' => '127.0.0.1', 'continueUrl' => $returnUrl, 'merchantPosId' => $posId, 'description' => $description, 'currencyCode' => 'PLN', 'totalAmount' => 15000, 'exOrderId' => $orderNo, 'buyer' => (object)[ 'email' => 'test@example.com', 'firstName' => 'Peter', 'lastName' => 'Morek', 'language' => 'pl' ], 'products' => [ (object)[ 'name' => 'Lenovo ThinkPad Edge E540', 'unitPrice' => 15000, 'quantity' => 1 ] ], 'payMethods' => (object) [ 'payMethod' => (object) [ 'type' => 'PBL', // this is for card-only forms (no bank transfers available) 'value' => 'c' ] ] ]; $response = $gateway->purchase($purchaseRequest); echo "TransactionId: " . $response->getTransactionId() . PHP_EOL; echo 'Is Successful: ' . (bool) $response->isSuccessful() . PHP_EOL; echo 'Is redirect: ' . (bool) $response->isRedirect() . PHP_EOL; // Payment init OK, redirect to the payment gateway echo $response->getRedirectUrl() . PHP_EOL; } catch (\Exception $e) { dump((string)$e); }
For custom sandbox payu gateway prepare .env
file based on .env-default
.
Test cards
Positive authorization
Negative authorization
The expiration date of cards range should be valid date range, value CVC / CVV2 (3 random digits). Sandbox environment doesn't support 3DS.