PHP code example of hopeofiran / nicardpayment
1. Go to this page and download the library: Download hopeofiran/nicardpayment 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/ */
hopeofiran / nicardpayment example snippets php
HopeOfIran\NicardPayment\Providers\NicardPaymentProvider::class
bash
php artisan vendor:publish --provider=HopeOfIran\NicardPayment\Providers\NicardPaymentProvider
php
Route::any('/payment', function () {
return \HopeOfIran\NicardPayment\Facades\NicardPaymentFacade::creditAmount(200000)
->cashAmount(0)
->callbackUrl(\route('payment.verification'))
->backUrl(\route('payment.verification'))
->installmentsCountList([3, 4])
->purchase(function (\HopeOfIran\NicardPayment\NicardPayment $nicardPayment, \Illuminate\Http\Client\Response $response, $data) {
return $nicardPayment->pay($data['open_cpg_url']);
return 'payment failed';
});
})->name('payment');
php
Route::any('/payment/verification', function (\Illuminate\Http\Request $request) {
$response = \HopeOfIran\NicardPayment\Facades\NicardPaymentFacade::verify($request->input('tid'));
if ($response->successful()) {
return $response['is_totally_success'];
}
return $response->collect()->get('status');
})->name('payment.verification');