Payment package kazcom epay api for laravel 5.2 - 5.6
composer require dosarkz/epay-kazcom
Dosarkz\EPayKazCom\EpayServiceProvider::class
'Epay' => \Dosarkz\EPayKazCom\Facades\Epay::class
php artisan vendor:publish
$pay = Epay::basicAuth([
'order_id' => '01111111111',
'currency' => '398',
'amount' => 9999,
'email' => '[email protected]',
'hashed' => true,
]);
$pay->generateUrl();
$checkPay = Epay::checkPay( [ 'order_id' => '01111111111' ] );
$response = Epay::request( $checkPay->generateUrl() );
$controlPay = Epay::controlPay( [
'order_id' => '01111111111',
'amount' => 9999,
'approval_code' => '170407',
'reference' => '180711170407',
'currency' => '398',
'command_type' => 'complete',
'reason' => 'for test'
] );
$response = Epay::request( $controlPay->generateUrl() );
$response = request()->input('response');
if ($response)
{
$payResponse = Epay::handleBasicAuth( $response );
$orderId = $payResponse->getOrderId();
// ... get order amount for check
$amount = 9999;
Log::info( $payResponse->getResponse() );
Log::info( 'pay status=' . ($payResponse->isSuccess( [ 'amount' => $amount ] ) ? 'success' : 'fail') );
}
$checkPay = Epay::checkPay( [ 'order_id' => '01111111111' ] );
$response = Epay::request( $checkPay->generateUrl() );
if ($response) {
$checkPayResponse = Epay::handleCheckPay( $response );
Log::info( 'state=' . $checkPayResponse->getPayState() );
Log::info( 'status=' . ( $checkPayResponse->isSuccess() ? 'success' : 'fail' ));
Log::info( $checkPayResponse->getResponse() );
}
$controlPay = Epay::controlPay( [
'order_id' => '01111111111',
'amount' => 9999,
'approval_code' => '170407',
'reference' => '180711170407',
'currency' => '398',
'command_type' => 'complete', //reverse || complete || refund
'reason' => 'for test'
] );
$url = $controlPay->generateUrl();
if ( is_string($url) ) {
$response = Epay::request( $url );
if ($response) {
$controlPayResponse = Epay::handleControlPay( $response );
Log::info( 'message=' . $controlPayResponse->getResponseMessage() );
Log::info( 'status=' . ( $controlPayResponse->isSuccess() ? 'success' : 'fail' ));
Log::info( $controlPayResponse->getResponse() );
}
}