Giter Site home page Giter Site logo

laravel-paytm's Introduction

๐Ÿ’ฐ Laravel Paytm ๐Ÿ’ฐ

Latest Stable Version Total Downloads License

This package allows you to integrate Paytm payment gateway into your laravel app. For Paytm full documentation your can refer here

๐Ÿ’ก Installation

  1. Install the package via Composer:
composer require brainlabsweb/laravel-paytm

The package will automatically register its service provider.

  1. publish the configuration file
php artisan vendor:publish --provider="Brainlabsweb\Paytm\PaytmServiceProvider"

Configuration

Note: For Laravel 5.5 and above you can skip the following steps

In you config/app.php add these

'providers' => [
    // Other service providers...
    Brainlabsweb\Patym\PatymServiceProvider::class,
],

Also under aliases

'aliases' => [
    // Other aliases
    'Paytm' => Brainlabsweb\Patym\Paytm::class,
],

To get the paytm api urls

These urls will automatically direct to corresponding paytm sandbox, live modes based on the ๐Ÿ’ช default status set in paytm config file

paytm()->getTxnUrl(); // for charging  
paytm()->getTransactionStatusUrl(); // to know the status of the paytm transaction
paytm()->getRefundUrl(); // to inititate refund
paytm()->getRefundStatusUrl(); // to know the refund status

in your view file

/**
* The below are mandatory fields
* optional fields MOBILE_NO, EMAIL
*/
$data = [
    'ORDER_ID'   => 'order_id',
    'TXT_AMOUNT' => '1',
    'CUST_ID'    => 'custid'
];
<form method="POST" action="{{ paytm()->getTxnUrl() }}">
    @foreach(\Brainlabsweb\Paytm\Paytm::prepare($data) as $key => value)
    <input type="hidden" name="{{ $key }}" value="{{ $value }}">   
    @endforeach
    
    <button type="submit">Pay</button>
</form>
OR

paytm()->prepare($data)

Disable CSRF on Paytm Routes

Make sure all POST request handling routes of Paytm are not CSRF protected. For example

Route::post('paytm/verify','PaytmController@verify');

You can disable these in app/Http/Middleware/VerifyCsrfToken.php

protected $except = ['paytm/verify'];

Once the payment is done in your controller

\Brainlabsweb\Paytm\Paytm::verify(); // returns true/false 

OR

paytm()->verify();

To get Paytm response status

\Brainlabsweb\Paytm\Paytm::response(); // returns paytm response array 

OR
                  
paytm()->response();                   

To know the transaction status

Make POST REQUEST with param $order_id

\Brainlabsweb\Paytm\Paytm::getTransactionStatus($order_id); // returns paytm response array

OR

paytm()->getTransactionStatus($order_id); 

To initiate refund

$data = [
    'ORDERID'   => 'order_id',
    'REFID' => 'ref1', // should be unique everytime
    'TXNID'    => 'TXNID' // will get as response when made a transaction
    'REFUNDAMOUNT' => '1',
    'COMMENT' => 'SOME TEXT' // THIS IS OPTIONAL PARAMTER
];

\Brainlabsweb\Paytm\Paytm::refund($data); // returns paytm response array 

OR

paytm()->refund($data);

To know the refund status

$data = [
    'ORDERID'   => 'order_id',
    'REFID' => 'ref1', // This is REFID for which refund status is being inquired
];

\Brainlabsweb\Paytm\Paytm::refundStatus($data); // returns paytm response array

OR

paytm()->refundStatus($data); 

Done!!

laravel-paytm's People

Contributors

brainlabs2010 avatar

Stargazers

 avatar

Forkers

infysumanta

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.