#dok_code

1 messages · Page 1 of 1 (latest)

night tartanBOT
#

👋 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/1412491715100541038

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

frosty ginkgo
#

hello! fyi the server is a little busy at the moment but i'll get back to you as soon as possible

queen hill
#

Thank you

#

Also just to add more info, I've tested this behavior using the Stripe Dashboard and it works fine. But I also read the API reference and it seems to suggest this behavior should also exist on the API but I can't seem to get it to work

https://docs.stripe.com/api/invoices

Stripe applies any customer credit on the account before determining the amount due for the invoice (i.e., the amount that will be actually charged). If the amount due for the invoice is less than Stripe’s minimum allowed charge per currency, the invoice is automatically marked paid, and we add the amount due to the customer’s credit balance which is applied to the next invoice.

However, if I try to create an invoice less than $0.50, it gives me an error and the invoice remains in Draft. Pic #1 is the draft invoice, Pic #2 is the error message I get

frosty ginkgo
#

ok, looking at this now

queen hill
#

And to give an example of this working via the Dashboard/GUI, here is an invoice that I've created manually that shows the behavior. The error happens when I call ->finalizeInvoice() so it seems to be tied to that action. However, when I use the dashboard, I can finalize an invoice with a balance under $0.50 without any error and it transfers the amount to the customer's balance

frosty ginkgo
#

any chance you can provide an example request ID where you tried this via the API and it failed?

queen hill
#

Yeah that error from Pic #2 is one. Here is the ID req_M3KkkQGaucTb7m

frosty ginkgo
#

hmm, let me see if i can reproduce this

#

i just tried with credit cards as a payment method so i wonder if it's specific to us_bank_account

#

when you tried that via the dashboard it was also using us_bank_account?

queen hill
#

Yes correct, when doing it through the dashboard, I was using a us_bank_account as well

#

I thought maybe the dashboard was setting the invoice amount_due to $0.00 and then separately setting a balance on the customer entity but it still has the line item for $0.14 on the successful invoice. I believe it should be possible to just do those 2 things separately but I still want a record month-to-month of how much the customer was "charged" even if we're not actually moving funds until they exceed the threshold.

frosty ginkgo
#

hmm, i just tried using us_bank_account via the API and that worked for me too. let me see if there's something specific to your flow that's causing this

queen hill
#

Hm, I am using a slightly older API version, I wonder if that matters?

2020-08-27 is the version I'm using

frosty ginkgo
#

good call, let me try one more time

queen hill
#

I'm glancing at the changelog and I don't believe I see any relevant updates to the invoice API after 2020-08-27 but maybe I'm missing it or it's not listed

frosty ginkgo
#

yeah, i was able to make this work in that version too so it has to be something about your flow that i'm missing. let me dig into it a bit more

queen hill
#

Hm okay thanks. I pasted most of my code snippet above, minus shortening part of it so that it would fit the word count. Here's the full snippet in case it helps:

` $invoice_item = $stripe->invoiceItems->create([
'description' => $invoice_label,
'customer' => $customer_id,
'amount' => (int)$invoice_total,
'currency' => 'USD',
//'invoice' => $invoice->id,
]);

$invoice = $stripe->invoices->create([
  'auto_advance' => FALSE,
  'customer' => $customer_id,
  'collection_method' => 'charge_automatically',
  'default_payment_method' => $pm->id,
  'payment_settings' => [
    'payment_method_types' => ['us_bank_account'],
  ]
]);

$stripe->invoices->finalizeInvoice($invoice->id, []);`

Error happens right after calling ->finalizeInvoice()

frosty ginkgo
#

hmmm, still not seeing anything. looking at it with some colleagues atm to see if they can spot the difference

queen hill
#

Okay thanks I appreciate the help

#

One other thought I had was maybe the stripe-php SDK version was playing a role. But I think that ultimately determines the API version and if you tested 2020-08-27 works fine, then I'm thinking that might not be relevant? We are on quite an old version of the SDK, v8.12

frosty ginkgo
#

ok, i think this might be specific to us_bank_account as a payment method

#

there was a configuration enabled on my account that was causing it to behave weirdly which is why i was seeing different behavior than you, but i've since fixed that and now i'm seeing the same error

queen hill
#

Ah okay interesting

frosty ginkgo
#

still testing out a few things though

#

ok yeah, that works for card payments

#

same API version

queen hill
#

Hm okay, it sounds like it might be a bug with the API? Since it works with the dashboard.

Ultimately I could recreate the behavior on my application side but I do like that Stripe keeps a record month-to-month of the amount charged, even if it doesn't move funds until it hits the threshold. If I recreate the same effect, I think I would lose that month-to-month record, or at least not have the same view of it. We've been doing these charges manually and it's worked but we've been trying to automate it so now I'm running into this

frosty ginkgo
#

it's worth noting that the dashboard often follows slightly different code paths than the API so their behavior isn't always 1:1

queen hill
#

Yeah that makes sense

#

But since the API doc mentioned the same behavior, I figured it would also exist via the API so I thought maybe I was doing something wrong

frosty ginkgo
#

it's possible that our support team might be able to help you out with this, but there are some other implications so it's probably best at this point if you chat with them:
https://support.stripe.com/

#

and yeah i agree, the docs are a little unclear on this so i will follow up with our docs team about clarifying this behavior

queen hill
#

Okay well I can try a few more things, I thought it might be an easy fix that I was overlooking. I can try and recreate the same effect using the Customer API and managing balances that way if the amount we're invoicing is less than $0.50 and I can talk with Support if I need some more assistance

#

I appreciate your time looking into this

frosty ginkgo
#

ok cool! that makes sense

#

yep of course! good luck 🙂