Stripe PHP : 如何处理支付成功通知

Stripe PHP : how to handle payment success notification

我正在尝试处理用户在 Stripe 上付款后的付款通知。

有效方法: 创建付款并将用户发送到结帐页面

$checkout_session = \Stripe\Checkout\Session::create([
            'payment_method_types' => ['card'],
            'line_items' => [[
              'price_data' => [
                'currency' => 'eur',
                'product_data' => [
                  'name' => 'Paiement de votre chef Persil & Romarin',
                ],
                'unit_amount' => $commande->getPrix()*100,
              ],
              'quantity' => 1,
            ]],
            'mode' => 'payment',
            'success_url' => $accepted_url,
            'cancel_url' => $canceled_url,
          ]);

        header("HTTP/1.1 303 See Other");
        return $this->redirect($checkout_session->url);

我有一个不错的支付页面,一切正常,我被很好地重定向到我的“accepted_url”页面。

我的问题是:

我应该如何检索付款信息? 奖励:我如何发送和检索元数据,如“订单 ID”?

谢谢你的帮助,如果你得到答案,我正在用头撞墙:​​P

您可以将 {CHECKOUT_SESSION_ID} 添加到您的 success_url,这样您就可以从 Stripe API 中获取结账会话以及与结账会话相关的任何其他信息。条纹有 a guide that covers this in detail.

您可以使用 the metadata support in the Stripe API 将元数据添加到结帐会话和相关对象。