2017 © Pedro Peláez
 

cakephp-plugin ipay

iPay88 Plugin for CakePHP

image

dilab/ipay

iPay88 Plugin for CakePHP

  • Friday, October 9, 2015
  • by xuding
  • Repository
  • 1 Watchers
  • 0 Stars
  • 12 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

iPay88 Plugin for CakePHP

iPay88 is a leading regional Payment Gateway Provider in South East Asia., (*1)

Requirements

  • CakePHP version: 2.5.x

Installation

Using Git

git clone git@github.com:dilab/ipay.git Ipay, (*2)

Using Composer

composer require dilab/ipay, (*3)

Usage

Create Plugin Database

cake schema create --plugin ipay

Supply iPay88 Merchant Info

  • Copy ipay_config.php to App/Config folder cp app/Plugin/Ipay/Config/ipay_config_sample.php app/Config/ipay_config.php, (*4)

  • Open app/Config/ipay_config.php and supply correct information for both merchantKey and merchantCode. Leave rest of info intact., (*5)

Create Event Listener

Ipay.IpayResponse model fires two events below, which you can use to add your business logic., (*6)

  • Model.IpayResponse.afterValidResponse: This event is fired when a valid response is sent from iPay88. It checks status and signature fields., (*7)

  • Model.IpayResponse.afterSuccessResponse: This event fires only if event above also happens. It re-query iPay88 server to check if it is valid payment., (*8)

Model.IpayResponse.afterSuccessResponse should be used to identify a successful payment., (*9)

Ipay Plugin comes with backend post by default, it will use this event listener to process, (*10)

Sample

In file app/Controller/AppController.php:, (*11)

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
}

Create iPay88 Form using Helper

You can use iPay88 to create the a iPay88 payment form, you should always the helper, because it takes care of signature creation., (*12)

Sample

$data = array(
    'RefNo' => 123,
    'Amount' => 100.00,
    'Currency' => 'USD',
    'ProdDesc' => 'Product',
    'UserName' => 'test user',
    'UserEmail' => 'test@gmail.com',
    'UserContact' => '123',
    'ResponseURL' => 'http://domain/controller/response_handler',
);

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

Process Response using Component

In your response action, simply call Ipay.processPaymentResponse();, it will take care of all the backend process., (*13)

Sample

public response_handler() 
{
    // Your other code


    $this->Ipay->processPaymentResponse();

}

Testing

Unit Test

cake test Ipay all, (*14)

Integration Test

cake test Ipay Integration/IpayRequeryIntegration, (*15)

(Do not run this test as part of your Unit Test as it will send HTTP request to iPay88 server.), (*16)

Support

Please use Github Issues to report bugs/issues., (*17)

License

Licensed under The MIT License Redistributions of files must retain the above copyright notice., (*18)

Author

Xu Ding, (*19)

https://github.com/dilab, (*20)

The Versions

09/10 2015

dev-master

9999999-dev

iPay88 Plugin for CakePHP

  Sources   Download

MIT

The Requires

 

09/10 2015

1.0.0

1.0.0.0

iPay88 Plugin for CakePHP

  Sources   Download

MIT

The Requires