Magento 2: How to change the on-line payment action method in Paypal Express

I already created a Paypal / Developer / Sandbox account. Already got the API credentials.

Downloaded PHP SDK http://paypal.imtqy.com/PayPal-PHP-SDK/

Referring: https://developer.paypal.com/docs/api/

https://devtools-paypal.com/guide/expresscheckout/php?interactive=ON&env=sandbox

I have already completed the Sandbox One transaction using the Authorization method using my PHP Script.

What should I achieve. I need to get authorization of payments, convert payments "Authorize" to the method "Capture / sale", and also notify the client and administrator.

How to get an authorization identifier?

Going through the above document, I need to use 3 web services

  • Get Authorized Payment Information
  • Authorized payment capture
  • Get captured payment information

Already have a transaction ID "Authorize" payment.

Please indicate the steps that should be followed, and if any example is already available, please share

It is necessary to integrate this functionality in Magento 2

[UPDATE]

I changed my Sandbox API data in the PHP SDK in the PayPal-PHP-SDK-master\sample\bootstrap.php file.

From sample/payments/AuthorizePayment.php I will receive an Authorized payment with ID: PAY-0TV39791XXX02404VK7XD32I and it works great.

When I enter my Transaction Id , it gives

{"name": "INVALID_RESOURCE_ID", "message": "The requested resource identifier was not found.", "information_link": " https://developer.paypal.com/webapps/developer/docs/api/#INVALID_RESOURCE_ID ", "debug_id": "1f2b08ce88633"}

My Sandbox Transaction ID is 3AA32794KF48247AA . So the question is, how do you convert your transaction id to a payment id?

https://magento.stackexchange.com/questions/138579/magento-2-change-paypal-action-method-on-the-fly

Below is the answer from Paypal

Transaction ID can be generated after executing the REST API, Classic API [NVP / SOAP] DoEC API, or the usual completion of a button payment. It will not work to cancel the search in order to find the payment identifier.

+5
source share
1 answer

If you have paymentId, you can get information about authorized payment in this way:

 $payment = Payment::get( $paymentId, $apiContext ); 

For all the benefits of a payment class, see this - Payment.php

To change your Sandbox / API credentials, edit bootstrap.php in your project.

UPDATE

You do not need to use AuthorizePayment.php. Isted, do the following:

  • Create a payment and get the URL for authorization (on your website).
  • Print the authorization URL (on the side of your website).
  • Cutomer follow the authorization URL and go to PayPal and authorize the payment (PayPal side).
  • PayPal returns the customer to your site using paymentId (PayPal side).
  • Take paymentId and complete the payment (from your site).
+1
source

Source: https://habr.com/ru/post/1257495/


All Articles