Package Data | |
---|---|
Maintainer Username: | shipu |
Maintainer Contact: | shipuahamed01@gmail.com (Shipu Ahamed) |
Package Create Date: | 2017-11-14 |
Package Last Update: | 2021-08-09 |
Home Page: | |
Language: | PHP |
License: | CC-BY-3.0 |
Last Refreshed: | 2024-11-15 15:12:09 |
Package Statistics | |
---|---|
Total Downloads: | 9,528 |
Monthly Downloads: | 219 |
Daily Downloads: | 6 |
Total Stars: | 34 |
Total Watchers: | 4 |
Total Forks: | 18 |
Total Open Issues: | 1 |
php-aamarpay-payment is a PHP client for Aamarpay Payment Gateway API. This package is also support Laravel and Lumen.
Go to terminal and run this command
composer require shipu/php-aamarpay-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\Aamarpay\AamarpayServiceProvider::class,
For Facade support you have add this line in aliases
section.
'Aamarpay' => Shipu\Aamarpay\Facades\Aamarpay::class,
Then run this command
php artisan vendor:publish --provider="Shipu\Aamarpay\AamarpayServiceProvider"
This package is required three configurations.
true
for sandbox and false
for livesuccess
and fail
.php-aamarpay-payment is take an array as config file. Lets services
use Shipu\Aamarpay\Aamarpay;
$config = [
'store_id' => 'Your store id',
'signature_key' => 'Your signature key',
'sandbox' => true,
'redirect_url' => [
'success' => [
'route' => 'payment.success'
],
'cancel' => [
'route' => 'payment.cancel'
]
]
];
$payment = new Aamarpay($config);
This package is also support Laravel. For laravel you have to configure it as laravel style.
Go to app\aamarpay.php
and configure it with your credentials.
return [
'store_id' => 'Your store id',
'signature_key' => 'Your signature key',
'sandbox' => true,
'redirect_url' => [
'success' => [
'route' => 'payment.success'
],
'cancel' => [
'route' => 'payment.cancel'
]
]
];
In PHP:
use \Shipu\Aamarpay\Aamarpay;
...
$payment = new Aamarpay($config);
return $payment->paymentUrl();
In Laravel:
use \Shipu\Aamarpay\Aamarpay;
...
$payment = new Aamarpay(config('aamarpay'));
return $payment->paymentUrl();
use \Shipu\Aamarpay\Aamarpay;
...
$payment = new Aamarpay(config('aamarpay'));
return $payment->customer([
'cus_name' => 'Shipu Ahamed', // Customer name
'cus_email' => 'shipuahamed01@gmail.com', // 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\Aamarpay\Aamarpay;
...
$payment = new Aamarpay(config('aamarpay'));
return $payment->customer([
'cus_name' => 'Shipu Ahamed', // Customer name
'cus_phone' => '01616022669' // Customer Phone
'cus_email' => 'shipuahamed01@gmail.com', // Customer email
])->transactionId()->amount(3500)->hiddenValue();
or
return $payment->customer([
'cus_name' => 'Shipu Ahamed', // Customer name
'cus_phone' => '01616022669' // Customer Phone
'cus_email' => 'shipuahamed01@gmail.com', // Customer email
])->amount(3500)->hiddenValue();
Default currency is BDT
. For change currency:
return $payment->customer([
'cus_name' => 'Shipu Ahamed', // Customer name
'cus_phone' => '01616022669' // Customer Phone
'cus_email' => 'shipuahamed01@gmail.com', // Customer email
])->currency()->amount(3500)->hiddenValue();
use \Shipu\Aamarpay\Aamarpay;
...
$payment = new Aamarpay(config('aamarpay'));
return $payment->generateTransaction();
use \Shipu\Aamarpay\Aamarpay;
...
$payment = new Aamarpay(config('aamarpay'));
return $payment->valid($request);
Checking valid response with amount:
use \Shipu\Aamarpay\Aamarpay;
...
$payment = new Aamarpay(config('aamarpay'));
return $payment->valid($request, '3500');
Where $request
will appear after post response.
{{ aamarpay_payment_url() }}
{!!
aamarpay_hidden_input([
'tran_id' => '21005455540', // random number. if you don't set this it will be auto generate.
'cus_name' => 'Shipu Ahamed', // Customer name
'cus_email' => 'shipuahamed01@gmail.com', // Customer email
'cus_phone' => '01616022669' // Customer Phone
], 3500)
!!}
or
{!!
aamarpay_hidden_input([
'tran_id' => '21005455540', // random number. if you don't set this it will be auto generate.
'cus_name' => 'Shipu Ahamed', // Customer name
'cus_email' => 'shipuahamed01@gmail.com', // Customer email
'cus_phone' => '01616022669' // Customer Phone
], 3500, 'T-shirt', 'BDT')
!!}
{!!
aamarpay_post_button([
'tran_id' => '21005455540', // random number. if you don't set this it will be auto generate.
'cus_name' => 'Shipu Ahamed', // Customer name
'cus_email' => 'shipuahamed01@gmail.com', // 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\Aamarpay\Facades\Aamarpay;
...
public function paymentSuccessOrFailed(Request $request)
{
if($request->get('pay_status') == 'Failed') {
return redirect()->back();
}
$amount = 3500;
$valid = Aamarpay::valid($request, $amount);
if($valid) {
// Successfully Paid.
} else {
// Something went wrong.
}
return redirect()->back();
}
Open app/Http/Middleware/VerifyCsrfToken.php
and adding :
protected $except = [
...
'payment/*',
...
];
Hey dude! Help me out for a couple of :beers:!