#damonstrr

1 messages · Page 1 of 1 (latest)

buoyant groveBOT
craggy vapor
#

Hi there!

sinful drum
#

Hi there soma

craggy vapor
#

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

sinful drum
#

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
craggy vapor
sinful drum
#

req_gmvjnqfTZd0jjV

craggy vapor
#

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.

sinful drum
#

So with the code i pasted above how i pass the connect account??

craggy vapor
#

I highligted the part of your code that's missing:

sinful drum
#

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

craggy vapor
#

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?
sinful drum
#

The second one please

craggy vapor
#

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.

sinful drum
#

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'
    )

craggy vapor
#

nope

sinful drum
#

That's why i am confused Soma

craggy vapor
#

Wait, what is current_user.payment_processor?

#

It's not Stripe.

sinful drum
#

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'
    )
craggy vapor
#

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'
})
sinful drum
#
GitHub

Payments for Ruby on Rails apps. Contribute to pay-rails/pay development by creating an account on GitHub.

GitHub

Payments for Ruby on Rails apps. Contribute to pay-rails/pay development by creating an account on GitHub.

sinful drum
craggy vapor
#

No idea what you are talking about. What is pay_subscripiton table? This seems unrelated to the Stripe API.

sinful drum