-
-
Notifications
You must be signed in to change notification settings - Fork 348
Description
Hey!
I'm curious what the recommended way to handle one-time purchases through pay is. Specifically, I'm looking at Section 8 of the Stripe docs (https://github.com/pay-rails/pay/blob/main/docs/stripe/8_stripe_checkout.md#fulfilling-orders-after-checkout-completed) where there's some information on fulfilling orders after a checkout.
I'm struggling to figure out what should go in the # Handle fulfillment section of the given code example —
Pay::Webhooks.delegator.subscribe "stripe.checkout.session.completed", FulfillCheckout.new
Pay::Webhooks.delegator.subscribe "stripe.checkout.session.async_payment_succeeded", FulfillCheckout.new
class FulfillCheckout
def call(event)
object = event.data.object
return if object.payment_status != "paid"
# Handle fulfillment
end
end
I'm wondering if I should manually create a Pay::Subscription here to indicate that the User (who just purchased access or whatever) now has access to the product.
Does this seem right, or am I missing something? I'm wondering if there's a state on Pay::Customer I should set here instead; I've gone through the Pay::Customer code at https://github.com/pay-rails/pay/blob/main/app/models/pay/customer.rb but nothing stood out to me.
Thanks!