Skip to content

Magento 2 API Routes

Yan Pantoja edited this page Jun 9, 2021 · 9 revisions

Route to cancel charge

[POST] https://mystoreurl/rest/default/V1/mundipagg/charge/cancel/{charge_id}

  • This feature cancels a charge through an id (charge_id)

PATH PARAMS

  1. charge_id* string
  • The charge id.

Response example

Our API uses standard HTTP codes as response to indicate the success or failure of a request.

200 OK

{
  "message": "Charge cancelada com sucesso"
}

400 Bad Request

{
  "message": "This charge can not be canceled."
}

401 Unauthorized

{
    "message": "The consumer isn't authorized to access %resources.",
    "parameters": {
        "resources": "Magento_Sales::sales"
    }
}

Route to perform multiple requests

[POST] http://mystoreurl/rest/default/V1/mundipagg/bulk

  • This feature executes multiple requests that are passed in the request body. It was initially designed to cancel multiple charges, but accepts other types of routes.

BODY PARAMS

  1. requests* array
  • Array of objects where each object contains the method of the request, the path of the route and the parameters of each route.
  1. access_token string (opcional)
  • Token for authenticating routes that are passed in the requests array.

The maximum number of requests that can be sent within this route must be determined by the store's technical manager, taking into account the processing limitations of the server used. This is because a large volume of requests will require more server resources which can cause a time-out before the operation is completed.


Request example

{
    "requests":[
        {
            "method": "post",
            "path":"/charge/cancel/ch_GPJgy45s6sxajw52",
            "params": {}
        },
        {
            "method": "post",
            "path":"/charge/cancel/ch_bM4JX7CYZs9adqpA",
            "params": {}
        },
        {
            "method": "post",
            "path": "/recurrence/plan/product",
            "params": {
                "productPlan" : {
                    "product_id": "2050",
                    "boleto" : true,
                    "credit_card" : true,
                    "allow_installments": true,
                    "intervalCount": 2,
                    "intervalType": "month",
                    "items": [
                        {
                            "product_id": 2,
                            "cycles": 2
                        },
                        {
                            "product_id": 2,
                            "cycles": 2
                        }
                    ]
                }
            }
        },
        {
            "method": "get",
            "path":"/recurrence/product/1",
            "params": {}
        }
    ],
    "access_token":"p1u1mw44xndbrih363ck39oebktxo981"
}

Response Example

Our API uses standard HTTP codes as response to indicate the success or failure of a request.

200 OK

[
    {
        "index": 0,
        "status": 200,
        "body": {
            "message": "Charge cancelada com sucesso"
        },
        "path": "/charge/cancel/ch_GPJgy45s6sxajw52",
        "method": "post"
    },
    {
        "index": 1,
        "status": 200,
        "body": {
            "message": "Charge cancelada com sucesso"
        },
        "path": "/charge/cancel/ch_bM4JX7CYZs9adqpA",
        "method": "post"
    },
    {
        "index": 2,
        "status": 404,
        "body": {
            "message": "Product id: 2. It's not correct"
        },
        "path": "/recurrence/plan/product",
        "method": "post"
    },
    {
        "index": 3,
        "status": 401,
        "body": {
            "message": "Consumer is not authorized to access %resources",
            "parameters": {
                "resources": "Magento_Catalog::products"
            }
        },
        "path": "/recurrence/product/1",
        "method": "get"
    }
]
"This route will always return an HTTP Code 200 OK, however the routes within the requests array will return their respective HTTP Code."
Clone this wiki locally