- Notifications
You must be signed in to change notification settings - Fork1
A Laravel package to encapsulate global PayU requests.
License
NotificationsYou must be signed in to change notification settings
somosgad/laravel-payu
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
A Laravel package to encapsulate global PayU requests. More info atPaymentsOS Docs.
Currently in development
ViaComposer
composer require somosgad/laravel-payu:dev-master
Set your PayU configs at.env
file
PAYU_APP_ID=PAYU_ENV=PAYU_PUBLIC_KEY=PAYU_PRIVATE_KEY=PAYU_PROVIDER=
Your.env
file must end up looking like:
PAYU_APP_ID=com.foo.barPAYU_ENV=testPAYU_PUBLIC_KEY=g6l2g4yn-nvgp-uiil-6fm7-d2337cegunmzPAYU_PRIVATE_KEY=68lhkww3-lkgw-4mcc-r21m-cf8nnnx3wj2kPAYU_PROVIDER="PayU Argentina"
php artisan vendor:publish --provider="SomosGAD_\LaravelPayU\LaravelPayUServiceProvider"
useSomosGAD_\LaravelPayU\LaravelPayU;$payu =newLaravelPayU;
$amount =2000;$currency ='USD';$payment =$payu->createPayment($amount,$currency);
$card_number ='4111111111111111';$credit_card_cvv ='123';$expiration_date ='10/29';$holder_name ='John Doe';$token_type ='credit_card';$token =$payu->createToken($card_number,$credit_card_cvv,$expiration_date,$holder_name,$token_type);
$authorization =$payu->createAuthorization($payment['id'],$encrypted_cvv,$token);
$capture =$payu->createCapture($payment['id'],$payment['amount']);
$charge =$payu->createCharge($payment['id'],$token);
$charge =$payu->createCharge2($payment['id'], ['payment_method' => ['source_type' =>'cash','type' =>'untokenized','vendor' =>'COBRO_EXPRESS','additional_details' => ['order_language' =>'en','cash_payment_method_vendor' =>'COBRO_EXPRESS','payment_method' =>'PSE','payment_country' =>'ARG', ], ],'reconciliation_id' =>time(),];
* Notes:
order_language
is always uppercased for you;- Omitted
reconciliation_id
gets created; - Only
ARG
payment_country
are able to create cash charges for Argentina; - Payments for cash charges must be created with
customer_id
set and customer must haveshipping_address
set with at least one field, otherwise, the receipt won't be printable or downloadable.
$customer =$payu->createCustomer(['customer_reference' =>'johntravolta18021954',]);
* Notes:
customer_reference
s are unique, API won't create customers for same references. Choose something like an ID, document or anything else unique and immutable to set ascustomer_reference
.- PayU Argentina won't print or download PDF if you haven't set customer's
shipping_address
with at least one info (likecountry
or any other field).
$customer =$payu->createCustomer(['customer_reference' =>'johntravolta18021954','email' =>'john@travolta.com',]);
$customer =$payu->createCustomer(['customer_reference' =>'johntravolta18021954','email' =>'john@travolta.com','first_name' =>'John','last_name' =>'Travolta','additional_details' => ['extra1' =>'Info Extra 1','extra2' =>'Info Extra 2', ],'shipping_address' => ['country' =>'ARG','state' =>'TX','city' =>'Customer Shipping City','line1' =>'10705 Old Mill Rd','line2' =>'10706 Young Mill Rd','zip_code' =>'75402-3435','title' =>'Dr.','first_name' =>'John','last_name' =>'Travolta','phone' =>'23645963','email' =>'john@travolta.com', ],]);
$customer_id ='0ab5511c-3a62-4b4b-8682-cb3c15172965';$delete =$payu->deleteCustomer($customer_id);
$customer_id ='0ab5511c-3a62-4b4b-8682-cb3c15172965';$customer =$payu->getCustomerById($customer_id);
$customer_reference ='johntravolta18021954';$customers =$payu->getCustomerByReference($customer_reference);
* Note:getCustomerByReference
returns anarray
not a single record likegetCustomerById
;
$payment_method =$payu->createPaymentMethod($customer['id'],$token);
phpunit
Feel free to contribute with anything on this package or contact us about it.
If you discover any security related issues, please emailgiovanni@somosgad.com instead of using the issue tracker.
MIT. Please see thelicense file for more information.