PHP code example of dosarkz / epay-kazcom

1. Go to this page and download the library: Download dosarkz/epay-kazcom 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/ */

    

dosarkz / epay-kazcom example snippets


$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() ); 
    } 
} 
 
'Epay' => \Dosarkz\EPayKazCom\Facades\Epay::class

  php artisan vendor:publish