#smartbettormicah-developer_api

1 messages · Page 1 of 1 (latest)

soft scaffoldBOT
#

đź‘‹ Welcome to your new thread!

⏲️ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

đź”— This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1364429050529054741

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

limber aspen
#

I can quickly review some decline. Please provide an example PaymentIntent Id pi_xxx

winged olive
#

pi_3RFK5dG1sU52JuJt1v6rA0dA

#

It said incomplete and failed until I manually pressed the charge customer btuton

limber aspen
#

It was failed before but succeeded today, correct?

winged olive
#

Yes

limber aspen
#

Previously it was "The customer has insufficient funds with the payment provider. Retry attempts might succeed after the customer takes action to resolve the issue with their account"

#

So this is the customer issue, not your integration issue

winged olive
#

pi_3RGNqtG1sU52JuJt1zBSryOf

What about this one. It seemed like it wasn't able to charge because it said that "The customer has not attempted to pay this yet"

#

I am wondering if it is because we dont request to save default payment method

limber aspen
#

Um I see this one succeeded too

#

You are seeing otherwise?

winged olive
#

I see it succeeded now because I manually pressed charge customer

#

I guess that is the same issue, but this is a team member of ours and they did not change anything in their link. It got to the end of the trial and it just didn't charge the card

#

Do you think this is because we dont request to save the payment method as default payment method

limber aspen
#

I see. So either the Subscription needs to have the payment method in its default_payment_method, or the Customer needs to have it in their invoice_settings.default_payment_method

#

to be able to auto-charge

#

Quickly checking how you created the Subscription, one sec

#

Alright, when you create the Sub, can you specify this save_default_payment_method?

#

Or, you can directly set the PM to the customer instead

winged olive
#

subscription = stripe.Subscription.create(
customer=customer.id,
items=[{"price": price_id}],
trial_period_days=7,
discounts=(
[{"promotion_code": promotion_code["id"]}]
if promotion_code
else []
),
)

So how would I change this

limber aspen
#

Let's set the Customer's invoice_settings.default_payment_method instead, to the PM you collected

#

more explicit

winged olive
#

What do you mean

#

pi_3RDN08G1sU52JuJt1FVwYLAZ

I see what you are saying where it needs to be the default method to auto charge. But that does not explain why this one is still failing

#

And Also What do you suggest I do in the code for your previous suggestion

limber aspen
#

I would suggest calling the Update Customer API

#

If you don’t have the PM on either places, it won’t automatically charge

#

either places = customer’s default payment method or subscription’s default payment method

winged olive
#

Define your customer ID and payment method ID

customer_id = "cus_ABC123"
payment_method_id = "pm_1234567890"

Step 1: Attach the payment method to the customer

stripe.PaymentMethod.attach(
payment_method_id,
customer=customer_id,
)

Step 2: Set the default payment method for invoices

stripe.Customer.modify(
customer_id,
invoice_settings={
"default_payment_method": payment_method_id,
},
)

Something like this?

I think I would prefer to do it simpler

limber aspen
#

Yep, but you can omit Step 1 if it is already attached

#

Which is usually the case if you collected the PM with a customer Id

winged olive
#

I am pretty sure I did. So just make the payment_method_id the default

limber aspen
#

yep

winged olive
#

pi_3RDN08G1sU52JuJt1FVwYLAZ

That does not explain why this one is still failing. Super strange, seems the same but still cannot succeed

limber aspen
#
  code: "payment_intent_payment_attempt_failed",
  decline_code: "generic_decline",
#

This is a generic decline, which is the customer issue again, not yours

winged olive
#

Okay thank you for all of your help. Is there anywhere I can find documentation on adding the paymentn method to the customer. I want to make sure my syntax is right. Or can I quickly send it to you

limber aspen
winged olive
#

Thanks so much!