微擎小程序支付功能+退款功能

1,要使用微擎特定的小程序框架

https://gitee.com/we7coreteam/wxapp

2,必须正确的配置siteinfo

https://www.kancloud.cn/qq188872170/xcx/673488

var siteinfo = {
"m": 'yhjd_fhjs',
"uniacid": "2",
"acid": "2",
"multiid": "0",
"version": "1.01",
"siteroot": "https://02.zcwlkj.cn/app/index.php",
'method_design': '3'
};
module.exports = siteinfo;
 
3,发起支付的页面,必须有m参数
appInfo.util.request({
'url': 'entry/wxapp/pay', //调用wxapp.php中的doPagePay方法获取支付参数
data: {
orderid: params.ordertid,
fee: params.fee,
openid: appInfo.globalData.openid,
m: appInfo.siteInfo.m
},
'cachetime': '0',
success(res) {
console.log(res);
}
});
4,PHP端生成支付参数——————wxapp.php文件就是专门用来写这个小程序支付逻辑的
class We7WxappDemoModuleWxapp extends WeModuleWxapp {
    public function doPagePay() {
        global $_GPC, $_W;
        //获取订单号,保证在业务模块中唯一即可
        $orderid = intval($_GPC['orderid']);
        //构造支付参数
        $order = array(
            'tid' => $orderid,
            'user' => $_W['openid'], //用户OPENID
            'fee' => floatval($fee), //金额
            'title' => '小程序支付示例',
        );
        //生成支付参数,返回给小程序端
        $pay_params = $this->pay($order);
        if (is_error($pay_params)) {
            return $this->result(1, '支付失败,请重试');
        }
        return $this->result(0, '', $pay_params);
    }
}
小程序端发起支付
app.util.request({
    'url': 'entry/wxapp/pay', //调用wxapp.php中的doPagePay方法获取支付参数
    data: {
        orderid: options.orderid,
    },
    'cachetime': '0',
    success(res) {
        if (res.data && res.data.data && !res.data.errno) {
            //发起支付
            wx.requestPayment({
                'timeStamp': res.data.data.timeStamp,
                'nonceStr': res.data.data.nonceStr,
                'package': res.data.data.package,
                'signType': 'MD5',
                'paySign': res.data.data.paySign,
                'success': function (res) {
                    //执行支付成功提示
                },
                'fail': function (res) {
                    backApp()
                }
            })
        }
    },
    fail(res) {
        wx.showModal({
            title: '系统提示',
            content: res.data.message ? res.data.message : '错误',
            showCancel: false,
            success: function (res) {
                if (res.confirm) {
                    backApp()
                }
            }
        })
    }
})
验证支付结果
和模块一样,验证代码写在 payResult() 函数中即可。
 
 
微擎退款功能——
1,微擎的支付订单存储在ims_core_paylog中,
2,退款订单存储在ims_core_refundlog中
3,支付和退款,都必须配置参数,退款要配置文件
证书:
使用微信退款功能需要上传双向证书。
证书下载方式:
微信商户平台(pay.weixin.qq.com)-->账户中心-->账户设置-->API安全-->证书下载。
我们仅用到apiclient_cert.pem 和 apiclient_key.pem这两个证书
 
  1. //首先load模块函数
  2. load()->model('refund');
  3. //创建退款订单
  4. //$tid 模块内订单id
  5. //$module 需要退款的模块
  6. //$fee 退款金额
  7. //$reason 退款原因
  8. //成功返回退款单id,失败返回error结构错误
  9. $refund_id = refund_create_order($tid, $module, $fee, $reason);
  10. if (is_error($refund_id)) {
  11. itoast($refund_id['message'], referer(), 'error');
  12. }
  13. //发起退款
  14. $refund_result = refund($refund_id);
  15. if (is_error($refund_result)) {
  16. itoast($refund_result['message'], referer(), 'error');
  17. } else {
  18. pdo_update('core_refundlog', array('status' => 1), array('id' => $refund_id));
  19. //XXX(这里继续写自己的其他逻辑)
  20. itoast('退款成功', referer(), 'info');
  21. }

转载于:https://www.cnblogs.com/bluestear/p/11247523.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
壹佰超级名片小程序是一个基于微信平台的应用,提供了多种功能和服务。它可以让用户通过添加企业微信账号,实现在微信中管理和跟进客户资料,一键发送常用话术和文件,查询客户历史跟进记录和历史订单和偏好。同时,壹佰超级名片小程序还支持自定义装修,让每个商家都能定制独特的界面,避免千篇一律的模板。此外,该小程序还提供了多渠道分发功能,方便用户将自己的名片分享给更多的潜在客户。通过壹佰超级名片小程序,用户可以更方便地与客户进行沟通和交流,提高销售效率和客户满意度。123 #### 引用[.reference_title] - *1* *2* [微擎 db where in_触达2.5亿用户,“壹佰企微助手”上线微擎,它的功能到底有多香?...](https://blog.csdn.net/weixin_39820588/article/details/110133862)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}} ] [.reference_item] - *3* [微信壹佰超级名片小程序源码v1.1.16](https://blog.csdn.net/banzhuan678/article/details/116300316)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值