(字节跳动(头条、抖音)小程序支付(PHP + UniApp,亲测可用)

本文详细介绍了如何使用PHP后端与UniApp前端实现字节跳动小程序的支付功能,包括配置过程、接口调用及验证流程,经过作者实际测试,已成功运行。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

// 调起支付
public function pay(Request $request)
{
    $openid  = $request->param('openid', 0);
    $orderNo = $request->param('orderNo', 0);

    $findOrder = Db::table('gc_order')->where(['orderNo' => $orderNo, 'openid' => $openid])->find();
    if (!$findOrder) {
        return self::err('订单不存在');
    }

    $findUser = Db::table('data_user')->where('openid', $openid)->find();
    if (!$findUser) {
        return self::err('用户不存在');
    }
    $tt_pay_app_id     = sysconf('wechat.dy_apppid');
    $tt_merchant_id    = sysconf('wechat.dy_mch_id');
    $tt_pay_secret_key = $app_secret = sysconf('wechat.dy_appsecret');
    $ip                = $this->getRealIp();
    $risk_info         = [
        'ip' => $ip,
    ];
    $orderInfo = [
        "app_id"       => $tt_pay_app_id,
        "sign_type"    => "MD5",
        "out_order_no" => $orderNo,
        "merchant_id"  => $tt_merchant_id,
        "timestamp"    => (string) time(),
        "product_code" => "pay",
        "payment_type" => "direct",
        "total_amount" => $findOrder['price'] * 100,
        "trade_type"   =&g
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值