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
paypal-sandbox paypal-rest-sdk
nfplee
source share