PHP code example of shipu / php-sslwireless-payment

1. Go to this page and download the library: Download shipu/php-sslwireless-payment library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

shipu / php-sslwireless-payment example snippets


Shipu\SslWPayment\SslWPaymentServiceProvider::class,

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

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);

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' 
        ]
    ]
];

use \Shipu\SslWPayment\Payment;

...

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

use \Shipu\SslWPayment\Payment;

...

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

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();

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();

use \Shipu\SslWPayment\Payment;

...

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

use \Shipu\SslWPayment\Payment;

...

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

use \Shipu\SslWPayment\Payment;

...

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

use \Shipu\SslWPayment\Payment;

...

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

{{ ssl_wireless_payment_url() }}

{!!
    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) 
!!}

{!! 
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') 
!!}

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');

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');


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();
}

protected $except = [
    ...
    'payment/*',
    ...
];
shell
composer 
shell
php artisan vendor:publish --provider="Shipu\SslWPayment\SslWPaymentServiceProvider"