#ronho

1 messages · Page 1 of 1 (latest)

dense brambleBOT
#

Hello! We'll be with you shortly. 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.

  • ronho, 18 hours ago, 57 messages
winged ore
#

so the flow is like

  • customer chooses product
  • customer enters biling info/zip
  • direct to confirmation page with 'automatic tax' calculation displayed on page
  • customer hits confirm
  • server finalizes invoice, and then we get 'customer_tax_location_invalid'
#

we can't finalize earlier because we would be able to give the customer an opportunity to change billing up until the point they hit "confirm"

storm magnet
#

Hi 👋

When you say billing info, you just mean payment method info? Are you collecting a biiling address?

winged ore
#

this is what we're collecting

storm magnet
#

Ack. Yeah we don't know the zipcode doesn't match until we communicate with the issuing bank

winged ore
#

so that happens during finalization only?

storm magnet
#

If you are only accepting payment in the US, the Postal Service has an API to validate zipcodes. You could listen to the change event and use the zipcode provided to check

#

It happens when we attempt to authorize the payment with the bank

winged ore
storm magnet
#

Finalization is the freezing of the invoice. We don't authorize the payment until you attempt to pay the invoice

winged ore
storm magnet
#

Yes that would be client-side

winged ore
# storm magnet Finalization is the freezing of the invoice. We don't authorize the payment unt...

hmm so how come the error triggers when i try to finalize ? it errors out on this call:

            final_invoice = stripe.Invoice.finalize_invoice(
                recent_invoice.id,
                auto_advance=False,
                expand=['payment_intent'],
            )
        except stripe.error.InvalidRequestError as e:
            if e.code == STRIPE_CONSTANTS.CUSTOMER_TAX_LOCATION_INVALID:
                return Response("CUSTOMER_TAX_LOCATION_INVALID", status=status.HTTP_400_BAD_REQUEST)
#

(my code that catches the tax error)

storm magnet
dense brambleBOT
winged ore
#

yes one second

#

req_0JJUeOyKuuoLFN

#

this was an example from last night

storm magnet
#

Ah yes I was focused on validation in terms of validating data for the payments. In this case we attempted to calculate taxes and couldn't use the zipcode provided.

We don't have a mechanism to force this on the client as far as I know. Even the Address Element https://stripe.com/docs/elements/address-element will still accept 11111 as a postal code.

winged ore
#

yeah i think we wanted to move the check earlier because right now the error only shows up after the user presses "confirm payment"

#

at which point behind the scenes, i am finalizing the invoice and then getting the error

#

but no way around this check until we finalize is what i am understanding?

still night
#

Stepping in for my teammate here!

#

At what point are you creating the invoice? One way you could handle this is to collect customer address details then use the retrieve an upcoming invoice endpoint to inspect the value of automatic_tax[status]. If the value is requires_location_inputs , you know you need more details from the customer before you can finalize an invoice that uses automatic tax

winged ore
#

for a single purchase, i am creating it earlier in the flow, as we need the invoice id and things earlier

#

but for a subscription i have been using the upcoming invoice to preview

#

so for single purchase, theres no way to really preview it ... i have to generate a invoice

still night
#

You'll need a step in between collecting addresses and finalizing the invoice, I think

winged ore
#

if we look at req_cu4bLJYdcriTBu, its the req right before i try to finalize

#

but the 'status' says 'complete'

still night
#

You could collect an address then look at a customer's tax[automatic_tax]. If the value is supported or not_collecting, invoice finalization shouldn't fail

winged ore
#

its on the customer object?

still night
#

Yep!

winged ore
#

ohh ok i see

#

yes now i see it, location invalid

#

ok i will give that a try first

still night
winged ore
#

thank you

#

ill reference this thread if i have further questions

#

(in case it closes)