Skip to content

This is a laravel php library package for paynamics paygate

Notifications You must be signed in to change notification settings

ormelflores/paynamics-paygate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Paynamics PayGate SDK Laravel PHP

A Laravel PHP library for Paynamics PayGate API

Installation

composer require laravel-paynamics/paygate

Usage

Initialize Client

Vanilla PHP:

$client = new \Laravel\Paynamics\Paygate\Client([
    'merchant_id'     => 'YOUR MERCHANT ID,
    'merchant_key'    => 'YOUR MERCHANT KEY',
    'sandbox'         => (true|false),
    'sandbox_url'     => 'TESTING URL',
    'production_url'  => 'PRODUCTION URL',
]);
Create Request Body

Please refer to the API Documentation for the request body parameters.

$requestBody = new \Laravel\Paynamics\Paygate\RequestBody([
    'request_id' => substr(uniqid(), 1, 13),
    'fname' => 'Paynamics',
    'lname' => 'Buyer',
    'address1' => '101 Oval St.',
    'city' => 'Pasig City',
    'state' => 'Metro Manila',
    'country' => 'PH',
    'zip' => '1600',
    'email' => 'buyer@example.com',
    'phone' => '+63 123 4567',
    'mobile' => '+63 999 123 4567',
    'currency' => 'PHP',
    'descriptor_note' => 'PayGate Sample Merchant',

    'notification_url' => 'http://example.com/notify',
    'response_url' => 'http://example.com/success',
    'cancel_url' => 'http://example.com/cancel',
    'mtac_url' => 'http://example.com/tnc',
    'mlogo_url' => 'http://example.com/assets/logo.png',
]);
Create Item Group and add Item

Add item details (name,quantity,amount) one by one using the addItem method.

$items = new \Paynamics\Paygate\ItemGroup;

$items->addItem([
    'name' => 'Sample Item',
    'quantity' => 1,
    'amount' => 100,
]);
Set Item Group to the request body

This will bind the items accordingly to the request body and computes its total amount.

$requestBody->setItemGroup($items);
Execute

All request by the Client will return an auto-submit form in string.

$client->responsivePayment($requestBody);

Laravel Support

  1. Add Provider to config/app.php.
Laravel\Paynamics\Paygate\Laravel\ServiceProvider::class
  1. Add Facade to config/app.php.
'Paygate' => Laravel\Paynamics\Paygate\Laravel\Facades\Paygate::class
  1. Execute
php artisan vendor:publish --tag=config
  1. Add the following to your .env file
PAYGATE_MERCHANT_ID=<YOUR MERCHANT ID>
PAYGATE_MERCHANT_KEY=<YOUR MERCHANT KEY>
PAYGATE_SANDBOX=<TRUE|FALSE>
PAYGATE_SANDBOX_URL=<PAYNAMICS_TESTING_URL>
PAYGATE_PRODUCTION_URL=<PAYNAMICS_PRODUCTION_URL>
PAYNAMICS_SERVER_IP_ADDRESS=<PAYNAMICS_SERVER_IP_ADDRESS>