cancel
Showing results for 
Search instead for 
Did you mean: 

How to make Credit card payment in Magento 2 using Rest API?

How to make Credit card payment in Magento 2 using Rest API?

I am working on Magento 2.3 REST API for a Roku application. Our client wants to give payment option on Roku device for his customers.

I have followed these APIs step by step:

1. http://10.1.1.5/demo/rest/V1/integration/customer/token

2. http://10.1.1.5/demo/rest/V1/carts/mine

3. http://10.1.1.5/demo/rest/V1/carts/mine/items

4. http://10.1.1.5/demo/rest/V1/carts/mine/shipping-information

It returns payment method:

"payment_methods": [
        {
            "code": "pmclain_authorizenetcim_vault",
            "title": "Stored Cards (Authorize.net CIM)"
        },
        {
            "code": "pmclain_authorizenetcim",
            "title": "Credit Cards (CIM)"
        },
        {
            "code": "braintree_cc_vault",
            "title": "Stored Cards (Braintree)"
        },
        {
            "code": "braintree",
            "title": "Credit Card (Braintree)"
        },
        {
            "code": "checkmo",
            "title": "Check / Money order"
        }
    ],

5. http://10.1.1.5/demo/rest/V1/carts/mine/payment-information

And payload for this api is:

{
 "email": "test@gmail.com",
 "cart_id": 180,
 "billing_address": {
              "email": "test@gmail.com",
             "region": "New York",
             "region_id": 43,
             "region_code": "NY",
                 "country_id": "US",
                 "street": ["123 Oak Ave"],
                 "postcode": "10577",
                 "city": "Purchase",
                 "telephone": "512-555-1111",
                 "firstname": "Jane",
                 "lastname": "Doe"
      },
 "paymentMethod": {
    "method": "pmclain_authorizenetcim",
    "additional_data":{  
        "cc_cid":"123",
        "cc_type":"VI",
        "cc_exp_year":"2021",
        "cc_exp_month":"3",
        "cc_number":"4111111111111111"
    }
 }
}

And response I am getting:

{
    "message": "Opaque Data requires Data Value."
}

 

I think this is happens due to invalid payload or I am not doing this in right direction. Since I am new for Magento so unable to figure out this problem.


Could i directly send credit card details to API "rest/V1/carts/mine/payment-information" or need to something like payment token? If i need payment token then what will be magento api for this? 
could anyone please suggest me how to do this or am I doing in incorrect way?

I have configured Authorize.Net in magento backend and also want to use this payment option in Roku device but not sure is this possible or not for Roku device?

Thank you!