#damonstrr
1 messages · Page 1 of 1 (latest)
Hi there!
Hi there soma
Can you share the request ID (req_xxx) that failed? You can find it here https://dashboard.stripe.com/test/logs
Note that cus_OmILh6SEMTffZE lives on a Connected account. So if you want to re-use it, you need to make sure you use the secert key of the paltform account and use the Stripe-Account header: https://stripe.com/docs/connect/authentication
doing so should fix the error
i did that which can be found in the code above
current_user.set_payment_processor :stripe, stripe_account: Blog.find_by(name: request.subdomain).stripe_account_id
Can you share the request ID (req_xxx) that failed? You can find it here https://dashboard.stripe.com/test/logs
req_gmvjnqfTZd0jjV
Thanks. This request is not using the Stripe-Account header. So it means it's trying to find the customer object on your platofmr account, so it's expected to fail.
So please read this and use the Stripe-Account header to fix this: https://stripe.com/docs/connect/authentication#stripe-account-header
So with the code i pasted above how i pass the connect account??
I highligted the part of your code that's missing:
it's a subscription, the problem is that if i should use Stripe::Session::Checkout() and attach stripe-account header it is not saved in the database
I don't understand. When you use Checkout Session with connect, you have two options:
- Create the payment or subscription directly on the platform account. it means all objects (price, customer, etc.) must live on the platform account
- Or create the payment or subscription on the connected account with the Stripe-Account header. it means all objects (price, customer, etc.) must live on the connected account
Which one do you want to do?
The second one please
Then you have to use the Stripe-Account header, as mentioned above. That's the only way.
So you need to update your code to add one extra line.
Oh okay i guess it would be like this
using this rails pay gem
@checkout_session = current_user.payment_processor.checkout(
mode: 'subscription',
locale: I18n.locale,
line_items: [{
price: 'price_1ILVZaKXBGcbgpbZQ26kgXWG',
quantity: 4
}],
subscription_data: {
trial_period_days: 15,
metadata: {
pay_name: "base" # Optional. Overrides the Pay::Subscription name attribute
},
},
success_url: root_url,
cancel_url: root_url,
stripe_account: 'your_stripe_account_id_here'
)
nope
That's why i am confused Soma
It's stripe current_user.set_payment_processor :stripe
Full code
current_user.set_payment_processor :stripe
@checkout_session = current_user.payment_processor.checkout(
mode: 'subscription',
locale: I18n.locale,
line_items: [{
price: 'price_1ILVZaKXBGcbgpbZQ26kgXWG',
quantity: 4
}],
subscription_data: {
trial_period_days: 15,
metadata: {
pay_name: "base" # Optional. Overrides the Pay::Subscription name attribute
},
},
success_url: root_url,
cancel_url: root_url,
stripe_account: 'your_stripe_account_id_here'
)
If you use Stripe itself, then it's like this:
Stripe::Checkout::Session.create({
mode: 'subscription',
locale: "...",
line_items: [{ ... }],
subscription_data: { ... },
success_url: "...",
cancel_url: "...",
}, {
stripe_account: 'acct_xxxx'
})
ref: https://github.com/pay-rails/pay/blob/master/docs/marketplaces/stripe_connect.md and https://github.com/pay-rails/pay/blob/master/docs/stripe/8_stripe_checkout.md
That's what i mean the stripe session checkout does not save subscription into the pay_subscription table for some weird reason
No idea what you are talking about. What is pay_subscripiton table? This seems unrelated to the Stripe API.
That's the gem i use... pay gem by ruby on rails