Skip to content

More info on tracking one-time charges #937

@harrison-broadbent

Description

@harrison-broadbent

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions