#stripe_connect_platform
1 messages · Page 1 of 1 (latest)
subscription_obj = {
:customer => customer.id,
:payment_behavior => 'allow_incomplete',
:items => [{ :plan => price.id}]
}
subscription = Stripe::Subscription.create(subscription_obj, {:stripe_account => stripe_user_id})
doesn't :source => 'tok_visa', add the payment method to the customer?
Hi
Hey there
Looks like the PaymentMethod for that Customer associated with req_mFmrwbC370gN2E was created via a Checkout Session
Oh, so check this out.
The customer was created via the Checkout Session too. So maybe you are mixing up your Customers?
We are doing a demo to show Customer Portal and I am getting their first test Customer OR.....creating a Customer so maybe we are getting their 1st test Customer and it happens to be someone with no payment method. Ugh.
I don't want to keep spinning up test customers. Hm....
You can just create a Sub with allow_incomplete
So how can we check if a testmode Customer has a payment method or not, and if not, add a fake on 4242 4242 or something.
And then you don't have to worry about the PaymentMethod at all
one sec
allow_incomplete forces a payment attempt
default_incomplete relies on you confirming the PaymentIntent
subscription_obj = {
:customer => customer.id,
:payment_behavior => 'default_incomplete',
:items => [{ :plan => price.id}]
}
like that?
Yep that looks good
OK, we just need some kind of fake payment so Customer Portal will spin up for that fake testmode Customer. OK, let me try.
Thank you!~
You won't see a payment in this case
But you should see an invoice in the Portal
If you want an actual payment, then you do want to use the Customer that you created as you noted above, and not one created from a Checkout Session (or you set the PaymentMethod from the Checkout Session as the default_payment_method)
Is there a way to find or create a valid Customer with a good payment method?
So that we can just spin up a testmode customer in a connected account once or if they delete it spin it up again but not keep creating new ones?
You are doing it correctly above: customer = Stripe::Customer.create({ :email => 'demo@example.com', :source => 'tok_visa', }, {:stripe_account => stripe_user_id})
customer = Stripe::Customer.list( {:limit => 1}, {:stripe_account => stripe_user_id} ).try(:first)
right but before we create it we are trying to find one
You just were using the wrong Customer ID when you created the Subscription
Oh
Yes you can check if any customers have a default_source
So list Customers where default_source: true right?
Sorry, can you list or retrieve via the Stripe API with a 'isn't null' or we just list and loop etc
No you would loop
ok thank you!