#b33fb0n3_best-practices

1 messages ยท Page 1 of 1 (latest)

celest daggerBOT
#

๐Ÿ‘‹ 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/1318972011372085308

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.

bleak lintel
#

Hello
What Stripe APIs are you using to create invoices and collect payment from the customers?

#

The payment method needs to set up for future use before you can charge them for other charges.

graceful sedge
bleak lintel
#

Ah so you're using Invoices API directly. Hmm.. I don't think there's a way to set up the payment method from customer in the flow you currently have.

graceful sedge
bleak lintel
#

Gotcha. Let me test something quickly..

#

Okay so I found a workaround that might work with little bit of tweaking.

In your current flow, after you finalize the invoice - the invoice would generate a PaymentIntent. Once the PaymentIntent gets generated, you can update the Intent and specify which payment method types you want to set up for future use by utilizing following param - https://docs.stripe.com/api/payment_intents/update#update_payment_intent-payment_method_options

the request options would look something like

payment_method_options: {
    card: {
      setup_future_usage: 'off_session'
    }
  },

Once you update the PaymentIntent, the hosted invoice page should save and attach the card customer pays with.

You can list the attached payment method using this API - https://docs.stripe.com/api/payment_methods/customer_list

And pass the payment method ID to the next invoice you create using default_payment_method param - https://docs.stripe.com/api/invoices/create#create_invoice-default_payment_method

graceful sedge
bleak lintel
#

Sure

celest daggerBOT
graceful sedge
#

It looks like it's working! Just to get this right the collection method must also be changed, right?

bleak lintel
#

It should work with either collection methods

graceful sedge
#

I just tried it with both:
charge_automatically: in_1QXQU0GdgFrJRsM6fQqa6z0n
send_invoice: in_1QXQR1GdgFrJRsM6SkcZrq9T

For this customer: cus_RQGk29IZ4ZElAT

However, even if the payment method is attached (and made as default), it won't be fulfilled.

chilly lily
#

Hello! I'm taking over and catching up...

graceful sedge
#

sure ๐Ÿ‘

#

This is what I done: #1318972011372085308 message

And you can see inside the provided ids, that everything works fine except the automatic collection of the invoice

chilly lily
#

Can you clarify what you mean by "won't be fulfilled"?

graceful sedge
chilly lily
#

It should be with charge_automatically as long as you don't turn off auto advance.

graceful sedge
chilly lily
#

Right, but have you tried either of the things I mentioned above?

graceful sedge
#

Inside the docs it's not clear what's the default value

graceful sedge
chilly lily
#

It depends on the payment method. I recommend you try setting auto_advance to true when you finalize and then see what happens first. Then, after that, try /pay and see how that works.

graceful sedge
chilly lily
#

There is no default, it depends on the state of the underlying Invoice.

graceful sedge