You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Stripe PHP支付完成后跳转设置失效,求问题排查提示

Stripe支付链接跳转失效问题排查与修复

你的代码中after_completion字段的结构存在错误,这是导致跳转设置不生效的核心原因:

错误点分析

Stripe API要求after_completion是一个关联数组,直接包含type和对应配置字段,但你的代码在after_completion下多嵌套了一层数组[],导致Stripe无法正确解析跳转规则。

修正后的代码

$link = $stripe->paymentLinks->create([
    'line_items' => [
        [
            'price' => $product['default_price'],
            'quantity' => 1,
        ],  
    ],
    'after_completion' => [
        'type' => 'redirect',
        'redirect' => [
            'url' => 'https://www.trainer-va.de/Trainer-Cloud/123.php?product=' . $product['default_price'],
        ],
    ],
]);

额外注意事项

  1. 移除了after_completion内多余的外层数组,让type和redirect直接作为after_completion的子字段
  2. 可去掉URL拼接中多余的空字符串,不影响功能但代码更简洁
  3. 若结构修正后跳转仍失效,请检查:
    • 跳转URL必须使用HTTPS协议
    • 该域名已添加到Stripe控制台「支付设置」->「允许的重定向域名」列表中

内容的提问来源于stack exchange,提问作者Simon Giesen

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.20 23:18:33