我如何将付款状态更改为“付款”客户用条纹付款后?

发布于 2025-02-04 15:36:47 字数 772 浏览 2 评论 0 原文

因此,我正在使用Web应用程序工作,并有些困惑...我正在尝试在客户成功付款以通过Stripe Checkout付款后更改预订的付款状态。基本上,在结帐成功后,更改预订。我尝试了一些事情,但我似乎被卡住了。谢谢您的任何帮助:)

这是我的结帐控制器:

class CheckoutController < ApplicationController

  def create
    product = Listing.find(params[:listing_id])
    booking = Booking.find(params[:id])
    duration = (booking.end_date - booking.start_date).to_i + 1
    @session = Stripe::Checkout::Session.create({
      payment_method_types: ['card'],
      line_items: [{
        name: product.name,
        amount: product.price * 100,
        currency: "gbp",
        quantity: duration
      }],
      mode: 'payment',
      success_url: bookings_url,
      cancel_url: bookings_url
    })
    respond_to do |format|
      format.js
    end
  end
end

So I am working on a web app and am a little confused... I am trying to change the payment status of a booking after the customer paid successfully over stripe checkout. Basically, change booking.paid to true after the checkout is successful. I tried some things but I seem to be stuck. Thank you for any help :)

Here is my checkout controller:

class CheckoutController < ApplicationController

  def create
    product = Listing.find(params[:listing_id])
    booking = Booking.find(params[:id])
    duration = (booking.end_date - booking.start_date).to_i + 1
    @session = Stripe::Checkout::Session.create({
      payment_method_types: ['card'],
      line_items: [{
        name: product.name,
        amount: product.price * 100,
        currency: "gbp",
        quantity: duration
      }],
      mode: 'payment',
      success_url: bookings_url,
      cancel_url: bookings_url
    })
    respond_to do |format|
      format.js
    end
  end
end

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

扛起拖把扫天下 2025-02-11 15:36:47

我建议您使用 Stripe webhooks 当结帐会话成功时,请告知您的内部系统。您将需要听取事件,代码> Checkout.session.completed 。

这是一个有用的指南 在客户付费时,可以通过Stripe Checkout签约来完成充实的订单。

I recommend leveraging Stripe Webhooks to inform your internal system when a Checkout Session succeeds. You’ll want to listen for event, checkout.session.completed.

Here’s a helpful guide that walks through fulfilling orders after a customer pays with Stripe Checkout.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文