字节跳动支付

字节跳动支付目前仅支持小程序,对应的支付 method 如下:

method说明参数返回值
createOrder小程序支付array $orderCollection

支付配置

# 字节跳动支付配置
$bytedanceConfig = [
    'app_id'        => '', // App ID
    'salt'          => '', // 支付密钥值
    'notify_url'    => '', // 支付回调地址
    'thirdparty_id' => '', // 第三方平台服务商 id,非服务商模式留空
];

小程序

例子

$pay = new \fengkui\Pay\Bytedance($bytedanceConfig);

$order = [
    'body'      => 'subject-测试', // 商品描述
    'order_sn'  => time(), // 商户订单号
    'total_amount' => 1, // 订单金额(分)
];

$result = $pay->createOrder($order);
// 返回 Collection 实例。包含了预下单接口的所有参数

订单配置参数

所有订单配置中,客观参数及配置,扩展包已自动处理
除必传参数外,如需传入其他参数,可根据自己需求任意修改扩展

所有订单配置参数和官方无异,参数请参考这里open in new window,查看「请求参数」一栏。

调用支付

小程序支付的调用,请参考这里open in new window,查看「唤起收银台」一栏。

tt.pay({
    orderInfo: {
        order_id:  'order_idxxxxxxxx',
        order_token: 'order_tokenxxxxxxxx',
    },
    service: 5,
    success(res) {
        if (res.code == 0) {
            // 支付成功处理逻辑,只有res.code=0时,才表示支付成功
            // 但是最终状态要以商户后端结果为准
        }
    },
    fail(res) {
        // 调起收银台失败处理逻辑
    },
});
方法名参数返回值
query/queryRefundstring $orderSnCollection

查询支付

$pay = new \fengkui\Pay\Bytedance($bytedanceConfig);

$orderSn = 'order_snxxxxxxxx'; // 商户订单号
$result = $pay->queryOrder($orderSn);

相关返回参数说明,请参考这里open in new window,查看「响应示例」一栏。

Last Updated:
Contributors: kuifeng