crabstudio/baokim

BaoKim payment gateway plugin for CakePHP 3.x

Installs: 50

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 3

Forks: 1

Type:cakephp-plugin

1.0.2 2016-01-24 00:00 UTC

This package is auto-updated.

Last update: 2024-04-29 02:43:33 UTC


README

Build Status Latest Stable Version Latest Unstable Version Total Downloads

CakePHP 3.x: BaoKim payment gateway plugin

[Donate] Buy me a cup of coffee paypal

Installation

You can install this plugin into your CakePHP application using composer.

The recommended way to install composer packages is:

composer require crabstudio/baokim

Or add the following lines to your application's composer.json:

"require": {
    "crabstudio/baokim": "^1.0"
}

followed by the command:

composer update

Load plugin

Add this line to Your_project\config\bootstrap.php

Plugin::load('Crabstudio/BaoKim', ['bootstrap' => true]);

Or from command line:

bin/cake plugin load crabstudio/baokim

Configure

Write to your configure:

$baokim = [
    'BaoKim' => [
        'merchant_id' => 'your_merchant_id',
        'secure_pass' => 'your_secret',
        'business' => 'your_business_email@example.com'
    ]
];
Cake\Core\Configure::write($baokim);

Usage

Apply in your controller

public function checkout() {
	$this->loadComponent('Crabstudio/BaoKim.BaoKim');
	
	//your checkout logic here
	//$url_success route to checkoutSuccessfull function
	//$url_cancel route to checkoutCancel function

	$redirect_url = $this->BaoKim->createRequestUrl($order_id, $total_amount, $shipping_fee, $tax_fee, $order_description, $url_success, $url_cancel, $url_detail);
	return $this->redirect($redirect_url);
}

public function checkoutSuccessfull() {
	$this->request->allowMethod('get');
	$this->loadComponent('Crabstudio/BaoKim.BaoKim');
	$isValid = $this->BaoKim->verifyResponseUrl($this->request);
	if($isValid) {
		//Valid logic here
	}
	//Invalid logic here
}

public function checkoutCancel() {
	//Cancel logic here
}