flyboyk/omnipay-alipay-hk

Alipay Hk gateway for Omnipay payment processing library

1.0.0 2019-12-08 01:38 UTC

This package is auto-updated.

Last update: 2024-04-08 11:52:16 UTC


README

Alipay Hk driver for the Omnipay PHP payment processing library

Build Status Latest Stable Version Total Downloads

Omnipay is a framework agnostic, multi-gateway payment processing library for PHP 5.3+. This package implements Alipay Hk support for Omnipay.

This package only support Alipay Hk service

Installation

Omnipay is installed via Composer. To install, simply add it to your composer.json file:

{
    "require": {
        "wjminions/omnipay-alipay-hk": "dev-master"
    }
}

And run composer to update your dependencies:

$ curl -s http://getcomposer.org/installer | php
$ php composer.phar update

Basic Usage

The following gateways are provided by this package:

  • AlipayHk_Web (Alipay Hk Web Gateway) 支付宝国际版Web支付宝接口
  • AlipayHk_Wap (Alipay Hk Wap Gateway) 支付宝国际版Wap支付宝接口
  • AlipayHk_App (Alipay Hk App Gateway) 支付宝国际版App支付宝接口

Usage

Purchase

/**
 * @var Omnipay\AlipayHk\WebGateway $gateway
 */
//gateways: AlipayHk_Web, AlipayHk_Wap, AlipayHk_App
$gateway = Omnipay::create('AlipayHk_Web');
$gateway->setPartner('8888666622221111');
$gateway->setKey('your**key**here'); //for sign_type=MD5
$gateway->setPrivateKey($privateKeyPathOrData); //for sign_type=RSA
$gateway->setReturnUrl('http://www.example.com/return');
$gateway->setNotifyUrl('http://www.example.com/notify');
$gateway->setEnvironment('sandbox'); //for Sandbox Test (Web/Wap)

$params = [
    'out_trade_no' => date('YmdHis') . mt_rand(1000,9999), //your site trade no, unique
    'subject'      => 'test', //order title
    'total_fee'    => '0.01', //order total fee
    'currency'     => 'USD', //default is 'USD'
];

/**
 * @var Omnipay\AlipayHk\Message\WebPurchaseResponse $response
 */
$response = $gateway->purchase($params)->send();

//$response->redirect();
var_dump($response->getRedirectUrl());
var_dump($response->getRedirectData());
var_dump($response->getOrderString()); //for AlipayHk_App

Return/Notify

/**
 * @var Omnipay\AlipayHk\WebGateway $gateway
 */
$gateway = Omnipay::create('AlipayHk_Web');
$gateway->setPartner('8888666622221111');
$gateway->setKey('your**key**here'); //for sign_type=MD5
$gateway->setPrivateKey($privateKeyPathOrData); //for sign_type=RSA
$gateway->setEnvironment('sandbox'); //for Sandbox Test (Web/Wap)

$params = [
    'request_params' => array_merge($_GET, $_POST), //Don't use $_REQUEST for may contain $_COOKIE
];

$response = $gateway->completePurchase($params)->send();

/**
 * @var Omnipay\AlipayHk\Message\CompletePurchaseResponse $response
 */
if ($response->isPaid()) {

   // Paid success, your statements go here.

   //For notify, response 'success' only please.
   //die('success');
} else {

   //For notify, response 'fail' only please.
   //die('fail');
}

For general usage instructions, please see the main Omnipay repository.