php-sslwireless-payment is a PHP client for SSL Wirless Payment Gateway API. This package is also support Laravel.
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.
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"
This package is required three configurations.
- store_id = your store id in SSL-Wirless Payment Gateway.
- store_password = your store password in SSL-Wirless Payment Gateway
- sandbox =
true
for sandbox andfalse
for live - redirect_url = your application redirect url after
success
,fail
andcancel
.
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);
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'
]
]
];
- Mandatory input field name
- tran_id
- cus_name
- cus_email
- cus_phone
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();
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);
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.
{{ 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)
!!}
{!!
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');
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');
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();
}
Open app/Http/Middleware/VerifyCsrfToken.php
and adding :
protected $except = [
...
'payment/*',
...
];
Special Thanks to Tawsif ul Karim.
Hey dude! Help me out for a couple of 🍻!