#JCrags
1 messages ยท Page 1 of 1 (latest)
Those objects aren't searchable via the Dashboard unfortunately
Ah ok, thanks for the info
I am still having issues with this:
Still trying to figure out why.
Thought it was due to the Tax ID created but I guess not
Can you elaborate on what issue specifically is left over?
When I create a user myself, everything works fine in regards to updating the Tax Rate from my application side. However, when I call checkoutSession for a brand new user from the front-end. The checkout itself creates a user with the Tax ID. Now if the user goes to my application dashboard and tries to change their billing details (including changing their Tax ID) I can't re-calculate the correct Tax Rates. I am doing this by creating an invoice item with tax_behavior defined, and by creating a draft invoice. But everytime I get that error message saying that the invoice items does not have tax_behavior defined.
It doesn't matter if I enter a Tax ID on the checkout or not (e.g. checkout as a business/company).
Now if the user goes to my application dashboard and tries to change their billing details (including changing their Tax ID) I can't re-calculate the correct Tax Rates.
When you say "re-calculate", do you mean for future payments for that customer?
Yes/No, I just need the new tax rate so I can display the right amounts/price in the application
For instance if a customer moves to a different state it could require a different tax rate.
That's why.
The only time Stripe uses the automatic tax calculation is when creating the invoice. So that's a work-around I am using for the time being until Stripe offers a dedicated tax rate lookup.
Okay, so you're creating a separate Invoice that you're using to calculate the customer's new tax rate. At what point are you getting the error and what is the actual error message?
Let's say a brand new user visits this page: xxx.com/purchase. They choose a package, and they are redirected to the stripe checkout. From here they just fullfill the payment. API request goes to my server and I will create the user, and generate the first invoice. I will also store the Tax rate in our database for future use, alongside with the Tax ID (if the customer entered one). And I don't mean the tax value, but the ID that Stripe stores. e.g: txi_xxxxxxx (to not stress the stripe API by expanding the tax_ids on the customer object).
Now let's say the user comes back after 3 months, and wants to change their billing details. Let's say they moved to a different state. I now require the new tax rates, so in order to achieve this, I generate a pending invoice item with the tax_behavior set to exclusive and a custom price (price that does not exists yet, but created on the fly I guess by Stripe, as you can see in the code example). Then create the invoice, but then Stripe returns that error. And I can't figure out why. The only thing I know as of now is that it ONLY happens when a customer uses the checkout.
A user also has the option to create an account without making an initial purchase. In this case they just register with email/password. In that case I will also create an Stripe account directly via the API. When the user changes/updates the billing details this issue does not happen. But I can't see any reason / difference between the two customers being created directly via API or via the Checkout Session itself. I am honestly at a loss, and been stuck at this **** for two days hahaha.
That makes sense. Do you have a request ID for the API call that's throwing the error?
Here's how you can find a request ID: https://support.stripe.com/questions/finding-the-id-for-an-api-request
Find help and support for Stripe. Our support center provides answers on all types of situations, including account information, charges and refunds, and subscriptions information. Get your questions answered and find international support for Stripe.
Here you have a request ID: req_mktbKzE93HGQK3
{"status":400,"message":"Nothing to invoice for this customer. For `automatic_tax[enabled]=true` invoices, ensure all invoice items have a `tax_behavior` specified.","param":"customer","request_id":"req_mktbKzE93HGQK3","type":"invalid_request_error"}
The only thing I can think of right now is that there are invoice line items created that I can't see or that I don't know about? Why else would stripe give that error?
That's a good question. I'm not sure. Let me dig on this for a bit and circle back
Sure thing ๐
I will do the same
Just leaving this for reference:
{
"object": {
"id": "ii_1LimYHFKn7uROhgCzOzqTdpq",
"object": "invoiceitem",
"amount": 100,
"currency": "usd",
"customer": "cus_MRfrak97naWhqg",
"date": 1663365505,
"description": "tax rate product",
"discountable": true,
"discounts": [
],
"invoice": null,
"livemode": false,
"metadata": {
},
"period": {
"end": 1663365505,
"start": 1663365505
},
"plan": null,
"price": {
"id": "price_1LimYHFKn7uROhgC0yuhYZfP",
"object": "price",
"active": false,
"billing_scheme": "per_unit",
"created": 1663365505,
"currency": "usd",
"custom_unit_amount": null,
"livemode": false,
"lookup_key": null,
"metadata": {
},
"nickname": null,
"product": "prod_KxRfsj8c4rL72C",
"recurring": null,
"tax_behavior": "exclusive",
"tiers_mode": null,
"transform_quantity": null,
"type": "one_time",
"unit_amount": 100,
"unit_amount_decimal": "100"
},
"proration": false,
"quantity": 1,
"subscription": null,
"tax_rates": [
],
"test_clock": null,
"unit_amount": 100,
"unit_amount_decimal": "100"
}
}
notice price.active is set to false is it always like that when creating an invoice item that isn't correctly attached just yet to an invoice?
The one above is from the customer created via Checkout Session which returns the error when creating the invoice. The one below is from another customer created directly through the API and I am able to create the invoice item and the invoice without problems:
{
"object": {
"id": "ii_1LimchFKn7uROhgCg5GWTPcF",
"object": "invoiceitem",
"amount": 100,
"currency": "usd",
"customer": "cus_MRfy126RaXQcCc",
"date": 1663365779,
"description": "tax rate product",
"discountable": true,
"discounts": [
],
"invoice": null,
"livemode": false,
"metadata": {
},
"period": {
"end": 1663365779,
"start": 1663365779
},
"plan": null,
"price": {
"id": "price_1LimchFKn7uROhgC0dHfWji7",
"object": "price",
"active": false,
"billing_scheme": "per_unit",
"created": 1663365779,
"currency": "usd",
"custom_unit_amount": null,
"livemode": false,
"lookup_key": null,
"metadata": {
},
"nickname": null,
"product": "prod_KxRfsj8c4rL72C",
"recurring": null,
"tax_behavior": "exclusive",
"tiers_mode": null,
"transform_quantity": null,
"type": "one_time",
"unit_amount": 100,
"unit_amount_decimal": "100"
},
"proration": false,
"quantity": 1,
"subscription": null,
"tax_rates": [
],
"test_clock": null,
"unit_amount": 100,
"unit_amount_decimal": "100"
}
}
Hmmm
"currency": "usd",
I think that might be the issue (maybe). Because when I create a user via my own system via the API, they basically are not assigned any currency really. So when I create an invoice item and invoice via the API, the user will get the currency usd assigned? While the one that was created via Checkout Session get's currency eur because that's how it is for users that are logged out and making a payment. At least right now... Could this be the reason for the error? Even though that error doesn't make any sense if that's the real reason? I will quickly try to change the currency on that price to eur to at least test if this is the case or not.
You won't actually believe it, but it works lol...
There is definitely a bug in Stripe then because first of all it shouldn't be returning that error message (it's unrelated to the real reason). And second, I should be able to create an invoice with a different currency for a customer.
Am I right?
Ahhhh, I think you have to have the default_payment_method on the Customer set to a payment method that supports the new currency in order for Stripe to recognize the pending Invoice Item. So the error is definitely not helpful
Changed it to this:
8022 iiparams := &stripe.InvoiceItemParams{
1 Currency: stripe.String("EUR"),
2 Customer: stripe.String(customerId),
3 Description: stripe.String("tax rate product"),
4 Quantity: stripe.Int64(1),
5 PriceData: &stripe.InvoiceItemPriceDataParams{
6 Currency: stripe.String("EUR"),
7 Product: stripe.String(productId),
8 TaxBehavior: stripe.String(taxBehavior),
9 UnitAmount: stripe.Int64(100),
10 },
11 }
and it now works . But now I guess the other customer with usd won't work anymore
I probably will have a little bit of a problem anyway, because my application also deals with subscriptions.
And subscriptions do not allow different currencies per customer. So I will probably be better of by just changing the checkout session currency to "USD". But then I won't be able to accept other payment methods like iDeal right?
ooof...
I will give default_payment_method a try to at least solve that issue. But at least I know now what the real issue is. Can you make sure the API returns a proper error message in the future? Something like Invoice item currency must match customers currency or something like that.
Can you make sure the API returns a proper error message in the future?
Absolutely. Once I'm off DIscord I'll make sure the product team takes a look at the error message and I'll see if I can work with them to update it to something more useful
That would be great. In the meantime I will try to make my application multi-currency compatible haha! ๐ have good weekend ๐