Welcome to Code Forum!

Join a community that supports you and your coding journey from day one. We strive to be a friendly, supportive community that empowers everyone to be better developers. By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.

    GIF shows where to locate </> in the thread and or post editor toolbar.
    To learn more about how to use our BBCode feature, review our "How to post your code into threads" here.

    Thank you, Code Forum.

Node.JS How to know how much to tax a buyer when using prepayment processor?

Sneaky

New Coder
I am just learning the ropes of Square API. I am currently using google pay api and then sending the token to the backend using square API. I am a bit lost on the topic of applying tax correctly. I am from Canada. From my current understanding, I only charge tax on canadian buyers (and also based on their province), else I don't charge tax. (I don't have a nexus in US)

Now to figure out which province they are from, I believe I need to get it from the google token, but I can't figure out how. I think I can get it from client side and I guess I could send it to server, but you can't trust anything sent from the client side unless its cryptographically signed like the google token from google pay. So I was thinking to decode it and get the billing address from there, but I can't figure out how. I also read you are not supposed to decode the token from google pay, just pass it on to square api. But then how would you reliably know the users province to know how much to tax them? Does anyone have any advice for this?
 
I am just learning the ropes of Square API. I am currently using google pay api and then sending the token to the backend using square API. I am a bit lost on the topic of applying tax correctly. I am from Canada. From my current understanding, I only charge tax on canadian buyers (and also based on their province), else I don't charge tax. (I don't have a nexus in US)

Now to figure out which province they are from, I believe I need to get it from the google token, but I can't figure out how. I think I can get it from client side and I guess I could send it to server, but you can't trust anything sent from the client side unless its cryptographically signed like the google token from google pay. So I was thinking to decode it and get the billing address from there, but I can't figure out how. I also read you are not supposed to decode the token from google pay, just pass it on to square api. But then how would you reliably know the users province to know how much to tax them? Does anyone have any advice for this?
You have to ask user and get it directly, maybe send it separately from client side. You could also use IP or navigator.geolocation but billing address is better. If you can't control things enough to get all you need, make a different setup. Also, if you sell outside your home country there are separate taxes, tariffs, blah, but only for outside your country. X E.
 
I am just learning the ropes of Square API. I am currently using google pay api and then sending the token to the backend using square API. I am a bit lost on the topic of applying tax correctly. I am from Canada. From my current understanding, I only charge tax on canadian buyers (and also based on their province), else I don't charge tax. (I don't have a nexus in US)

Now to figure out which province they are from, I believe I need to get it from the google token, but I can't figure out how. I think I can get it from client side and I guess I could send it to server, but you can't trust anything sent from the client side unless its cryptographically signed like the google token from google pay. So I was thinking to decode it and get the billing address from there, but I can't figure out how. I also read you are not supposed to decode the token from google pay, just pass it on to square api. But then how would you reliably know the users province to know how much to tax them? Does anyone have any advice for this?
Hi there
You are treading very dangerous waters there bud. I suggest you move away from that and instead find you answer here


Square is the odd ball of the payment gateways so, there is no clear and clean way to implement
 

Buy us a coffee!

Buy me a coffee.
Back
Top Bottom