1 Star 1 Fork 0

随风 / applet-paylogin

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

注意事项

微信支付使用APIv2规则 所以需要配置V2接口的密匙 不会用就看 test 目录下的示例 本项目只要是为自己服务 其他人用请自行看文档摸索 支付宝是订阅消息 不是订单消息等

安装说明

composer require suifeng/applet-paylogin

功能支持

第三方 token openid 支付 回调 退款 订单查询 解密手机号 订阅消息
微信小程序
支付宝小程序 x
字节小程序

字节小程序

Config

参数名字 类型 必须 说明
salt string 担保交易的 SALT
app_id int 小程序的 APP_ID
secret string 小程序的 APP_SECRET
debug string 沙盒调试开关 使用为 true 不使用为false
notify_url string 支付回调 url

token

    $data= \Applet\Pay\Factory::getInstance('Toutiao')->init($config)->getToken();
    

openid

    $code="";//小程序传递过来的
    $data= \Applet\Pay\Factory::getInstance('Toutiao')->init($config)->getOpenid($code);

预下单

    $options=[
    'out_order_no'=>1,
    'total_amount'=>'2'...
    ];
    appid,valid_time 不需要传递 其他必填都必须传递 
    $pay= \Applet\Pay\Factory::getInstance('Toutiao')->init($config)->createOrder($options);

文档地址:https://microapp.bytedance.com/docs/zh-CN/mini-app/develop/server/ecpay/APIlist/pay-list/pay

解密手机号

    $data= \Applet\Pay\Factory::getInstance('Toutiao')->init($config)->decryptPhone($session_key, $iv, $encryptedData);

字节订单查询

    $Toutiao = \Applet\Pay\Factory::getInstance('Toutiao')->init($config)->findOrder("订单号");
   

文档地址:https://microapp.bytedance.com/docs/zh-CN/mini-app/develop/server/ecpay/APIlist/pay-list/query

字节退款

    $order = [
            'out_order_no' => '',
            'out_refund_no' => time(),
            'reason' => '说明 都看文档吧',
            'refund_amount' => 1, //退款金额
        ];
    $data= \Applet\Pay\Factory::getInstance('Toutiao')->init($config)->applyOrderRefund($order);
    

文档地址:https://microapp.bytedance.com/docs/zh-CN/mini-app/develop/server/ecpay/APIlist/refund-list/refund

异步通知

   $result=\Applet\Pay\Factory::getInstance('Toutiao')->init($Config)->verify();
    $msg=$result['msg'];
    if($msg['status']=='SUCCESS'){
	$msg['cp_orderno'];; //网站订单号
	$msg['channel_no']; //流水号
	$data=[
		"err_no"  =>0,
		"err_tips"=>"success",
	];
	return json_encode($data); //必须输出一个 json

}
    
    

文档地址:https://microapp.bytedance.com/docs/zh-CN/mini-app/develop/server/ecpay/APIlist/pay-list/callback
这里如果有退款 记得要判断下 支付回调和退款回调

订阅消息

$token=''; //接口调用凭证access_token
$tpl_id=''; //所需下发的订阅模板id
$open_id=''; //接收者(用户)的 openid
$page='/page/index/index'; //点击模板卡片后的跳转页面
//模板内容 数组
$send_data=[
	'thing4' =>'参数1',
	'phrase5'=>'参数2'
];
$result=Applet::getInstance('Toutiao')->init($Config)->sendMessage($token,$tpl_id,$open_id,$send_data,$page);  
    

微信小程序

Config

参数名字 类型 必须 说明
appid int 小程序 appid
secret int 小程序 secret
mch_id string 商户 mch_id
mch_key string 商户 mch_key
notify_url string 异步地址
cert_pem string cert_pem 证书
key_pem string key_pem 证书

token

    $data= \Applet\Pay\Factory::getInstance('Weixin')->init($config)->getToken();
    

openid

    $code="";
    $data= \Applet\Pay\Factory::getInstance('Weixin')->init($config)->getOpenid($code);
    

预下单

    $options=[]; 
    $pay= \Applet\Pay\Factory::getInstance('Weixin')->init($config)->set($options);
   

文档地址:https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_1

微信解密手机号

    $data= \Applet\Pay\Factory::getInstance('Weixin')->init($config)->decryptPhone($session_key, $iv, $encryptedData);
   

微信订单查询

    $payName='Weixin';//设置驱动
    $Baidu = \Applet\Pay\Factory::getInstance('Weixin')->init($config);
    $data = $Baidu->findOrder("订单号");
     

文档地址:https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_2

微信退款

    $order = [
             'out_trade_no' => '123',
            'total_fee' => 0.01,
            'out_refund_no' => time(),
            'refund_fee' => 0.01,
        ];
    $data= \Applet\Pay\Factory::getInstance('Weixin')->init($config)->applyOrderRefund($order);
  

文档地址:https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_4

异步通知

   $result=\Applet\Pay\Factory::getInstance('Weixin')->init($Config)->verify();
 if($result['result_code']=='SUCCESS'&&$result['return_code']=='SUCCESS'){
	$result['out_trade_no']; //网站订单号
	$result['transaction_id']; //流水号
	$result['openid']; //支付账户
	return 'success'; //必须输出一个 success
}
    
    

文档地址:https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_7&index=8

订阅消息

$token=''; //接口调用凭证access_token
$template_id=''; //所需下发的订阅模板id
$touser=''; //接收者(用户)的 openid
$url='/page/index/index'; //点击模板卡片后的跳转页面
//模板内容 数组
$send_data=[
	'thing4' =>'参数1',
	'phrase5'=>'参数2'
];
$result=Applet::getInstance('Weixin')->init($Config)->sendMessage($token,$template_id,$touser,$url,$send_data);   
    

支付宝小程序

Config

参数名字 类型 必须 说明
appid int 小程序 appid
screct_key int 解密手机号的 AES密钥
notify_url string 异步回调地址
debug string 沙箱调试开关 使用沙箱设置为ture 不使用设置为false
rsaPrivateKey int 请填写开发者私钥去头去尾去回车,一行字符串
alipayrsaPublicKey int 请填写支付宝公钥,一行字符串

openid

    $code="";
    $data= \Applet\Pay\Factory::getInstance('Alipay')->init($config)->getOpenid($code);

支付宝解密手机号

    $code='';
    $data= \Applet\Pay\Factory::getInstance('Alipay')->init($config)->decryptPhone($code);

预下单

    $options=[
		'out_trade_no'=>1,// 订单号
		'total_amount'=>2,// 订单金额,**单位:元**
		'buyer_id'    =>3,//支付人的 buyer_id
		'subject'     =>4,// 订单描述
	];
    $data= \Applet\Pay\Factory::getInstance('Alipay')->init($config)->createOrder($options);

文档地址:https://opendocs.alipay.com/open/02ekfj

支付宝订单查询

    $options=[];//这里是数组
    $data = \Applet\Pay\Factory::getInstance('Alipay')->findOrder($options);
     

文档地址:https://opendocs.alipay.com/open/02ekfh?scene=common

支付宝退款

    $options=[];//这里是数组
    $data= \Applet\Pay\Factory::getInstance('Alipay')->init($config)->applyOrderRefund($options);

文档地址:https://opendocs.alipay.com/open/02ekfk

异步通知

       
		
   $result=\Applet\Pay\Factory::getInstance('Alipay')->init($Config)->verify($_POST);
    if($result['trade_status']=='TRADE_SUCCESS'||$result['trade_status']=='TRADE_FINISHED'){
		return 'success';//必须输出
    }
    
    

文档地址:https://opendocs.alipay.com/open/194/103296

订阅消息

       
$options=[
	'to_user_id' =>'参数1',//接收模板消息的用户 user_id
	'user_template_id'=>'参数2',//消息模板ID
	'page'=>'',//小程序的跳转页面
	//模板参数
	'data'=>[
		'thing4' =>'参数1',
		'phrase5'=>'参数2'
	]
];
$result=Applet::getInstance('Alipay')->init($Config)->sendMessage($options);
    
    

文档地址:https://opendocs.alipay.com/mini/02cth2

MIT License Copyright (c) 2022 suifeng Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

微信小程序、字节小程序、支付宝小程序(支付、手机号解密、获取Token、支付异步通知、退款、订单查询) 展开 收起
PHP
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
PHP
1
https://gitee.com/qibo168/applet-paylogin.git
git@gitee.com:qibo168/applet-paylogin.git
qibo168
applet-paylogin
applet-paylogin
main

搜索帮助