cancel
Showing results for 
Search instead for 
Did you mean: 

PLEASE HELP, REST API integration for Paypal or any other gateway. Magento 2.1

PLEASE HELP, REST API integration for Paypal or any other gateway. Magento 2.1

Hello Community,

We really need your help here,  we cant seem to find a single example of checking out with PayPal or any other gateway for via REST for Magento 2.1.   We would really really appreciate your help on this matter. 

 

Any info related to REST API and payment gateway integration would be extremely helpful.

2 REPLIES 2

Re: PLEASE HELP, REST API integration for Paypal or any other gateway. Magento 2.1

In the time I'm answering this, You will need to create a Magento 2 module to process the payment ID.

 

After you receive the response from in example Paypal android SDK.

 

Below is the JSON format that you can send to Magento endpoint :

  • for logged user : PUT /V1/carts/mine/order
  • for guest : PUT /V1/guest-carts/:cartId/order

Referrence : http://devdocs.magento.com/swagger

 

The "paypal_express_payment_payload" is just a custom attribute to hold the paypal payment response previously from android SDK.

 

{
    "paymentMethod": {
        "method": "paypal_express",
        "additional_data": {
            "paypal_express_payment_payload": "{\"create_time\":\"2017-06-15T23:13:52Z\",\"id\":\"PAY-2LB41725NU654612TLFBRIUQ\",\"intent\":\"sale\",\"state\":\"approved\"}"
        }
    }
}

 

To process the "paypal_express_payment_payload" data, you can implement a Interceptor in your Magento 2 module :

 

 

 

You can find the full PHP codes in my following gist : https://gist.github.com/feelinc/de817030e00adc7ff7001de1807c1835

Re: PLEASE HELP, REST API integration for Paypal or any other gateway. Magento 2.1

If you use the below to run a post query  replace runPostQuery with your curl request. this will pass a token that already has been successful to magento 2. 

<?php $payment['paymentMethod'] = ['method' =>'paypal_express', 'additional_data' => array ( 'paypal_express_checkout_token' => $request->query->get('token'), 'paypal_express_checkout_redirect_required' => false, 'paypal_express_checkout_payer_id' => $request->query->get('PayerID') )]; $completedPayment = $this->runPostQuery('carts/mine/payment-information', $headers, json_encode($payment));