定制 hjiash/easypay 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

hjiash/easypay

Composer 安装命令:

composer require hjiash/easypay

包简介

an integration for third party payment

README 文档

README

1. 说明

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

所有属性值支持以下方式进行set/get:

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

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

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

以下是demo

微信扫码支付

$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();

微信公众号内支付

$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支付

$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();

微信支付结果回调

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('信息可以不需要');
}

微信红包

$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即时到账

$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();

支付宝手机即时到账

$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();

支付宝支付结果回调

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();
}

统计信息

  • 总下载量: 101
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-05-03

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固