Not able to place the order using paypal in magento 2 rest

前端 未结 3 1141
臣服心动
臣服心动 2020-12-21 01:22

I am developing an e-commerce mobiloe application using magento 2 rest apis only.This is the flow for making the REST API calls for order placement.

3条回答
  •  囚心锁ツ
    2020-12-21 02:03

    In case someone still looking the solution.

    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 :

    di.xml

    
        
            
        
    
    

    Mycompanyorpersonal\Mymodule\Plugin\Paypal\Model\Express.php

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

提交回复
热议问题