Replies: 2 comments
-
You have to associate things with the Stripe Customer ID in the database so Pay can sync webhooks for the customer. If you're not providing a Stripe Customer ID to the pricing table, it will create a new customer each time. Pay will see the webhook but not a matching customer so it will ignore it. Recommend reading Stripe's documentation for how things work: https://docs.stripe.com/payments/checkout/pricing-table#customer-session I just added a class PricingController < ApplicationController
def show
# sets Stripe as the payment processor which lazily creates a Stripe Customer when you use it
current_user.set_payment_processor(:stripe)
# Ensures a Stripe Customer exists, and creates a CustomerSession object.
@customer_session = current_user.payment_processor.customer_session(components: {
pricing_table: {enabled: true}
})
end
end <script
async
src="https://js.stripe.com/v3/pricing-table.js">
</script>
<stripe-pricing-table
pricing-table-id='{{PRICING_TABLE_ID}}'
publishable-key="pk_test_1234"
customer-session-client-secret="<%= @customer_session.client_secret %>"
>
</stripe-pricing-table> |
Beta Was this translation helpful? Give feedback.
-
Thanks, @excid3! This makes more sense now. I had only got as far as adding a I'll go implement this and come back with a step-by-step for future reference. |
Beta Was this translation helpful? Give feedback.
-
I am integrating Pay into my SaaS application and wondering if there's a recommended flow for onboarding users and setting up subscriptions.
My use case is fairly common:
Using a pricing table (and Stripe Checkout) I am able to get Pay Customer records created with the web hooks, but not really sure where I should be creating the subscriptions and/or in what order I should be creating Pay Customers, syncing subscriptions, or creating subscriptions.
Overall I'm confused about how much I need to be explicitly creating Pay records vs. not.
Things like:
@user.payment_processor.subscribe(name: "default", plan: "monthly")
?@user.payment_processor.customer
or rely on the web hooks to do that for me?Would love to get a handle on a recommended approach and then contribute something back to the docs.
Beta Was this translation helpful? Give feedback.
All reactions