Can't figure out how to charge taxes - paypal

I have set up the sales tax in my account but Paypal always return 0%
Here are the SetExpressCheckout parameters
This is the result
TOKEN=EC-03E58022CK445842R
&TIMESTAMP=2015-01-10T20:48:57Z
&CORRELATIONID=b875a01d29414
&ACK=Success
&VERSION=119
&BUILD=14726230
Then the user is redirected to Paypal and enter its billing address.
On the callback url, I do the GetExpressCheckoutDetails with the following parameters
and the result is
TOKEN=EC-5TF12550CK165913F
&BILLINGAGREEMENTACCEPTEDSTATUS=0
&CHECKOUTSTATUS=PaymentActionNotInitiated
&TIMESTAMP=2015-01-10T21:04:05Z
&CORRELATIONID=7eefa2e1b98b5
&ACK=Success
&VERSION=119
&BUILD=14726230
&EMAIL=something#hotmail.com
&PAYERID=WDUJK7NL59J7A&PAYERSTATUS=verified
&FIRSTNAME=SandboxTest
&LASTNAME=Account
&COUNTRYCODE=CA
&CURRENCYCODE=CAD
&AMT=59.99
&SHIPPINGAMT=0.00
&HANDLINGAMT=0.00
&TAXAMT=0.00
&INSURANCEAMT=0.00
&SHIPDISCAMT=0.00
&PAYMENTREQUEST_0_CURRENCYCODE=CAD
&PAYMENTREQUEST_0_AMT=59.99
&PAYMENTREQUEST_0_SHIPPINGAMT=0.00
&PAYMENTREQUEST_0_HANDLINGAMT=0.00
&PAYMENTREQUEST_0_TAXAMT=0.00
&PAYMENTREQUEST_0_INSURANCEAMT=0.00
&PAYMENTREQUEST_0_SHIPDISCAMT=0.00
&PAYMENTREQUEST_0_INSURANCEOPTIONOFFERED=false
&PAYMENTREQUEST_0_ADDRESSNORMALIZATIONSTATUS=None
&PAYMENTREQUESTINFO_0_ERRORCODE=0
so the sales tax are not calculated
and from the documentation it looks like you have to set up the taxes yourself SetExpressCheckout with L_PAYMENTREQUEST_n_TAXAMTm
but how are you supposed to know how much to charge if you don't know where the user lives?

After you call SetExpressCheckout and redirect the user to PayPal, they'll login and review the order, choose their shipping, etc. and are then sent back to the ReturnURL you specified.
That is where you'll call GetExpressCheckoutDetails like you did, which would typically contain the payer's shipping address. You could then calculate shipping and tax based on that address and display a final review page to your buyer which includes all of the totals.
Note that your GECD response doesn't include an address because you specified NOSHIPPING=1 in your SEC request.
When they submit that final review you'll call DoExpressCheckoutPayment, and make sure to include the shipping and tax parameters in that request in order for them to be included in the payment that gets processed at that point.
If you want to skip your own final review page, you can setup a callback service where PayPal's review page will POST the payer details to a script you have sitting on your server, which can then take the address, calculate shipping and tax values, and return them back to PayPal's review page, which populates a drop down on that page so the payer can choose from the rates your script returns. They call this the Instant Update API.

Related

PayPal Rest API Update transactions

I am using the PayPal Rest API to implement PayPal into my website. The flow for my site is below.
Users selects PayPal to pay
Create payment in code
Send to PayPal to approve
Sent back to Step 2 of my order process
User can update the shipping method or apply a coupon code
User Submits the order
As you can see the amount and details of my order can be changed after I create the initial payment in Step 2 of my process. Also a user could update items/amounts on their order as well.
How do I update the transactions of a payment after it gets approved?
you should use Payment authorization:
PayPal Authorization & Capture is a settlement solution that provides increased flexibility in obtaining payments from buyers. During a traditional sale at PayPal, the authorization and capture action is completed simultaneously. PayPal Authorization & Capture separates the authorization of payment from the capture of the authorized payment.
Authorization & Capture is for merchants who have a delayed order fulfillment process and who typically make a $1 USD authorization at checkout. It enables merchants to modify the original authorization amount due to order changes (such as taxes, shipping, or item availability) that occur after the buyers place the initial order. This chapter discusses the authorization and capture process and provides steps to help you authorize, capture, reauthorize, and void funds.
Paypal doc
you need to impelemnt instant update callback:
Here is how the Instant Update API works
When a buyer logs in to PayPal, the PayPal server calls your callback server with the buyer's default shipping address, which is stored in the PayPal system.
Your callback server responds with the shipping options available for that address, along with any insurance options and tax adjustments on the order.
PayPal displays this information in the cart review area so buyers can choose from the options.
The buyer's final choices are returned in the GetExpressCheckoutDetails response.
https://developer.paypal.com/docs/classic/express-checkout/integration-guide/ECInstantUpdateAPI/
hope this helps you

PP REST API charge tax and shipping without sending address?

Using the REST API, how can I charge tax or shipping if I send the user to PayPal to collect shipping information (and pay, of course)?
Doing some research it almost seems like that isn't possible, but I can't imagine that being the case. If I have to collect shipping information myself, the value prop for using PP is greatly reduced.
With the REST API, just like the Classic API, a PayPal payment is executed in three steps:
1) Send initial information to PayPal to get a token. Redirect customer to PayPal. Customer authorizes payment.
2) Get payment details (like the shipping address)
3) Confirm payment.
So, in this case, after getting the shipping address, you display an order review page to the customer where it will generate the shipping options and tax amount to the customer. They then have to select a "Confirm Order" button which will then finalize the charge to PayPal with the new tax/shipping and final amount.
In API terms, the final step is done with the /execute command. This accepts the payer_id you received in step 2, and a transactions array that supports a new amount object.
The amount object includes a details object that includes shipping, tax, handling fee, insurance, etc.
Include the details the customer decides on your review page and PayPal will charge the updated amount to the customer's funding source of choice.

Paypal: technique to obtain buyer's country for establishing postage prices without introducing extra steps

This is probably a stupid question, I think I'm having a mental block.
I want to use Paypal's express checkout for buyers to make purchases with as few steps as possible (also using Paypal's optional account feature). The problem is: for me to direct the user to paypal, I will need to have calculated shipping costs, which depends on the country they're in. Obviously I cannot know this unless I have been told one way or another. What are common solutions to this problem?
Ideas:
Use their IP address. Not reliable - various types of proxies, VPNs, anonymizers etc.
Have the user select their country from a drop-down box before I redirect them to paypal
Force them to log in using Paypal's Identity service before calculating postage
Use 1. or 2. and once payment is received, if country is different to expected,
Refund buyer the difference in postage cost or request an additional payment. (Hardly ideal)
Similar to 4., instead of "Sale Payment Action for Express Checkout" Use 1. or 2. in conjunction with one of Paypal's delayed express checkout payment methods and if necessary reduce or increase the amount charged:
Authorization Payment Action for Express Checkout
Order Payment Action for Express Checkout
I'd like to know what solutions other developers have chosen - maybe I've missed an idea. As a consumer, I cannot remember seeing solutions to this.
The general way people do this is simply to use GetExpressCheckoutDetails to obtain the buyer's shipping address, apply any shipping/tax as necessary, and display a final review page on your site that the user would confirm before calling DoExpressCheckoutPayment.
If you want to eliminate the additional review page (PayPal's and then your own) you can use the Instant Update API.
In this case you would include an additional parameter on the URL when you redirect to PayPal (useraction=commit) and this will change the button on the PayPal review page to say Pay instead of Continue.
Also in your SEC request you'll include the CALLBACK parameter and include a URL to your callback listener. PayPal's review page will POST the buyer's shipping address to this callback URL so that you can receive the data, calculate shipping and tax accordingly, and send a response of those options back to the PayPal review page. This will populate the PayPal review page's drop down menu for the shipping option and the user can choose accordingly.
This method allows you to utilize the PayPal review page entirely and finalize the payment there so that the only thing the user sees once they're returned to your site (after you call DECP) is a final thank you / receipt page.

Changing Shipping Address on Order Confirmation Step in PayPal Express Checkout

I am using the Express Checkout API to accept payments for my online store. The payment flow is as follows:
1) User adds Item to Cart
2) User proceeds to PayPal
3) User enters or selects existing shipping address, confirms, and is redirected to order confirmation step
4) Order Details such as Shipping Address are retrieved from PayPal using GetExpressCheckoutDetails.
5) On the order confirmation step (prior to DoExpressCheckoutPayment), user has the option to change the shipping address returned by PayPal. If user changes the shipping address, I need to recalculate the shipping cost to this new address, and submit the new shipping cost, as well as the new address back to PayPal
6) I am attempting to do this as part of the DoExpressCheckoutPayment payment call, using PAYMENTREQUEST_0_SHIPTONAME etc, but the shipping address within the transaction details does not change. (Likely because these are deprecated) Instead, the address chosen or entered on PayPal remains.
How can I submit a new shipping address to PayPal without having the user re-enter the transaction funnel from the beginning?
The shipping parameters in DECP are not deprecated. The documentation is a little bit misleading. It's the old version of those parameters, prior to when they added the ability to do parallel payments to EC, that are deprecated.
So, for example, SHIPTONAME is deprecated. Instead, you should now use PAYMENTREQUEST_n_SHIPTONAME like you have.
That said, whatever you send in the DECP request should be carried over to PayPal and end up being what is used for the payment's shipping address. In fact, if you don't include an address in DECP it shouldn't end up as part of the payment details in my experience.
If you want to provide a sample of the API requests during a checkout I'll be happy to take a look and see if I can figure out where you're going wrong.

PayPal Express Checkout

Is it necessary to have a confirm page after returning from PayPal with token and PayerID? Or there is no problem in calling directly DoExpressCheckoutPayment without showing confirm page to buyer?
You could use the useraction=commit variable in your SetExpressCheckout API call. The purpose of "useraction=commit" is to allow you to finalize the transaction automatically, immediately when the buyer returns, instead of offering them one more confirmation screen. You would do this in a scenario where you don't need to do things such as calculating shipping charges based on the address returned from GetExpressCheckoutDetails, and you are sure the original payment amount is the final amount.