#stripe_connect_platform

1 messages · Page 1 of 1 (latest)

cold prismBOT
hollow sandal
#

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?

rough relic
#

Hi

hollow sandal
#

Hey there

rough relic
#

Looks like the PaymentMethod for that Customer associated with req_mFmrwbC370gN2E was created via a Checkout Session

hollow sandal
#

Oh, so check this out.

rough relic
#

The customer was created via the Checkout Session too. So maybe you are mixing up your Customers?

hollow sandal
#

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....

rough relic
#

You can just create a Sub with allow_incomplete

hollow sandal
#

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.

rough relic
#

And then you don't have to worry about the PaymentMethod at all

hollow sandal
#

We have allow_incomplete

#

I pasted the code above

rough relic
#

Ah you do

#

I meant default_incomplete

#

Sorry, mixed them up

hollow sandal
#

one sec

rough relic
#

allow_incomplete forces a payment attempt

#

default_incomplete relies on you confirming the PaymentIntent

hollow sandal
#

subscription_obj = {
:customer => customer.id,
:payment_behavior => 'default_incomplete',
:items => [{ :plan => price.id}]
}

#

like that?

rough relic
#

Yep that looks good

hollow sandal
#

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!~

rough relic
#

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)

hollow sandal
#

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?

rough relic
#

You are doing it correctly above: customer = Stripe::Customer.create({ :email => 'demo@example.com', :source => 'tok_visa', }, {:stripe_account => stripe_user_id})

hollow sandal
#

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

rough relic
#

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

hollow sandal
#

So list Customers where default_source: true right?

rough relic
#

Where default_source isn't null

#

It will be an ID, so not a bool

hollow sandal
#

Sorry, can you list or retrieve via the Stripe API with a 'isn't null' or we just list and loop etc

rough relic
#

No you would loop

hollow sandal
#

ok thank you!