Direct Payments PayPal Rest API

My site is currently accepting payments through PayPal. I am using the PHP SDK for the REST API for this. These are the steps that I take to process payments through my website:

  • Create a payment with the intent set for "Sale" for which the payment method is set to "PayPal" and the redirect URL is on the confirmation page.
  • On the confirmation page, I save the returned paymentId and PayerID (from the query string) for use in step 3.
  • As soon as the user confirms the order, I then complete the payment , passing the paymentId and PayerID identifiers saved in step 2.

It works. However, I would like to give the user the opportunity to process the payment through PayPal (for example, above) or through my website (using direct PayPal payments).

For direct payments, I was able to successfully create a payment by setting the intention to "Sale", the payment method to "credit_card" and transferring the relevant card details. However, I am not sure if I should make the payment after that, as I do above, or if the payment automatically passes.

If I need to make a payment, then how do I get paymentId and PayerID? If I do not need to make a payment, this creates a problem, because I want the user to confirm the payment. I could only move the created payment material after the user confirms the direct payment order, but then I canโ€™t check the card details after the user enters them. I was wondering if there is a better way to handle this?

I would appreciate it if someone would help clarify this. Thanks

+7
paypal-sandbox paypal-rest-sdk
source share
1 answer

You just need to process the first step (create a payment) when it comes to credit cards (more details here: https://developer.paypal.com/docs/integration/direct/accept-credit-cards/ ).

For your other question about problems, when you cannot confirm this, you can do a few things:

Since I think auth / capture is closer to what you think about it, let me dig there a little further. What you essentially do is allow the funds (keep them at the user's source of payment) and then fix them later. This is the same premise as the hotel holding your credit card for unforeseen circumstances and then canceling the hold.

You can do all this with the PayPal REST API. Here are the features you are looking for:

After you authorize, the point at which the user can confirm, and you can check the card. Once everything is approved, you can capture.

I know that this will not be a problem for you, but I will tell you about it anyway. With auth / capture, guaranteed funds will be stored there for only 3 days (honor period), but you can continue to collect funds for 29 days. After these three days, however, there is no guarantee that funds will be present.

Hope that helps

+1
source share

All Articles