2017 © Pedro Peláez
 

library easypay

an integration for third party payment

image

hjiash/easypay

an integration for third party payment

  • Thursday, August 18, 2016
  • by jason.y
  • Repository
  • 1 Watchers
  • 1 Stars
  • 95 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

1. 说明

使用前,请进入src/目录下,复制Configuration.php.example并重命名为Configuration.php,配置好参数。, (*1)

所有属性值支持以下方式进行set/get:, (*2)

$this->setParameter('key', $value);
$this->getParameter('key');

另外,微信支付支持将参数名转换成大驼峰,前面加get/set的方法名获取,如, (*3)

$request->getOutTradeNo();
$request->setOutTradeNo();

以下是demo

微信扫码支付, (*4)

$order = [
    'body' => '商品描述',
    'detail' => '商品详情',
    'out_trade_no' => createOrderNumber(),
    'product_id' => 1,
    'total_fee' => 1,
    'spbill_create_ip' => getClientIp(),
    'notify_url' => 'http://test.com',
];
$context = new PaymentContext('Strategy\WechatPay\WechatUnifiedPay');
$context->execute($order);
$result = $context->getResult();
$result->getCodeUrl();

微信公众号内支付, (*5)

$order = [
    'body' => '商品描述',
    'detail' => '商品详情',
    'out_trade_no' => createOrderNumber(),
    'total_fee' => 1,
    'spbill_create_ip' => getClientIp(),
    'notify_url' => 'http://test.com',
    'openid' => 'openid'
];
$context = new PaymentContext('Strategy\WechatPay\WechatJsPay');
$context->execute($order);
$result = $context->getResult();
$result->createWebPaymentPackage();

微信APP支付, (*6)

$order = [
 'body' => '商品描述',
 'detail' => '商品详情',
 'out_trade_no' => createOrderNumber(),
 'total_fee' => 1,
 'spbill_create_ip' => getClientIp(),
 'notify_url' => 'http://test.com',
 'openid' => 'openid'
];
$context = new PaymentContext('Strategy\WechatPay\WechatAppPay');
$context->execute($order);
$result = $context->getResult();

微信支付结果回调, (*7)

use \ChengFang\EasyPay\Traits\WechatPayNotify;

$body = file_get_contents('php://input');
$context = new PaymentContext('Strategy\WechatPay\WechatPayNotify');
$context->execute($body);

try{
    $result = $context->getResult();
    /**
     * result是CompleteOrderResponse的对象
     * 可以根据微信支付文档,将参数转化成驼峰的形式获取返回值
    */

    // $result->getTransactionId();
    // $result->getOutTradeNo();

    // $this->success($message = null);
    $this->success('信息可以不需要');
}catch(Exception $e){
    // $this->fail($message = null);
    $this->fail('信息可以不需要');
}

微信红包, (*8)

$redPack = [
    'send_name' => '广州乘方',
    're_openid' => 'o6FwguKysTyj3zlikp8U8DwHk4XA',
    'total_amount' => 100,
    'total_num' => 1,
    'wishing' => '祝福语',
    'client_ip' => getClientIp(),
    'act_name' => '活动名称',
    'remark' => '备注'
];
$context = new PaymentContext('Strategy\WechatPay\WechatRedPack');
$context->execute($redPack);
$result = $context->getResult();
echo $result->getSendListid();

支付宝PC即时到账, (*9)

$order = [
    'subject' => '商品描述',
    'body' => '商品详情',
    'out_trade_no' => createOrderNumber(),
    'total_fee' => 0.01,
    'notify_url' => '',
    'return_url' => ''
];
$context = new PaymentContext('Strategy\Alipay\AlipayPcExpress');
$context->execute($order);
echo $context->getResult()->getRedirectUrl();

支付宝手机即时到账, (*10)

$order = [
    'subject' => '商品描述',
    'body' => '商品详情',
    'out_trade_no' => createOrderNumber(),
    'total_fee' => 0.01,
    'notify_url' => '',
    'return_url' => ''
];
$context = new PaymentContext('Strategy\Alipay\AlipayWapExpress');
$context->execute($order);
echo $context->getResult()->getRedirectUrl();

支付宝支付结果回调, (*11)

use \ChengFang\EasyPay\Traits\AlipayNotify;

$body = Input::get();
$context = new PaymentContext('Strategy\WechatPay\WechatPayNotify');
$context->execute($body);

try{
    $result = $context->getResult();

    // $result->getRequest()->getRequestParam('trade_no');
    // $result->getRequest()->getRequestParam('out_trade_no');

    $this->success();
}catch(Exception $e){
    $this->fail();
}

The Versions

18/08 2016

dev-master

9999999-dev https://github.com/hjiash/EasyPay

an integration for third party payment

  Sources   Download

MIT

The Requires

 

by hjiash

php easypay third party payment

04/05 2016

v1.0.1

1.0.1.0 https://github.com/hjiash/EasyPay

an integration for third party payment

  Sources   Download

MIT

The Requires

 

by hjiash

php easypay third party payment

04/05 2016

v1.0.0

1.0.0.0 https://github.com/hjiash/EasyPay

an integration for third party payment

  Sources   Download

MIT

The Requires

 

by hjiash

php easypay third party payment