Paypal: Is there a way to check a cart right before a user pays? - paypal

Is there any way currently for Paypal's API to send my site an authorization request before completing a user's payment?
I think the answer here would be that there is no way to do this, but one can set "authorization" as a cart parameter instead of "sale". This still leaves the question of how to complete the authorization in the callback.

May be this would clarify your doubt up to a certain extent.
Authorization & Capture starts when your buyer authorizes a payment amount during checkout.
For example, you can use the PayPal Express Checkout API with the PAYMENTACTION element set to Authorization or Order.
After your buyer completes checkout, you can then use the payment’s transaction ID with Authorization & Capture APIs. You can:
Capture either a partial amount or the full authorization amount.
Authorize a higher amount, up to 115% of the originally authorized amount (not to exceed an increase of $75 USD).
Void a previous authorization.

Related

How can i capture more then autorized amount

On the PayPal developer site they state it is possible to capture 75 US Dollar or 15% percent more than the original authorized amount of a payment. I am currently using the order API because I can't seem to figure out how to create a Payment from the payment API. My question is the following: how can I capture a different amount then the authorized amount(order API). In the capture section of the Order API I can't give up a new amount. I tried to patch the order first but after the amount was authorized the status of the order is COMPLETED, so the value couldn't be updated.
I think the reason I don't understand how to do it is because I don't know the difference between Order and Payment API. I would like to use the payment API but I can not find an PayPal API to create a payment.
Use the order API with "intent":"authorize". The completed order will have a payment authorization object in the response.
Use the payment API to capture the authorization object for the desired amount, https://developer.paypal.com/docs/api/payments/v2/#authorizations_capture

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

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.

Handling unknown shipping costs via PayPal Express nvp API

Can some confirm something for me; I've searched PayPal's docs and just can't find the answer.
If calling SetExpressCheckout with the parameter 'TOTALTYPE'= 'EstimatedTotal', how much headroom does PayPal allow for finalizing the transaction?
For example, someone carts an item that has a cost of $1. They click PayPal Express and get sent to PayPal to authorize an estimated amount of $1. Then they return to the merchant site and now that their address is known, the cart says shipping is +$20.
Is that acceptable? I'd really like to understand the groundrules on this, as I don't want to risk any authorization errors due to insufficient order amount when making the request.
Well, I have to answer my own question here. I called PayPal. The answer is "it's handled, don't worry about it". They would rather not publish the details on their proprietary algorithm because there are fraud tests, etc. going on -- but said it is a key design point for them and it is absolutely handled no worries.
If you are not passing a SHIPPINGAMT variable with the SetExpressCheckout call, then we will not display or "calculate" shipping on the PayPal page. When they are transferred to the PayPal page the customer is not authorizing the payment per se, rather they are selecting their payment method/funding source to be used when the DoExpressCheckout call is passed.
Only after the customer is transferred back to your page, and the final order total is known and passed via the DoExpressCheckout is the payment initiated. The difference between the total amount in the Set call and the Do call does not matter. Perhaps the agent with whom you were speaking with under the impression of an authorize/capture structure being in place. This will limit the final capture amount to the authorized amount +/- 20%.
Of course this is all turned on its head if you are passing the USERACTION=COMMIT variable which will "finalize" the payment on the PayPal page, while the DoExpress call is run transparently on your end. This will change the text on the button on the PayPal page to "Pay Now" instead of "Continue: You're almost done. You will confirm your payment on yourwebsitehere.com"
I hope this helps!

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.