Payment API: How to Make Payment Through REST API in Magento 2

Nowadays, the mobile application has huge demand so providing the payment option by using mobile needs API to get the details and make payment done.

In this method, you can use the payments Magento 2 REST API to get the details and securely accept mobile payments through the mobile.

Magento 2 has many default payment methods so it depends on the customer-owner how they are going to give the customer experience. You can choose to make enable or disable that payment method.

The use of the PayPal payment method using REST API in Magento 2 can accept credit cards, debit cards to make payments done.

Magento Payment API

Cash On Delivery Payment API Configuration

If you are looking for the cash on delivery method option in Magento 2 then you can enable this payment method from

Admin > Stores > Configuration > Sales > Payment Method

You will see the COD option to enable and disable under other payment methods and set Enabled to Yes.

You can also set payment applicability countries.


Read more: How to Add Product in Cart Using REST API in Magento 2

Magento 2 Cash on Delivery REST API

This method allows the business owner to accept payment through the cash on delivery (COD) method from specific countries. Here you can also configure with minimum and maximum order total limits using COD REST API.

Method: GET


Payload: Not RequiredPayment Method Options in Magento 2Response:


"payment_methods": [


"code": "checkmo",

"title": "Check / Money order"



"code": "cashondelivery",

"title": "Cash On Delivery"



"code": "purchaseorder",

"title": "Purchase Order"



"code": "razorpay",

"title": "Razorpay"



"totals": {

"grand_total": 125,

"base_grand_total": 125,

"subtotal": 120,

"base_subtotal": 120,

"discount_amount": 0,

"base_discount_amount": 0,

"subtotal_with_discount": 120,

"base_subtotal_with_discount": 120,

"shipping_amount": 5,

"base_shipping_amount": 5,

"shipping_discount_amount": 0,

"base_shipping_discount_amount": 0,

"tax_amount": 0,

"base_tax_amount": 0,

"weee_tax_applied_amount": null,

"shipping_tax_amount": 0,

"base_shipping_tax_amount": 0,

"subtotal_incl_tax": 120,

"shipping_incl_tax": 5,

"base_shipping_incl_tax": 5,

"base_currency_code": "USD",

"quote_currency_code": "USD",

"items_qty": 1,

"items": [


"item_id": 289,

"price": 120,

"base_price": 120,

"qty": 1,

"row_total": 120,

"base_row_total": 120,

"row_total_with_discount": 0,

"tax_amount": 0,

"base_tax_amount": 0,

"tax_percent": 0,

"discount_amount": 0,

"base_discount_amount": 0,

"discount_percent": 0,

"price_incl_tax": 120,

"base_price_incl_tax": 120,

"row_total_incl_tax": 120,

"base_row_total_incl_tax": 120,

"options": "[]",

"weee_tax_applied_amount": null,

"weee_tax_applied": null,

"name": "SANJEEVNI®/SANJEEVNI+ Trichoderma wrap Biofungicide (IPL)"



"total_segments": [


"code": "subtotal",

"title": "Subtotal",

"value": 120



"code": "shipping",

"title": "Shipping & Handling (Flat Rate - Fixed)",

"value": 5



"code": "tax",

"title": "Tax",

"value": 0,

"extension_attributes": {

"tax_grandtotal_details": []




"code": "grand_total",

"title": "Grand Total",

"value": 125,

"area": "footer"






Step 2: Make Payment With COD REST API

Now, we got all the available payment methods in Magento 2 websites through the REST API so, In order to complete this payment, we have to send the payment method and the billing address along with it.

Method: POST




"paymentMethod": {

"method": "cashondelivery"


"billing_address": {

"email": "",

"region": "Uttar Pradesh",

"region_id": 566,

"region_code": "UP",

"country_id": "IN",

"street": ["Noida, Noida"],

"postcode": "201301",

"city": "Noida",

"telephone": "7992293862",

"firstname": "Hemant",

"lastname": "Singh"



Payment Cash on Delivery

Response: 79

Now we will get the order confirmation response.


Other Posts:

Razorpay Payment: Step By Step Guide to Integrate Payment Method

Product Order Payload: How To Order Product Using Magento 2 REST API