PHP code example of dilab / ipay

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

    

dilab / ipay example snippets

 cp app/Plugin/Ipay/Config/ipay_config_sample.php app/Config/ipay_config.php  

public function beforeFilter()
{
  $this->loadModel('Ipay.IpayResponse');
  $callback = array($this, 'ipaySuccessResponseCallBack');
  $this->IpayResponse->getEventManager()->attach(
          $callback,
          'Model.IpayResponse.afterSuccessResponse',
          array('passParams' => true)
  );
}

public function ipaySuccessResponseCallBack($id)
{
  // Process your order with your business logic
  // Use $id to get the order information from ipay_repsonses table
}

$data = array(
    'RefNo' => 123,
    'Amount' => 100.00,
    'Currency' => 'USD',
    'ProdDesc' => 'Product',
    'UserName' => 'test user',
    'UserEmail' => '[email protected]',
    'UserContact' => '123',
    'ResponseURL' => 'http://domain/controller/response_handler',
);

echo $this->Ipay->button($data);
             

public response_handler() 
{
    // Your other code
    
    
    $this->Ipay->processPaymentResponse();

}