Giter Site home page Giter Site logo

php-sslwireless-payment's Introduction

PHP SSL-Wirless Payment Client

php-sslwireless-payment is a PHP client for SSL Wirless Payment Gateway API. This package is also support Laravel.

Installation

Go to terminal and run this command

composer require shipu/php-sslwireless-payment

Wait for few minutes. Composer will automatically install this package for your project.

For Laravel

Below Laravel 5.5 open config/app and add this line in providers section

Shipu\SslWPayment\SslWPaymentServiceProvider::class,

For Facade support you have add this line in aliases section.

'Payment'   =>  Shipu\SslWPayment\Facades\Payment::class,

Then run this command

php artisan vendor:publish --provider="Shipu\SslWPayment\SslWPaymentServiceProvider"

Configuration

This package is required three configurations.

  1. store_id = your store id in SSL-Wirless Payment Gateway.
  2. store_password = your store password in SSL-Wirless Payment Gateway
  3. sandbox = true for sandbox and false for live
  4. redirect_url = your application redirect url after success, fail and cancel.

php-sslwireless-payment is take an array as config file. Lets services

use Shipu\SslWPayment\Payment;

$config = [
    'store_id' => 'Your store id',
    'store_password' => 'Your store password',
    'sandbox' => true,
    'redirect_url' => [
        'fail' => [
            'route' => 'payment.failed'
        ],
        'success' => [
            'route' => 'payment.success'
        ],
        'cancel' => [
            'route' => 'payment.cancel' 
        ]
    ]
];

$payment = new Payment($config);

For Laravel

This package is also support Laravel. For laravel you have to configure it as laravel style.

Go to app\sslwpayment.php and configure it with your credentials.

return [
    'store_id' => 'Your store id',
    'store_password' => 'Your store password',
    'sandbox' => true,
    'redirect_url' => [
        'fail' => [
            'route' => 'payment.failed'
        ],
        'success' => [
            'route' => 'payment.success'
        ],
        'cancel' => [
            'route' => 'payment.cancel' 
        ]
    ]
];

Usages

  • Mandatory input field name
    • tran_id
    • cus_name
    • cus_email
    • cus_phone

Getting Payment Post Url

In PHP:

use \Shipu\SslWPayment\Payment;

...

$payment = new Payment($config);
return $payment->paymentUrl();

In Laravel:

use \Shipu\SslWPayment\Payment;

...

$payment = new Payment(config('sslwpayment'));
return $payment->paymentUrl();

Getting Hidden Input Field

use \Shipu\SslWPayment\Payment;

...

$payment = new Payment(config('sslwpayment'));
return $payment->customer([
    'cus_name'  => 'Shipu Ahamed', // Customer name
    'cus_email' => '[email protected]', // Customer email
    'cus_phone' => '01616022669' // Customer Phone
])->transactionId('21005455540')->amount(3500)->hiddenValue();

Where Transaction id is random value. you can generate by yourself or follow bellow steps:

use \Shipu\SslWPayment\Payment;

...

$payment = new Payment(config('sslwpayment'));
return $payment->customer([
    'cus_name'  => 'Shipu Ahamed', // Customer name
    'cus_phone' => '01616022669', // Customer Phone
    'cus_email' => '[email protected]' // Customer email
])->transactionId()->amount(3500)->hiddenValue();

or 

return $payment->customer([
    'cus_name'  => 'Shipu Ahamed', // Customer name
    'cus_phone' => '01616022669', // Customer Phone
    'cus_email' => '[email protected]' // Customer email
])->amount(3500)->hiddenValue();

Generate Transaction Id

use \Shipu\SslWPayment\Payment;

...

$payment = new Payment(config('sslwpayment'));
return $payment->generateTransaction();

Checking Valid Response

use \Shipu\SslWPayment\Payment;

...

$payment = new Payment(config('sslwpayment'));
return $payment->valid($request);

Checking valid response with amount:

use \Shipu\SslWPayment\Payment;

...

$payment = new Payment(config('sslwpayment'));
return $payment->valid($request, '3500'); 

Checking valid response with amount and transaction id:

use \Shipu\SslWPayment\Payment;

...

$payment = new Payment(config('sslwpayment'));
return $payment->valid($request, '3500', '21005455540');

Where $request will appear after post response.

In Blade

Getting Payment Post Url

{{ ssl_wireless_payment_url() }}

Getting Hidden Input Field

{!!
    ssl_wireless_hidden_input([
        'tran_id'   => '21005455540', // random number
        'cus_name'  => 'Shipu Ahamed', // Customer name
        'cus_email' => '[email protected]', // Customer email
        'cus_phone' => '01616022669' // Customer Phone
    ], 3500) 
!!}

Complete Post Button View

{!! 
ssl_wireless_post_button([
    'tran_id'   => '21005455540', // random number
    'cus_name'  => 'Shipu Ahamed', // Customer name
    'cus_email' => '[email protected]', // Customer email
    'cus_phone' => '01616022669' // Customer Phone
], 2000, '<i class="fa fa-money"></i>', 'btn btn-sm btn-success') 
!!}

Example

Route
Route::post('payment/success', 'YourMakePaymentsController@paymentSuccess')->name('payment.success');
Route::post('payment/failed', 'YourMakePaymentsController@paymentFailed')->name('payment.failed');
Route::post('payment/cancel', 'YourMakePaymentsController@paymentCancel')->name('payment.cancel');

or

Route::post('payment/success', 'YourMakePaymentsController@paymentSuccessOrFailed')->name('payment.success');
Route::post('payment/failed', 'YourMakePaymentsController@paymentSuccessOrFailed')->name('payment.failed');
Route::post('payment/cancel', 'YourMakePaymentsController@paymentSuccessOrFailed')->name('payment.cancel');
Controller Method
use Shipu\SslWPayment\Facades\Payment;

...

public function paymentSuccessOrFailed(Request $request)
{
    if($request->get('status') == 'CANCELLED') {
        return redirect()->back();
    }
    
    $transactionId = $request->get('tran_id');
    $valid = Payment::valid($request, 3500, $transactionId);
    
    if($valid) {
        // Successfully Paid.
    } else {
       // Something went wrong. 
    }
    
    return redirect()->back();
}

To Disable CSRF token

Open app/Http/Middleware/VerifyCsrfToken.php and adding :

protected $except = [
    ...
    'payment/*',
    ...
];

Credits

Special Thanks to Tawsif ul Karim.

Support on Beerpay

Hey dude! Help me out for a couple of ๐Ÿป!

Beerpay Beerpay

php-sslwireless-payment's People

Contributors

shipu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

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.