簡體   English   中英

Stripe PHP 購買后重定向

[英]Stripe PHP Redirect after Purchase

我只想在購買后使用 PHP 的 Stripe API 添加重定向到某個 url。 到目前為止,我的方法是:

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

]);

但它不起作用。 任何提示這里出了什么問題?

提前致謝!

您的請求正文在 after_completion 屬性級別 [1] 格式錯誤。

你應該這樣做:

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

[1] https://stripe.com/docs/api/payment_links/payment_links/create#create_payment_link-after_completion

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM