Managing Payment Links

Ecart Pay allows you to update or delete existing payment link templates through its API. This functionality is essential for modifying details like the shipping address, items, or other configurations without creating a new link from scratch.

To ensure flexibility and maintain up-to-date payment link details, Ecart Pay allows updates to existing templates. This can be done using the following endpoints:

⚠️

IMPORTANT

To follow the steps below, it is essential to have the corresponding Authorization Token. For more information, please refer to the following documentation page: Authorization Token

Update Payment Link Template

Use the following endpoint to update an existing payment link template. You can adjust various parameters such as the recipient's details, item information, usage limits, and more.

💻

Visit our API Reference to test this endpoint.

Endpoint

  • PUT https://ecartpay.com/api/templates/{{id}}
  • PUT https://sandbox.ecartpay.com/api/templates/{{id}} (Sandbox only)

Headers

  • Authorization: {token}
  • Content-Type: application/json

Path Parameters

  • id: The id of the payment link template to update.

Examples

Request Body

Here is an example of the structure to use when updating a payment link:

{
    "shipping_address": {
        "first_name": "Juana",
        "last_name": "Perez",
        "address1": "Padros de la Capilla",
        "address2": "Gladiolas",
        "country": {
            "code": "MX",
            "name": "Mexico"
        },
        "state": {
            "code": "TB"
        },
        "city": "Monterrey",
        "postal_code": "64000",
        "phone": "1111111111",
        "reference": "reference"
    },
    "items": [
        {
            "discount": 0,
            "tax": 0,
            "name": "Collar oro BZ3909",
            "quantity": 3,
            "price": 4
        }
    ],
    "quantity_uses": -1,
    "first_name": "Anita",
    "start_date": "2021-06-18 17:00:00",
    "currency": "MXN",
    "shipping_items": [
        {
            "name": "Express Shipping",
            "amount": 1,
            "carrier": "OWN"
        }
    ],
    "installments_information": [
      {
        "quantity": 3,
        "fixed_installments": false
      },
      {
        "quantity": 6,
        "fixed_installments": true
      },
      {
        "quantity": 12,
        "fixed_installments": false
      }
    ],
    "end_date": null,
    "discounts": []
}

Request

curl --location --request PUT 'https://sandbox.ecartpay.com/api/templates/65a864a93df1d9cacf436c5a' \
--header 'Authorization: <your_merchant_token>' \
--header 'Content-Type: application/json' \
--header 'Cookie: lang=en' \
--data '{
    "shipping_address": {
        "first_name": "Juana",
        "last_name": "Perez",
        "address1": "Padros de la Capilla",
        "address2": "Gladiolas",
        "country": {
            "code": "MX",
            "name": "Mexico"
        },
        "state": {
            "code": "TB"
        },
        "city": "Monterrey",
        "postal_code": "64000",
        "phone": "1111111111",
        "reference": "reference"
    },
    "items": [
        {
            "discount": 0,
            "tax": 0,
            "name": "Collar oro BZ3909",
            "quantity": 3,
            "price": 4
        }
    ],
    "quantity_uses": -1,
    "first_name": "Anita",
    "start_date": "2021-06-18 17:00:00",
    "currency": "MXN",
    "shipping_items": [
        {
            "name": "Express Shipping",
            "amount": 1,
            "carrier": "OWN"
        }
    ],
    "end_date": null,
    "discounts": []
}'
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io"
)

func main() {

  url := "https://sandbox.ecartpay.com/api/templates/65a864a93df1d9cacf436c5a"
  method := "PUT"

  payload := strings.NewReader(`{`+"
"+`
    "shipping_address": {`+"
"+`
        "first_name": "Juana",`+"
"+`
        "last_name": "Perez",`+"
"+`
        "address1": "Padros de la Capilla",`+"
"+`
        "address2": "Gladiolas",`+"
"+`
        "country": {`+"
"+`
            "code": "MX",`+"
"+`
            "name": "Mexico"`+"
"+`
        },`+"
"+`
        "state": {`+"
"+`
            "code": "TB"`+"
"+`
        },`+"
"+`
        "city": "Monterrey",`+"
"+`
        "postal_code": "64000",`+"
"+`
        "phone": "1111111111",`+"
"+`
        "reference": "reference"`+"
"+`
    },`+"
"+`
    "items": [`+"
"+`
        {`+"
"+`
            "discount": 0,`+"
"+`
            "tax": 0,`+"
"+`
            "name": "Collar oro BZ3909",`+"
"+`
            "quantity": 3,`+"
"+`
            "price": 4`+"
"+`
        }`+"
"+`
    ],`+"
"+`
    "quantity_uses": -1,`+"
"+`
    "first_name": "Anita",`+"
"+`
    "start_date": "2021-06-18 17:00:00",`+"
"+`
    "currency": "MXN",`+"
"+`
    "shipping_items": [`+"
"+`
        {`+"
"+`
            "name": "Express Shipping",`+"
"+`
            "amount": 1,`+"
"+`
            "carrier": "OWN"`+"
"+`
        }`+"
"+`
    ],`+"
"+`
    "end_date": null,`+"
"+`
    "discounts": []`+"
"+`
}`)

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("Authorization", "<your_merchant_token>")
  req.Header.Add("Content-Type", "application/json")
  req.Header.Add("Cookie", "lang=en")

  res, err := client.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()

  body, err := io.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}
PUT /api/templates/65a864a93df1d9cacf436c5a HTTP/1.1
Host: sandbox.ecartpay.com
Authorization: <your_merchant_token>
Content-Type: application/json
Cookie: lang=en
Content-Length: 966

{
    "shipping_address": {
        "first_name": "Juana",
        "last_name": "Perez",
        "address1": "Padros de la Capilla",
        "address2": "Gladiolas",
        "country": {
            "code": "MX",
            "name": "Mexico"
        },
        "state": {
            "code": "TB"
        },
        "city": "Monterrey",
        "postal_code": "64000",
        "phone": "1111111111",
        "reference": "reference"
    },
    "items": [
        {
            "discount": 0,
            "tax": 0,
            "name": "Collar oro BZ3909",
            "quantity": 3,
            "price": 4
        }
    ],
    "quantity_uses": -1,
    "first_name": "Anita",
    "start_date": "2021-06-18 17:00:00",
    "currency": "MXN",
    "shipping_items": [
        {
            "name": "Express Shipping",
            "amount": 1,
            "carrier": "OWN"
        }
    ],
    "end_date": null,
    "discounts": []
}
// OkHttp

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n    \"shipping_address\": {\r\n        \"first_name\": \"Juana\",\r\n        \"last_name\": \"Perez\",\r\n        \"address1\": \"Padros de la Capilla\",\r\n        \"address2\": \"Gladiolas\",\r\n        \"country\": {\r\n            \"code\": \"MX\",\r\n            \"name\": \"Mexico\"\r\n        },\r\n        \"state\": {\r\n            \"code\": \"TB\"\r\n        },\r\n        \"city\": \"Monterrey\",\r\n        \"postal_code\": \"64000\",\r\n        \"phone\": \"1111111111\",\r\n        \"reference\": \"reference\"\r\n    },\r\n    \"items\": [\r\n        {\r\n            \"discount\": 0,\r\n            \"tax\": 0,\r\n            \"name\": \"Collar oro BZ3909\",\r\n            \"quantity\": 3,\r\n            \"price\": 4\r\n        }\r\n    ],\r\n    \"quantity_uses\": -1,\r\n    \"first_name\": \"Anita\",\r\n    \"start_date\": \"2021-06-18 17:00:00\",\r\n    \"currency\": \"MXN\",\r\n    \"shipping_items\": [\r\n        {\r\n            \"name\": \"Express Shipping\",\r\n            \"amount\": 1,\r\n            \"carrier\": \"OWN\"\r\n        }\r\n    ],\r\n    \"end_date\": null,\r\n    \"discounts\": []\r\n}");
Request request = new Request.Builder()
  .url("https://sandbox.ecartpay.com/api/templates/65a864a93df1d9cacf436c5a")
  .method("PUT", body)
  .addHeader("Authorization", "<your_merchant_token>")
  .addHeader("Content-Type", "application/json")
  .addHeader("Cookie", "lang=en")
  .build();
Response response = client.newCall(request).execute();

// -------------------------------------------------------------

// Unirest

Unirest.setTimeouts(0, 0);
HttpResponse<String> response = Unirest.put("https://sandbox.ecartpay.com/api/templates/65a864a93df1d9cacf436c5a")
  .header("Authorization", "<your_merchant_token>")
  .header("Content-Type", "application/json")
  .header("Cookie", "lang=en")
  .body("{\r\n    \"shipping_address\": {\r\n        \"first_name\": \"Juana\",\r\n        \"last_name\": \"Perez\",\r\n        \"address1\": \"Padros de la Capilla\",\r\n        \"address2\": \"Gladiolas\",\r\n        \"country\": {\r\n            \"code\": \"MX\",\r\n            \"name\": \"Mexico\"\r\n        },\r\n        \"state\": {\r\n            \"code\": \"TB\"\r\n        },\r\n        \"city\": \"Monterrey\",\r\n        \"postal_code\": \"64000\",\r\n        \"phone\": \"1111111111\",\r\n        \"reference\": \"reference\"\r\n    },\r\n    \"items\": [\r\n        {\r\n            \"discount\": 0,\r\n            \"tax\": 0,\r\n            \"name\": \"Collar oro BZ3909\",\r\n            \"quantity\": 3,\r\n            \"price\": 4\r\n        }\r\n    ],\r\n    \"quantity_uses\": -1,\r\n    \"first_name\": \"Anita\",\r\n    \"start_date\": \"2021-06-18 17:00:00\",\r\n    \"currency\": \"MXN\",\r\n    \"shipping_items\": [\r\n        {\r\n            \"name\": \"Express Shipping\",\r\n            \"amount\": 1,\r\n            \"carrier\": \"OWN\"\r\n        }\r\n    ],\r\n    \"end_date\": null,\r\n    \"discounts\": []\r\n}")
  .asString();
// Fetch

const myHeaders = new Headers();
myHeaders.append("Authorization", "<your_merchant_token>");
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Cookie", "lang=en");

const raw = JSON.stringify({
  "shipping_address": {
    "first_name": "Juana",
    "last_name": "Perez",
    "address1": "Padros de la Capilla",
    "address2": "Gladiolas",
    "country": {
      "code": "MX",
      "name": "Mexico"
    },
    "state": {
      "code": "TB"
    },
    "city": "Monterrey",
    "postal_code": "64000",
    "phone": "1111111111",
    "reference": "reference"
  },
  "items": [
    {
      "discount": 0,
      "tax": 0,
      "name": "Collar oro BZ3909",
      "quantity": 3,
      "price": 4
    }
  ],
  "quantity_uses": -1,
  "first_name": "Anita",
  "start_date": "2021-06-18 17:00:00",
  "currency": "MXN",
  "shipping_items": [
    {
      "name": "Express Shipping",
      "amount": 1,
      "carrier": "OWN"
    }
  ],
  "end_date": null,
  "discounts": []
});

const requestOptions = {
  method: "PUT",
  headers: myHeaders,
  body: raw,
  redirect: "follow"
};

fetch("https://sandbox.ecartpay.com/api/templates/65a864a93df1d9cacf436c5a", requestOptions)
  .then((response) => response.text())
  .then((result) => console.log(result))
  .catch((error) => console.error(error));

// -------------------------------------------------------------

// jQuery

var settings = {
  "url": "https://sandbox.ecartpay.com/api/templates/65a864a93df1d9cacf436c5a",
  "method": "PUT",
  "timeout": 0,
  "headers": {
    "Authorization": "<your_merchant_token>",
    "Content-Type": "application/json",
    "Cookie": "lang=en"
  },
  "data": JSON.stringify({
    "shipping_address": {
      "first_name": "Juana",
      "last_name": "Perez",
      "address1": "Padros de la Capilla",
      "address2": "Gladiolas",
      "country": {
        "code": "MX",
        "name": "Mexico"
      },
      "state": {
        "code": "TB"
      },
      "city": "Monterrey",
      "postal_code": "64000",
      "phone": "1111111111",
      "reference": "reference"
    },
    "items": [
      {
        "discount": 0,
        "tax": 0,
        "name": "Collar oro BZ3909",
        "quantity": 3,
        "price": 4
      }
    ],
    "quantity_uses": -1,
    "first_name": "Anita",
    "start_date": "2021-06-18 17:00:00",
    "currency": "MXN",
    "shipping_items": [
      {
        "name": "Express Shipping",
        "amount": 1,
        "carrier": "OWN"
      }
    ],
    "end_date": null,
    "discounts": []
  }),
};

$.ajax(settings).done(function (response) {
  console.log(response);
});

// -------------------------------------------------------------

// XHR

var data = JSON.stringify({
  "shipping_address": {
    "first_name": "Juana",
    "last_name": "Perez",
    "address1": "Padros de la Capilla",
    "address2": "Gladiolas",
    "country": {
      "code": "MX",
      "name": "Mexico"
    },
    "state": {
      "code": "TB"
    },
    "city": "Monterrey",
    "postal_code": "64000",
    "phone": "1111111111",
    "reference": "reference"
  },
  "items": [
    {
      "discount": 0,
      "tax": 0,
      "name": "Collar oro BZ3909",
      "quantity": 3,
      "price": 4
    }
  ],
  "quantity_uses": -1,
  "first_name": "Anita",
  "start_date": "2021-06-18 17:00:00",
  "currency": "MXN",
  "shipping_items": [
    {
      "name": "Express Shipping",
      "amount": 1,
      "carrier": "OWN"
    }
  ],
  "end_date": null,
  "discounts": []
});

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("PUT", "https://sandbox.ecartpay.com/api/templates/65a864a93df1d9cacf436c5a");
xhr.setRequestHeader("Authorization", "<your_merchant_token>");
xhr.setRequestHeader("Content-Type", "application/json");
// WARNING: Cookies will be stripped away by the browser before sending the request.
xhr.setRequestHeader("Cookie", "lang=en");

xhr.send(data);
CURL *curl;
CURLcode res;
curl = curl_easy_init();
if(curl) {
  curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "PUT");
  curl_easy_setopt(curl, CURLOPT_URL, "https://sandbox.ecartpay.com/api/templates/65a864a93df1d9cacf436c5a");
  curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
  curl_easy_setopt(curl, CURLOPT_DEFAULT_PROTOCOL, "https");
  struct curl_slist *headers = NULL;
  headers = curl_slist_append(headers, "Authorization: <your_merchant_token>");
  headers = curl_slist_append(headers, "Content-Type: application/json");
  headers = curl_slist_append(headers, "Cookie: lang=en");
  curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
  const char *data = "{\r\n    \"shipping_address\": {\r\n        \"first_name\": \"Juana\",\r\n        \"last_name\": \"Perez\",\r\n        \"address1\": \"Padros de la Capilla\",\r\n        \"address2\": \"Gladiolas\",\r\n        \"country\": {\r\n            \"code\": \"MX\",\r\n            \"name\": \"Mexico\"\r\n        },\r\n        \"state\": {\r\n            \"code\": \"TB\"\r\n        },\r\n        \"city\": \"Monterrey\",\r\n        \"postal_code\": \"64000\",\r\n        \"phone\": \"1111111111\",\r\n        \"reference\": \"reference\"\r\n    },\r\n    \"items\": [\r\n        {\r\n            \"discount\": 0,\r\n            \"tax\": 0,\r\n            \"name\": \"Collar oro BZ3909\",\r\n            \"quantity\": 3,\r\n            \"price\": 4\r\n        }\r\n    ],\r\n    \"quantity_uses\": -1,\r\n    \"first_name\": \"Anita\",\r\n    \"start_date\": \"2021-06-18 17:00:00\",\r\n    \"currency\": \"MXN\",\r\n    \"shipping_items\": [\r\n        {\r\n            \"name\": \"Express Shipping\",\r\n            \"amount\": 1,\r\n            \"carrier\": \"OWN\"\r\n        }\r\n    ],\r\n    \"end_date\": null,\r\n    \"discounts\": []\r\n}";
  curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);
  res = curl_easy_perform(curl);
  curl_slist_free_all(headers);
}
curl_easy_cleanup(curl);
// Axios

const axios = require('axios');
let data = JSON.stringify({
  "shipping_address": {
    "first_name": "Juana",
    "last_name": "Perez",
    "address1": "Padros de la Capilla",
    "address2": "Gladiolas",
    "country": {
      "code": "MX",
      "name": "Mexico"
    },
    "state": {
      "code": "TB"
    },
    "city": "Monterrey",
    "postal_code": "64000",
    "phone": "1111111111",
    "reference": "reference"
  },
  "items": [
    {
      "discount": 0,
      "tax": 0,
      "name": "Collar oro BZ3909",
      "quantity": 3,
      "price": 4
    }
  ],
  "quantity_uses": -1,
  "first_name": "Anita",
  "start_date": "2021-06-18 17:00:00",
  "currency": "MXN",
  "shipping_items": [
    {
      "name": "Express Shipping",
      "amount": 1,
      "carrier": "OWN"
    }
  ],
  "end_date": null,
  "discounts": []
});

let config = {
  method: 'put',
  maxBodyLength: Infinity,
  url: 'https://sandbox.ecartpay.com/api/templates/65a864a93df1d9cacf436c5a',
  headers: { 
    'Authorization': '<your_merchant_token>', 
    'Content-Type': 'application/json', 
    'Cookie': 'lang=en'
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

// -------------------------------------------------------------

// Native

var https = require('follow-redirects').https;
var fs = require('fs');

var options = {
  'method': 'PUT',
  'hostname': 'sandbox.ecartpay.com',
  'path': '/api/templates/65a864a93df1d9cacf436c5a',
  'headers': {
    'Authorization': '<your_merchant_token>',
    'Content-Type': 'application/json',
    'Cookie': 'lang=en'
  },
  'maxRedirects': 20
};

var req = https.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function (chunk) {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });

  res.on("error", function (error) {
    console.error(error);
  });
});

var postData = JSON.stringify({
  "shipping_address": {
    "first_name": "Juana",
    "last_name": "Perez",
    "address1": "Padros de la Capilla",
    "address2": "Gladiolas",
    "country": {
      "code": "MX",
      "name": "Mexico"
    },
    "state": {
      "code": "TB"
    },
    "city": "Monterrey",
    "postal_code": "64000",
    "phone": "1111111111",
    "reference": "reference"
  },
  "items": [
    {
      "discount": 0,
      "tax": 0,
      "name": "Collar oro BZ3909",
      "quantity": 3,
      "price": 4
    }
  ],
  "quantity_uses": -1,
  "first_name": "Anita",
  "start_date": "2021-06-18 17:00:00",
  "currency": "MXN",
  "shipping_items": [
    {
      "name": "Express Shipping",
      "amount": 1,
      "carrier": "OWN"
    }
  ],
  "end_date": null,
  "discounts": []
});

req.write(postData);

req.end();

// -------------------------------------------------------------

// Request

var request = require('request');
var options = {
  'method': 'PUT',
  'url': 'https://sandbox.ecartpay.com/api/templates/65a864a93df1d9cacf436c5a',
  'headers': {
    'Authorization': '<your_merchant_token>',
    'Content-Type': 'application/json',
    'Cookie': 'lang=en'
  },
  body: JSON.stringify({
    "shipping_address": {
      "first_name": "Juana",
      "last_name": "Perez",
      "address1": "Padros de la Capilla",
      "address2": "Gladiolas",
      "country": {
        "code": "MX",
        "name": "Mexico"
      },
      "state": {
        "code": "TB"
      },
      "city": "Monterrey",
      "postal_code": "64000",
      "phone": "1111111111",
      "reference": "reference"
    },
    "items": [
      {
        "discount": 0,
        "tax": 0,
        "name": "Collar oro BZ3909",
        "quantity": 3,
        "price": 4
      }
    ],
    "quantity_uses": -1,
    "first_name": "Anita",
    "start_date": "2021-06-18 17:00:00",
    "currency": "MXN",
    "shipping_items": [
      {
        "name": "Express Shipping",
        "amount": 1,
        "carrier": "OWN"
      }
    ],
    "end_date": null,
    "discounts": []
  })

};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

// -------------------------------------------------------------

// Unirest

var unirest = require('unirest');
var req = unirest('PUT', 'https://sandbox.ecartpay.com/api/templates/65a864a93df1d9cacf436c5a')
  .headers({
    'Authorization': '<your_merchant_token>',
    'Content-Type': 'application/json',
    'Cookie': 'lang=en'
  })
  .send(JSON.stringify({
    "shipping_address": {
      "first_name": "Juana",
      "last_name": "Perez",
      "address1": "Padros de la Capilla",
      "address2": "Gladiolas",
      "country": {
        "code": "MX",
        "name": "Mexico"
      },
      "state": {
        "code": "TB"
      },
      "city": "Monterrey",
      "postal_code": "64000",
      "phone": "1111111111",
      "reference": "reference"
    },
    "items": [
      {
        "discount": 0,
        "tax": 0,
        "name": "Collar oro BZ3909",
        "quantity": 3,
        "price": 4
      }
    ],
    "quantity_uses": -1,
    "first_name": "Anita",
    "start_date": "2021-06-18 17:00:00",
    "currency": "MXN",
    "shipping_items": [
      {
        "name": "Express Shipping",
        "amount": 1,
        "carrier": "OWN"
      }
    ],
    "end_date": null,
    "discounts": []
  }))
  .end(function (res) { 
    if (res.error) throw new Error(res.error); 
    console.log(res.raw_body);
  });
#import <Foundation/Foundation.h>

dispatch_semaphore_t sema = dispatch_semaphore_create(0);

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://sandbox.ecartpay.com/api/templates/65a864a93df1d9cacf436c5a"]
  cachePolicy:NSURLRequestUseProtocolCachePolicy
  timeoutInterval:10.0];
NSDictionary *headers = @{
  @"Authorization": @"<your_merchant_token>",
  @"Content-Type": @"application/json",
  @"Cookie": @"lang=en"
};

[request setAllHTTPHeaderFields:headers];
NSData *postData = [[NSData alloc] initWithData:[@"{\r\n    \"shipping_address\": {\r\n        \"first_name\": \"Juana\",\r\n        \"last_name\": \"Perez\",\r\n        \"address1\": \"Padros de la Capilla\",\r\n        \"address2\": \"Gladiolas\",\r\n        \"country\": {\r\n            \"code\": \"MX\",\r\n            \"name\": \"Mexico\"\r\n        },\r\n        \"state\": {\r\n            \"code\": \"TB\"\r\n        },\r\n        \"city\": \"Monterrey\",\r\n        \"postal_code\": \"64000\",\r\n        \"phone\": \"1111111111\",\r\n        \"reference\": \"reference\"\r\n    },\r\n    \"items\": [\r\n        {\r\n            \"discount\": 0,\r\n            \"tax\": 0,\r\n            \"name\": \"Collar oro BZ3909\",\r\n            \"quantity\": 3,\r\n            \"price\": 4\r\n        }\r\n    ],\r\n    \"quantity_uses\": -1,\r\n    \"first_name\": \"Anita\",\r\n    \"start_date\": \"2021-06-18 17:00:00\",\r\n    \"currency\": \"MXN\",\r\n    \"shipping_items\": [\r\n        {\r\n            \"name\": \"Express Shipping\",\r\n            \"amount\": 1,\r\n            \"carrier\": \"OWN\"\r\n        }\r\n    ],\r\n    \"end_date\": null,\r\n    \"discounts\": []\r\n}" dataUsingEncoding:NSUTF8StringEncoding]];
[request setHTTPBody:postData];

[request setHTTPMethod:@"PUT"];

NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
  if (error) {
    NSLog(@"%@", error);
    dispatch_semaphore_signal(sema);
  } else {
    NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
    NSError *parseError = nil;
    NSDictionary *responseDictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:&parseError];
    NSLog(@"%@",responseDictionary);
    dispatch_semaphore_signal(sema);
  }
}];
[dataTask resume];
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);
open Lwt
open Cohttp
open Cohttp_lwt_unix

let postData = ref "{\r\n    \"shipping_address\": {\r\n        \"first_name\": \"Juana\",\r\n        \"last_name\": \"Perez\",\r\n        \"address1\": \"Padros de la Capilla\",\r\n        \"address2\": \"Gladiolas\",\r\n        \"country\": {\r\n            \"code\": \"MX\",\r\n            \"name\": \"Mexico\"\r\n        },\r\n        \"state\": {\r\n            \"code\": \"TB\"\r\n        },\r\n        \"city\": \"Monterrey\",\r\n        \"postal_code\": \"64000\",\r\n        \"phone\": \"1111111111\",\r\n        \"reference\": \"reference\"\r\n    },\r\n    \"items\": [\r\n        {\r\n            \"discount\": 0,\r\n            \"tax\": 0,\r\n            \"name\": \"Collar oro BZ3909\",\r\n            \"quantity\": 3,\r\n            \"price\": 4\r\n        }\r\n    ],\r\n    \"quantity_uses\": -1,\r\n    \"first_name\": \"Anita\",\r\n    \"start_date\": \"2021-06-18 17:00:00\",\r\n    \"currency\": \"MXN\",\r\n    \"shipping_items\": [\r\n        {\r\n            \"name\": \"Express Shipping\",\r\n            \"amount\": 1,\r\n            \"carrier\": \"OWN\"\r\n        }\r\n    ],\r\n    \"end_date\": null,\r\n    \"discounts\": []\r\n}";;

let reqBody = 
  let uri = Uri.of_string "https://sandbox.ecartpay.com/api/templates/65a864a93df1d9cacf436c5a" in
  let headers = Header.init ()
    |> fun h -> Header.add h "Authorization" "<your_merchant_token>"
    |> fun h -> Header.add h "Content-Type" "application/json"
    |> fun h -> Header.add h "Cookie" "lang=en"
  in
  let body = Cohttp_lwt.Body.of_string !postData in

  Client.call ~headers ~body `PUT uri >>= fun (_resp, body) ->
  body |> Cohttp_lwt.Body.to_string >|= fun body -> body

let () =
  let respBody = Lwt_main.run reqBody in
  print_endline (respBody)
// cURL

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://sandbox.ecartpay.com/api/templates/65a864a93df1d9cacf436c5a',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'PUT',
  CURLOPT_POSTFIELDS =>'{
    "shipping_address": {
        "first_name": "Juana",
        "last_name": "Perez",
        "address1": "Padros de la Capilla",
        "address2": "Gladiolas",
        "country": {
            "code": "MX",
            "name": "Mexico"
        },
        "state": {
            "code": "TB"
        },
        "city": "Monterrey",
        "postal_code": "64000",
        "phone": "1111111111",
        "reference": "reference"
    },
    "items": [
        {
            "discount": 0,
            "tax": 0,
            "name": "Collar oro BZ3909",
            "quantity": 3,
            "price": 4
        }
    ],
    "quantity_uses": -1,
    "first_name": "Anita",
    "start_date": "2021-06-18 17:00:00",
    "currency": "MXN",
    "shipping_items": [
        {
            "name": "Express Shipping",
            "amount": 1,
            "carrier": "OWN"
        }
    ],
    "end_date": null,
    "discounts": []
}',
  CURLOPT_HTTPHEADER => array(
    'Authorization: <your_merchant_token>',
    'Content-Type: application/json',
    'Cookie: lang=en'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

// -------------------------------------------------------------

// Guzzle

<?php
$client = new Client();
$headers = [
  'Authorization' => '<your_merchant_token>',
  'Content-Type' => 'application/json',
  'Cookie' => 'lang=en'
];
$body = '{
  "shipping_address": {
    "first_name": "Juana",
    "last_name": "Perez",
    "address1": "Padros de la Capilla",
    "address2": "Gladiolas",
    "country": {
      "code": "MX",
      "name": "Mexico"
    },
    "state": {
      "code": "TB"
    },
    "city": "Monterrey",
    "postal_code": "64000",
    "phone": "1111111111",
    "reference": "reference"
  },
  "items": [
    {
      "discount": 0,
      "tax": 0,
      "name": "Collar oro BZ3909",
      "quantity": 3,
      "price": 4
    }
  ],
  "quantity_uses": -1,
  "first_name": "Anita",
  "start_date": "2021-06-18 17:00:00",
  "currency": "MXN",
  "shipping_items": [
    {
      "name": "Express Shipping",
      "amount": 1,
      "carrier": "OWN"
    }
  ],
  "end_date": null,
  "discounts": []
}';
$request = new Request('PUT', 'https://sandbox.ecartpay.com/api/templates/65a864a93df1d9cacf436c5a', $headers, $body);
$res = $client->sendAsync($request)->wait();
echo $res->getBody();

// -------------------------------------------------------------

// HTTP_Request2

<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('https://sandbox.ecartpay.com/api/templates/65a864a93df1d9cacf436c5a');
$request->setMethod(HTTP_Request2::METHOD_PUT);
$request->setConfig(array(
  'follow_redirects' => TRUE
));
$request->setHeader(array(
  'Authorization' => '<your_merchant_token>',
  'Content-Type' => 'application/json',
  'Cookie' => 'lang=en'
));
$request->setBody('{
\n    "shipping_address": {
\n        "first_name": "Juana",
\n        "last_name": "Perez",
\n        "address1": "Padros de la Capilla",
\n        "address2": "Gladiolas",
\n        "country": {
\n            "code": "MX",
\n            "name": "Mexico"
\n        },
\n        "state": {
\n            "code": "TB"
\n        },
\n        "city": "Monterrey",
\n        "postal_code": "64000",
\n        "phone": "1111111111",
\n        "reference": "reference"
\n    },
\n    "items": [
\n        {
\n            "discount": 0,
\n            "tax": 0,
\n            "name": "Collar oro BZ3909",
\n            "quantity": 3,
\n            "price": 4
\n        }
\n    ],
\n    "quantity_uses": -1,
\n    "first_name": "Anita",
\n    "start_date": "2021-06-18 17:00:00",
\n    "currency": "MXN",
\n    "shipping_items": [
\n        {
\n            "name": "Express Shipping",
\n            "amount": 1,
\n            "carrier": "OWN"
\n        }
\n    ],
\n    "end_date": null,
\n    "discounts": []
\n}');
try {
  $response = $request->send();
  if ($response->getStatus() == 200) {
    echo $response->getBody();
  }
  else {
    echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
    $response->getReasonPhrase();
  }
}
catch(HTTP_Request2_Exception $e) {
  echo 'Error: ' . $e->getMessage();
}

// -------------------------------------------------------------

// pecl_http

<?php
$client = new http\Client;
$request = new http\Client\Request;
$request->setRequestUrl('https://sandbox.ecartpay.com/api/templates/65a864a93df1d9cacf436c5a');
$request->setRequestMethod('PUT');
$body = new http\Message\Body;
$body->append('{
    "shipping_address": {
        "first_name": "Juana",
        "last_name": "Perez",
        "address1": "Padros de la Capilla",
        "address2": "Gladiolas",
        "country": {
            "code": "MX",
            "name": "Mexico"
        },
        "state": {
            "code": "TB"
        },
        "city": "Monterrey",
        "postal_code": "64000",
        "phone": "1111111111",
        "reference": "reference"
    },
    "items": [
        {
            "discount": 0,
            "tax": 0,
            "name": "Collar oro BZ3909",
            "quantity": 3,
            "price": 4
        }
    ],
    "quantity_uses": -1,
    "first_name": "Anita",
    "start_date": "2021-06-18 17:00:00",
    "currency": "MXN",
    "shipping_items": [
        {
            "name": "Express Shipping",
            "amount": 1,
            "carrier": "OWN"
        }
    ],
    "end_date": null,
    "discounts": []
}');
$request->setBody($body);
$request->setOptions(array());
$request->setHeaders(array(
  'Authorization' => '<your_merchant_token>',
  'Content-Type' => 'application/json',
  'Cookie' => 'lang=en'
));
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Authorization", "<your_merchant_token>")
$headers.Add("Content-Type", "application/json")
$headers.Add("Cookie", "lang=en")

$body = @"
{
    `"shipping_address`": {
        `"first_name`": `"Juana`",
        `"last_name`": `"Perez`",
        `"address1`": `"Padros de la Capilla`",
        `"address2`": `"Gladiolas`",
        `"country`": {
            `"code`": `"MX`",
            `"name`": `"Mexico`"
        },
        `"state`": {
            `"code`": `"TB`"
        },
        `"city`": `"Monterrey`",
        `"postal_code`": `"64000`",
        `"phone`": `"1111111111`",
        `"reference`": `"reference`"
    },
    `"items`": [
        {
            `"discount`": 0,
            `"tax`": 0,
            `"name`": `"Collar oro BZ3909`",
            `"quantity`": 3,
            `"price`": 4
        }
    ],
    `"quantity_uses`": -1,
    `"first_name`": `"Anita`",
    `"start_date`": `"2021-06-18 17:00:00`",
    `"currency`": `"MXN`",
    `"shipping_items`": [
        {
            `"name`": `"Express Shipping`",
            `"amount`": 1,
            `"carrier`": `"OWN`"
        }
    ],
    `"end_date`": null,
    `"discounts`": []
}
"@

$response = Invoke-RestMethod 'https://sandbox.ecartpay.com/api/templates/65a864a93df1d9cacf436c5a' -Method 'PUT' -Headers $headers -Body $body
$response | ConvertTo-Json
# http.client

import http.client
import json

conn = http.client.HTTPSConnection("sandbox.ecartpay.com")
payload = json.dumps({
  "shipping_address": {
    "first_name": "Juana",
    "last_name": "Perez",
    "address1": "Padros de la Capilla",
    "address2": "Gladiolas",
    "country": {
      "code": "MX",
      "name": "Mexico"
    },
    "state": {
      "code": "TB"
    },
    "city": "Monterrey",
    "postal_code": "64000",
    "phone": "1111111111",
    "reference": "reference"
  },
  "items": [
    {
      "discount": 0,
      "tax": 0,
      "name": "Collar oro BZ3909",
      "quantity": 3,
      "price": 4
    }
  ],
  "quantity_uses": -1,
  "first_name": "Anita",
  "start_date": "2021-06-18 17:00:00",
  "currency": "MXN",
  "shipping_items": [
    {
      "name": "Express Shipping",
      "amount": 1,
      "carrier": "OWN"
    }
  ],
  "end_date": None,
  "discounts": []
})
headers = {
  'Authorization': '<your_merchant_token>',
  'Content-Type': 'application/json',
  'Cookie': 'lang=en'
}
conn.request("PUT", "/api/templates/65a864a93df1d9cacf436c5a", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

// -------------------------------------------------------------

# Requests

import requests
import json

url = "https://sandbox.ecartpay.com/api/templates/65a864a93df1d9cacf436c5a"

payload = json.dumps({
  "shipping_address": {
    "first_name": "Juana",
    "last_name": "Perez",
    "address1": "Padros de la Capilla",
    "address2": "Gladiolas",
    "country": {
      "code": "MX",
      "name": "Mexico"
    },
    "state": {
      "code": "TB"
    },
    "city": "Monterrey",
    "postal_code": "64000",
    "phone": "1111111111",
    "reference": "reference"
  },
  "items": [
    {
      "discount": 0,
      "tax": 0,
      "name": "Collar oro BZ3909",
      "quantity": 3,
      "price": 4
    }
  ],
  "quantity_uses": -1,
  "first_name": "Anita",
  "start_date": "2021-06-18 17:00:00",
  "currency": "MXN",
  "shipping_items": [
    {
      "name": "Express Shipping",
      "amount": 1,
      "carrier": "OWN"
    }
  ],
  "end_date": None,
  "discounts": []
})
headers = {
  'Authorization': '<your_merchant_token>',
  'Content-Type': 'application/json',
  'Cookie': 'lang=en'
}

response = requests.request("PUT", url, headers=headers, data=payload)

print(response.text)
# httr

library(httr)

headers = c(
  'Authorization' = '<your_merchant_token>',
  'Content-Type' = 'application/json',
  'Cookie' = 'lang=en'
)

body = '{
  "shipping_address": {
    "first_name": "Juana",
    "last_name": "Perez",
    "address1": "Padros de la Capilla",
    "address2": "Gladiolas",
    "country": {
      "code": "MX",
      "name": "Mexico"
    },
    "state": {
      "code": "TB"
    },
    "city": "Monterrey",
    "postal_code": "64000",
    "phone": "1111111111",
    "reference": "reference"
  },
  "items": [
    {
      "discount": 0,
      "tax": 0,
      "name": "Collar oro BZ3909",
      "quantity": 3,
      "price": 4
    }
  ],
  "quantity_uses": -1,
  "first_name": "Anita",
  "start_date": "2021-06-18 17:00:00",
  "currency": "MXN",
  "shipping_items": [
    {
      "name": "Express Shipping",
      "amount": 1,
      "carrier": "OWN"
    }
  ],
  "end_date": null,
  "discounts": []
}';

res <- VERB("PUT", url = "https://sandbox.ecartpay.com/api/templates/65a864a93df1d9cacf436c5a", body = body, add_headers(headers))

cat(content(res, 'text'))

// -------------------------------------------------------------

# RCurl

library(RCurl)
headers = c(
  "Authorization" = "<your_merchant_token>",
  "Content-Type" = "application/json",
  "Cookie" = "lang=en"
)
params = "{
  \"shipping_address\": {
    \"first_name\": \"Juana\",
    \"last_name\": \"Perez\",
    \"address1\": \"Padros de la Capilla\",
    \"address2\": \"Gladiolas\",
    \"country\": {
      \"code\": \"MX\",
      \"name\": \"Mexico\"
    },
    \"state\": {
      \"code\": \"TB\"
    },
    \"city\": \"Monterrey\",
    \"postal_code\": \"64000\",
    \"phone\": \"1111111111\",
    \"reference\": \"reference\"
  },
  \"items\": [
    {
      \"discount\": 0,
      \"tax\": 0,
      \"name\": \"Collar oro BZ3909\",
      \"quantity\": 3,
      \"price\": 4
    }
  ],
  \"quantity_uses\": -1,
  \"first_name\": \"Anita\",
  \"start_date\": \"2021-06-18 17:00:00\",
  \"currency\": \"MXN\",
  \"shipping_items\": [
    {
      \"name\": \"Express Shipping\",
      \"amount\": 1,
      \"carrier\": \"OWN\"
    }
  ],
  \"end_date\": null,
  \"discounts\": []
}"
res <- httpPUT("https://sandbox.ecartpay.com/api/templates/65a864a93df1d9cacf436c5a", params, httpheader = headers, followlocation = TRUE)
cat(res)
require "uri"
require "json"
require "net/http"

url = URI("https://sandbox.ecartpay.com/api/templates/65a864a93df1d9cacf436c5a")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Put.new(url)
request["Authorization"] = "<your_merchant_token>"
request["Content-Type"] = "application/json"
request["Cookie"] = "lang=en"
request.body = JSON.dump({
  "shipping_address": {
    "first_name": "Juana",
    "last_name": "Perez",
    "address1": "Padros de la Capilla",
    "address2": "Gladiolas",
    "country": {
      "code": "MX",
      "name": "Mexico"
    },
    "state": {
      "code": "TB"
    },
    "city": "Monterrey",
    "postal_code": "64000",
    "phone": "1111111111",
    "reference": "reference"
  },
  "items": [
    {
      "discount": 0,
      "tax": 0,
      "name": "Collar oro BZ3909",
      "quantity": 3,
      "price": 4
    }
  ],
  "quantity_uses": -1,
  "first_name": "Anita",
  "start_date": "2021-06-18 17:00:00",
  "currency": "MXN",
  "shipping_items": [
    {
      "name": "Express Shipping",
      "amount": 1,
      "carrier": "OWN"
    }
  ],
  "end_date": "__RUBY\#%0NULL__",
  "discounts": []
})

response = https.request(request)
puts response.read_body
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = reqwest::Client::builder()
        .build()?;

    let mut headers = reqwest::header::HeaderMap::new();
    headers.insert("Authorization", "<your_merchant_token>".parse()?);
    headers.insert("Content-Type", "application/json".parse()?);
    headers.insert("Cookie", "lang=en".parse()?);

    let data = r#"{
    "shipping_address": {
        "first_name": "Juana",
        "last_name": "Perez",
        "address1": "Padros de la Capilla",
        "address2": "Gladiolas",
        "country": {
            "code": "MX",
            "name": "Mexico"
        },
        "state": {
            "code": "TB"
        },
        "city": "Monterrey",
        "postal_code": "64000",
        "phone": "1111111111",
        "reference": "reference"
    },
    "items": [
        {
            "discount": 0,
            "tax": 0,
            "name": "Collar oro BZ3909",
            "quantity": 3,
            "price": 4
        }
    ],
    "quantity_uses": -1,
    "first_name": "Anita",
    "start_date": "2021-06-18 17:00:00",
    "currency": "MXN",
    "shipping_items": [
        {
            "name": "Express Shipping",
            "amount": 1,
            "carrier": "OWN"
        }
    ],
    "end_date": null,
    "discounts": []
}"#;

    let json: serde_json::Value = serde_json::from_str(&data)?;

    let request = client.request(reqwest::Method::PUT, "https://sandbox.ecartpay.com/api/templates/65a864a93df1d9cacf436c5a")
        .headers(headers)
        .json(&json);

    let response = request.send().await?;
    let body = response.text().await?;

    println!("{}", body);

    Ok(())
}
# Httpie

printf '{
    "shipping_address": {
        "first_name": "Juana",
        "last_name": "Perez",
        "address1": "Padros de la Capilla",
        "address2": "Gladiolas",
        "country": {
            "code": "MX",
            "name": "Mexico"
        },
        "state": {
            "code": "TB"
        },
        "city": "Monterrey",
        "postal_code": "64000",
        "phone": "1111111111",
        "reference": "reference"
    },
    "items": [
        {
            "discount": 0,
            "tax": 0,
            "name": "Collar oro BZ3909",
            "quantity": 3,
            "price": 4
        }
    ],
    "quantity_uses": -1,
    "first_name": "Anita",
    "start_date": "2021-06-18 17:00:00",
    "currency": "MXN",
    "shipping_items": [
        {
            "name": "Express Shipping",
            "amount": 1,
            "carrier": "OWN"
        }
    ],
    "end_date": null,
    "discounts": []
}'| http  --follow --timeout 3600 PUT 'https://sandbox.ecartpay.com/api/templates/65a864a93df1d9cacf436c5a' \
 Authorization:'<your_merchant_token>' \
 Content-Type:'application/json' \
 Cookie:'lang=en'
 
// -------------------------------------------------------------

# wget

wget --no-check-certificate --quiet \
  --method PUT \
  --timeout=0 \
  --header 'Authorization: <your_merchant_token>' \
  --header 'Content-Type: application/json' \
  --header 'Cookie: lang=en' \
  --body-data '{
    "shipping_address": {
        "first_name": "Juana",
        "last_name": "Perez",
        "address1": "Padros de la Capilla",
        "address2": "Gladiolas",
        "country": {
            "code": "MX",
            "name": "Mexico"
        },
        "state": {
            "code": "TB"
        },
        "city": "Monterrey",
        "postal_code": "64000",
        "phone": "1111111111",
        "reference": "reference"
    },
    "items": [
        {
            "discount": 0,
            "tax": 0,
            "name": "Collar oro BZ3909",
            "quantity": 3,
            "price": 4
        }
    ],
    "quantity_uses": -1,
    "first_name": "Anita",
    "start_date": "2021-06-18 17:00:00",
    "currency": "MXN",
    "shipping_items": [
        {
            "name": "Express Shipping",
            "amount": 1,
            "carrier": "OWN"
        }
    ],
    "end_date": null,
    "discounts": []
}' \
   'https://sandbox.ecartpay.com/api/templates/65a864a93df1d9cacf436c5a'
let parameters = "{\r\n    \"shipping_address\": {\r\n        \"first_name\": \"Juana\",\r\n        \"last_name\": \"Perez\",\r\n        \"address1\": \"Padros de la Capilla\",\r\n        \"address2\": \"Gladiolas\",\r\n        \"country\": {\r\n            \"code\": \"MX\",\r\n            \"name\": \"Mexico\"\r\n        },\r\n        \"state\": {\r\n            \"code\": \"TB\"\r\n        },\r\n        \"city\": \"Monterrey\",\r\n        \"postal_code\": \"64000\",\r\n        \"phone\": \"1111111111\",\r\n        \"reference\": \"reference\"\r\n    },\r\n    \"items\": [\r\n        {\r\n            \"discount\": 0,\r\n            \"tax\": 0,\r\n            \"name\": \"Collar oro BZ3909\",\r\n            \"quantity\": 3,\r\n            \"price\": 4\r\n        }\r\n    ],\r\n    \"quantity_uses\": -1,\r\n    \"first_name\": \"Anita\",\r\n    \"start_date\": \"2021-06-18 17:00:00\",\r\n    \"currency\": \"MXN\",\r\n    \"shipping_items\": [\r\n        {\r\n            \"name\": \"Express Shipping\",\r\n            \"amount\": 1,\r\n            \"carrier\": \"OWN\"\r\n        }\r\n    ],\r\n    \"end_date\": null,\r\n    \"discounts\": []\r\n}"
let postData = parameters.data(using: .utf8)

var request = URLRequest(url: URL(string: "https://sandbox.ecartpay.com/api/templates/65a864a93df1d9cacf436c5a")!,timeoutInterval: Double.infinity)
request.addValue("<your_merchant_token>", forHTTPHeaderField: "Authorization")
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
request.addValue("lang=en", forHTTPHeaderField: "Cookie")

request.httpMethod = "PUT"
request.httpBody = postData

let task = URLSession.shared.dataTask(with: request) { data, response, error in 
  guard let data = data else {
    print(String(describing: error))
    return
  }
  print(String(data: data, encoding: .utf8)!)
}

task.resume()

Response

❗️

This request does not return a response body. A successful update is indicated by a 200 OK status code.

Image 1. Updating a Payment Link

Image 1. Updating a Payment Link


Update Payment Link Status

This endpoint is used to update the status of a specific template, such as marking it as "accepted" for business purposes.

💻

Visit our API Reference to test this endpoint.

Endpoints

  • POST https://ecartpay.com/api/webhooks/verification
  • POST https://sandbox.ecartpay.com/api/webhooks/verification (Sandbox only)

Headers

  • Authorization: {token}
  • Content-Type: application/json

Examples

Request Body

Here is an example of the structure to use when updating a payment link status:

{
  "id": "68dab82eff8f016d8e168971",
  "status": "accepted",
  "type": "business"
}

Request

curl --request POST \
     --url https://sandbox.ecartpay.com/api/webhooks/verification \
     --header 'Authorization: <your_merchant_token>' \
     --header 'content-type: application/json' \
     --data '
{
  "id": "68dab82eff8f016d8e168971",
  "status": "accepted",
  "type": "business"
}
'
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io"
)

func main() {

  url := "https://sandbox.ecartpay.com/api/webhooks/verification"
  method := "POST"

  payload := strings.NewReader(`{`+"
"+`
   "id": "6584803a0369e3f50c08e234",`+"
"+`
   "type": "business",`+"
"+`
   "status": "accepted"`+"
"+`
}`)

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("Authorization", "<your_merchant_token>")
  req.Header.Add("Content-Type", "application/json")
  req.Header.Add("Cookie", "lang=en")

  res, err := client.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()

  body, err := io.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}
POST /api/webhooks/verification HTTP/1.1
Host: sandbox.ecartpay.com
Authorization: <your_merchant_token>
Content-Type: application/json
Cookie: lang=en
Content-Length: 91

{
   "id": "6584803a0369e3f50c08e234",
   "type": "business",
   "status": "accepted"
}
// OkHttp

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n   \"id\": \"6584803a0369e3f50c08e234\",\r\n   \"type\": \"business\",\r\n   \"status\": \"accepted\"\r\n}");
Request request = new Request.Builder()
  .url("https://sandbox.ecartpay.com/api/webhooks/verification")
  .method("POST", body)
  .addHeader("Authorization", "<your_merchant_token>")
  .addHeader("Content-Type", "application/json")
  .addHeader("Cookie", "lang=en")
  .build();
Response response = client.newCall(request).execute();

// -------------------------------------------------------------

// Unirest

Unirest.setTimeouts(0, 0);
HttpResponse<String> response = Unirest.post("https://sandbox.ecartpay.com/api/webhooks/verification")
  .header("Authorization", "<your_merchant_token>")
  .header("Content-Type", "application/json")
  .header("Cookie", "lang=en")
  .body("{\r\n   \"id\": \"6584803a0369e3f50c08e234\",\r\n   \"type\": \"business\",\r\n   \"status\": \"accepted\"\r\n}")
  .asString();
// Fetch

const myHeaders = new Headers();
myHeaders.append("Authorization", "<your_merchant_token>");
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Cookie", "lang=en");

const raw = JSON.stringify({
  "id": "6584803a0369e3f50c08e234",
  "type": "business",
  "status": "accepted"
});

const requestOptions = {
  method: "POST",
  headers: myHeaders,
  body: raw,
  redirect: "follow"
};

fetch("https://sandbox.ecartpay.com/api/webhooks/verification", requestOptions)
  .then((response) => response.text())
  .then((result) => console.log(result))
  .catch((error) => console.error(error));

// -------------------------------------------------------------

// jQuery

var settings = {
  "url": "https://sandbox.ecartpay.com/api/webhooks/verification",
  "method": "POST",
  "timeout": 0,
  "headers": {
    "Authorization": "<your_merchant_token>",
    "Content-Type": "application/json",
    "Cookie": "lang=en"
  },
  "data": JSON.stringify({
    "id": "6584803a0369e3f50c08e234",
    "type": "business",
    "status": "accepted"
  }),
};

$.ajax(settings).done(function (response) {
  console.log(response);
});

// -------------------------------------------------------------

// XHR

// WARNING: For POST requests, body is set to null by browsers.
var data = JSON.stringify({
  "id": "6584803a0369e3f50c08e234",
  "type": "business",
  "status": "accepted"
});

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "https://sandbox.ecartpay.com/api/webhooks/verification");
xhr.setRequestHeader("Authorization", "<your_merchant_token>");
xhr.setRequestHeader("Content-Type", "application/json");
// WARNING: Cookies will be stripped away by the browser before sending the request.
xhr.setRequestHeader("Cookie", "lang=en");

xhr.send(data);
CURL *curl;
CURLcode res;
curl = curl_easy_init();
if(curl) {
  curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");
  curl_easy_setopt(curl, CURLOPT_URL, "https://sandbox.ecartpay.com/api/webhooks/verification");
  curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
  curl_easy_setopt(curl, CURLOPT_DEFAULT_PROTOCOL, "https");
  struct curl_slist *headers = NULL;
  headers = curl_slist_append(headers, "Authorization: <your_merchant_token>");
  headers = curl_slist_append(headers, "Content-Type: application/json");
  headers = curl_slist_append(headers, "Cookie: lang=en");
  curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
  const char *data = "{\r\n   \"id\": \"6584803a0369e3f50c08e234\",\r\n   \"type\": \"business\",\r\n   \"status\": \"accepted\"\r\n}";
  curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);
  res = curl_easy_perform(curl);
  curl_slist_free_all(headers);
}
curl_easy_cleanup(curl);
// Axios

const axios = require('axios');
let data = JSON.stringify({
  "id": "6584803a0369e3f50c08e234",
  "type": "business",
  "status": "accepted"
});

let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://sandbox.ecartpay.com/api/webhooks/verification',
  headers: { 
    'Authorization': '<your_merchant_token>', 
    'Content-Type': 'application/json', 
    'Cookie': 'lang=en'
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

// -------------------------------------------------------------

// Native

var https = require('follow-redirects').https;
var fs = require('fs');

var options = {
  'method': 'POST',
  'hostname': 'sandbox.ecartpay.com',
  'path': '/api/webhooks/verification',
  'headers': {
    'Authorization': '<your_merchant_token>',
    'Content-Type': 'application/json',
    'Cookie': 'lang=en'
  },
  'maxRedirects': 20
};

var req = https.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function (chunk) {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });

  res.on("error", function (error) {
    console.error(error);
  });
});

var postData = JSON.stringify({
  "id": "6584803a0369e3f50c08e234",
  "type": "business",
  "status": "accepted"
});

req.write(postData);

req.end();

// -------------------------------------------------------------

// Request

var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://sandbox.ecartpay.com/api/webhooks/verification',
  'headers': {
    'Authorization': '<your_merchant_token>',
    'Content-Type': 'application/json',
    'Cookie': 'lang=en'
  },
  body: JSON.stringify({
    "id": "6584803a0369e3f50c08e234",
    "type": "business",
    "status": "accepted"
  })

};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

// -------------------------------------------------------------

// Unirest

var unirest = require('unirest');
var req = unirest('POST', 'https://sandbox.ecartpay.com/api/webhooks/verification')
  .headers({
    'Authorization': '<your_merchant_token>',
    'Content-Type': 'application/json',
    'Cookie': 'lang=en'
  })
  .send(JSON.stringify({
    "id": "6584803a0369e3f50c08e234",
    "type": "business",
    "status": "accepted"
  }))
  .end(function (res) { 
    if (res.error) throw new Error(res.error); 
    console.log(res.raw_body);
  });
#import <Foundation/Foundation.h>

dispatch_semaphore_t sema = dispatch_semaphore_create(0);

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://sandbox.ecartpay.com/api/webhooks/verification"]
  cachePolicy:NSURLRequestUseProtocolCachePolicy
  timeoutInterval:10.0];
NSDictionary *headers = @{
  @"Authorization": @"<your_merchant_token>",
  @"Content-Type": @"application/json",
  @"Cookie": @"lang=en"
};

[request setAllHTTPHeaderFields:headers];
NSData *postData = [[NSData alloc] initWithData:[@"{\r\n   \"id\": \"6584803a0369e3f50c08e234\",\r\n   \"type\": \"business\",\r\n   \"status\": \"accepted\"\r\n}" dataUsingEncoding:NSUTF8StringEncoding]];
[request setHTTPBody:postData];

[request setHTTPMethod:@"POST"];

NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
  if (error) {
    NSLog(@"%@", error);
    dispatch_semaphore_signal(sema);
  } else {
    NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
    NSError *parseError = nil;
    NSDictionary *responseDictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:&parseError];
    NSLog(@"%@",responseDictionary);
    dispatch_semaphore_signal(sema);
  }
}];
[dataTask resume];
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);
open Lwt
open Cohttp
open Cohttp_lwt_unix

let postData = ref "{\r\n   \"id\": \"6584803a0369e3f50c08e234\",\r\n   \"type\": \"business\",\r\n   \"status\": \"accepted\"\r\n}";;

let reqBody = 
  let uri = Uri.of_string "https://sandbox.ecartpay.com/api/webhooks/verification" in
  let headers = Header.init ()
    |> fun h -> Header.add h "Authorization" "<your_merchant_token>"
    |> fun h -> Header.add h "Content-Type" "application/json"
    |> fun h -> Header.add h "Cookie" "lang=en"
  in
  let body = Cohttp_lwt.Body.of_string !postData in

  Client.call ~headers ~body `POST uri >>= fun (_resp, body) ->
  body |> Cohttp_lwt.Body.to_string >|= fun body -> body

let () =
  let respBody = Lwt_main.run reqBody in
  print_endline (respBody)
// cURL

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://sandbox.ecartpay.com/api/webhooks/verification',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
   "id": "6584803a0369e3f50c08e234",
   "type": "business",
   "status": "accepted"
}',
  CURLOPT_HTTPHEADER => array(
    'Authorization: <your_merchant_token>',
    'Content-Type: application/json',
    'Cookie: lang=en'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

// -------------------------------------------------------------

// Guzzle

<?php
$client = new Client();
$headers = [
  'Authorization' => '<your_merchant_token>',
  'Content-Type' => 'application/json',
  'Cookie' => 'lang=en'
];
$body = '{
  "id": "6584803a0369e3f50c08e234",
  "type": "business",
  "status": "accepted"
}';
$request = new Request('POST', 'https://sandbox.ecartpay.com/api/webhooks/verification', $headers, $body);
$res = $client->sendAsync($request)->wait();
echo $res->getBody();

// -------------------------------------------------------------

// HTTP_Request2

<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('https://sandbox.ecartpay.com/api/webhooks/verification');
$request->setMethod(HTTP_Request2::METHOD_POST);
$request->setConfig(array(
  'follow_redirects' => TRUE
));
$request->setHeader(array(
  'Authorization' => '<your_merchant_token>',
  'Content-Type' => 'application/json',
  'Cookie' => 'lang=en'
));
$request->setBody('{
\n   "id": "6584803a0369e3f50c08e234",
\n   "type": "business",
\n   "status": "accepted"
\n}');
try {
  $response = $request->send();
  if ($response->getStatus() == 200) {
    echo $response->getBody();
  }
  else {
    echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
    $response->getReasonPhrase();
  }
}
catch(HTTP_Request2_Exception $e) {
  echo 'Error: ' . $e->getMessage();
}

// -------------------------------------------------------------

// pecl_http

<?php
$client = new http\Client;
$request = new http\Client\Request;
$request->setRequestUrl('https://sandbox.ecartpay.com/api/webhooks/verification');
$request->setRequestMethod('POST');
$body = new http\Message\Body;
$body->append('{
   "id": "6584803a0369e3f50c08e234",
   "type": "business",
   "status": "accepted"
}');
$request->setBody($body);
$request->setOptions(array());
$request->setHeaders(array(
  'Authorization' => '<your_merchant_token>',
  'Content-Type' => 'application/json',
  'Cookie' => 'lang=en'
));
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Authorization", "<your_merchant_token>")
$headers.Add("Content-Type", "application/json")
$headers.Add("Cookie", "lang=en")

$body = @"
{
   `"id`": `"6584803a0369e3f50c08e234`",
   `"type`": `"business`",
   `"status`": `"accepted`"
}
"@

$response = Invoke-RestMethod 'https://sandbox.ecartpay.com/api/webhooks/verification' -Method 'POST' -Headers $headers -Body $body
$response | ConvertTo-Json
# http.client

import http.client
import json

conn = http.client.HTTPSConnection("sandbox.ecartpay.com")
payload = json.dumps({
  "id": "6584803a0369e3f50c08e234",
  "type": "business",
  "status": "accepted"
})
headers = {
  'Authorization': '<your_merchant_token>',
  'Content-Type': 'application/json',
  'Cookie': 'lang=en'
}
conn.request("POST", "/api/webhooks/verification", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

// -------------------------------------------------------------

# Requests

import requests
import json

url = "https://sandbox.ecartpay.com/api/webhooks/verification"

payload = json.dumps({
  "id": "6584803a0369e3f50c08e234",
  "type": "business",
  "status": "accepted"
})
headers = {
  'Authorization': '<your_merchant_token>',
  'Content-Type': 'application/json',
  'Cookie': 'lang=en'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)
# httr

library(httr)

headers = c(
  'Authorization' = '<your_merchant_token>',
  'Content-Type' = 'application/json',
  'Cookie' = 'lang=en'
)

body = '{
  "id": "6584803a0369e3f50c08e234",
  "type": "business",
  "status": "accepted"
}';

res <- VERB("POST", url = "https://sandbox.ecartpay.com/api/webhooks/verification", body = body, add_headers(headers))

cat(content(res, 'text'))

// -------------------------------------------------------------

# RCurl

library(RCurl)
headers = c(
  "Authorization" = "<your_merchant_token>",
  "Content-Type" = "application/json",
  "Cookie" = "lang=en"
)
params = "{
  \"id\": \"6584803a0369e3f50c08e234\",
  \"type\": \"business\",
  \"status\": \"accepted\"
}"
res <- postForm("https://sandbox.ecartpay.com/api/webhooks/verification", .opts=list(postfields = params, httpheader = headers, followlocation = TRUE), style = "httppost")
cat(res)
require "uri"
require "json"
require "net/http"

url = URI("https://sandbox.ecartpay.com/api/webhooks/verification")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = "<your_merchant_token>"
request["Content-Type"] = "application/json"
request["Cookie"] = "lang=en"
request.body = JSON.dump({
  "id": "6584803a0369e3f50c08e234",
  "type": "business",
  "status": "accepted"
})

response = https.request(request)
puts response.read_body
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = reqwest::Client::builder()
        .build()?;

    let mut headers = reqwest::header::HeaderMap::new();
    headers.insert("Authorization", "<your_merchant_token>".parse()?);
    headers.insert("Content-Type", "application/json".parse()?);
    headers.insert("Cookie", "lang=en".parse()?);

    let data = r#"{
    "id": "6584803a0369e3f50c08e234",
    "type": "business",
    "status": "accepted"
}"#;

    let json: serde_json::Value = serde_json::from_str(&data)?;

    let request = client.request(reqwest::Method::POST, "https://sandbox.ecartpay.com/api/webhooks/verification")
        .headers(headers)
        .json(&json);

    let response = request.send().await?;
    let body = response.text().await?;

    println!("{}", body);

    Ok(())
}
# Httpie

printf '{
   "id": "6584803a0369e3f50c08e234",
   "type": "business",
   "status": "accepted"
}'| http  --follow --timeout 3600 POST 'https://sandbox.ecartpay.com/api/webhooks/verification' \
 Authorization:'<your_merchant_token>' \
 Content-Type:'application/json' \
 Cookie:'lang=en'
 
// -------------------------------------------------------------

# wget

wget --no-check-certificate --quiet \
  --method POST \
  --timeout=0 \
  --header 'Authorization: <your_merchant_token>' \
  --header 'Content-Type: application/json' \
  --header 'Cookie: lang=en' \
  --body-data '{
   "id": "6584803a0369e3f50c08e234",
   "type": "business",
   "status": "accepted"
}' \
   'https://sandbox.ecartpay.com/api/webhooks/verification'
let parameters = "{\r\n   \"id\": \"6584803a0369e3f50c08e234\",\r\n   \"type\": \"business\",\r\n   \"status\": \"accepted\"\r\n}"
let postData = parameters.data(using: .utf8)

var request = URLRequest(url: URL(string: "https://sandbox.ecartpay.com/api/webhooks/verification")!,timeoutInterval: Double.infinity)
request.addValue("<your_merchant_token>", forHTTPHeaderField: "Authorization")
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
request.addValue("lang=en", forHTTPHeaderField: "Cookie")

request.httpMethod = "POST"
request.httpBody = postData

let task = URLSession.shared.dataTask(with: request) { data, response, error in 
  guard let data = data else {
    print(String(describing: error))
    return
  }
  print(String(data: data, encoding: .utf8)!)
}

task.resume()

Response

This request does not return a response body. A successful update is indicated by a 200 OK status code.

{
  "success":true
}

With the ability to update payment links, Ecart Pay provides flexibility and control, ensuring your payment processes remain up-to-date and tailored to your business needs.


Delete Payment Link Template

Ecart Pay allows you to delete payment link templates when they are no longer needed.

💻

Visit our API Reference to test this endpoint.

Endpoints

  • DELETE https://ecartpay.com/api/templates/{{id}}
  • DELETE https://sandbox.ecartpay.com/api/templates/{{id}} (Sandbox only)

Headers

  • Authorization: {token}

Path Parameters

  • id: The id of the payment link template to delete.

Examples

Request

curl --location --request DELETE 'https://sandbox.ecartpay.com/api/templates/65a864a93df1d9cacf436c5a' \
--header 'Authorization: <your_merchant_token>' \
--header 'Cookie: lang=en'
package main

import (
  "fmt"
  "net/http"
  "io"
)

func main() {

  url := "https://sandbox.ecartpay.com/api/templates/65a864a93df1d9cacf436c5a"
  method := "DELETE"

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, nil)

  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("Authorization", "<your_merchant_token>")
  req.Header.Add("Cookie", "lang=en")

  res, err := client.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()

  body, err := io.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}
DELETE /api/templates/65a864a93df1d9cacf436c5a HTTP/1.1
Host: sandbox.ecartpay.com
Authorization: <your_merchant_token>
Cookie: lang=en
// OkHttp

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = RequestBody.create(mediaType, "");
Request request = new Request.Builder()
  .url("https://sandbox.ecartpay.com/api/templates/65a864a93df1d9cacf436c5a")
  .method("DELETE", body)
  .addHeader("Authorization", "<your_merchant_token>")
  .addHeader("Cookie", "lang=en")
  .build();
Response response = client.newCall(request).execute();

// -------------------------------------------------------------

// Unirest

Unirest.setTimeouts(0, 0);
HttpResponse<String> response = Unirest.delete("https://sandbox.ecartpay.com/api/templates/65a864a93df1d9cacf436c5a")
  .header("Authorization", "<your_merchant_token>")
  .header("Cookie", "lang=en")
  .asString();
// Fetch

const myHeaders = new Headers();
myHeaders.append("Authorization", "<your_merchant_token>");
myHeaders.append("Cookie", "lang=en");

const requestOptions = {
  method: "DELETE",
  headers: myHeaders,
  redirect: "follow"
};

fetch("https://sandbox.ecartpay.com/api/templates/65a864a93df1d9cacf436c5a", requestOptions)
  .then((response) => response.text())
  .then((result) => console.log(result))
  .catch((error) => console.error(error));

// -------------------------------------------------------------

// jQuery

var settings = {
  "url": "https://sandbox.ecartpay.com/api/templates/65a864a93df1d9cacf436c5a",
  "method": "DELETE",
  "timeout": 0,
  "headers": {
    "Authorization": "<your_merchant_token>",
    "Cookie": "lang=en"
  },
};

$.ajax(settings).done(function (response) {
  console.log(response);
});

// -------------------------------------------------------------

// XHR

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("DELETE", "https://sandbox.ecartpay.com/api/templates/65a864a93df1d9cacf436c5a");
xhr.setRequestHeader("Authorization", "<your_merchant_token>");
// WARNING: Cookies will be stripped away by the browser before sending the request.
xhr.setRequestHeader("Cookie", "lang=en");

xhr.send();
CURL *curl;
CURLcode res;
curl = curl_easy_init();
if(curl) {
  curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "DELETE");
  curl_easy_setopt(curl, CURLOPT_URL, "https://sandbox.ecartpay.com/api/templates/65a864a93df1d9cacf436c5a");
  curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
  curl_easy_setopt(curl, CURLOPT_DEFAULT_PROTOCOL, "https");
  struct curl_slist *headers = NULL;
  headers = curl_slist_append(headers, "Authorization: <your_merchant_token>");
  headers = curl_slist_append(headers, "Cookie: lang=en");
  curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
  res = curl_easy_perform(curl);
  curl_slist_free_all(headers);
}
curl_easy_cleanup(curl);
// Axios

const axios = require('axios');

let config = {
  method: 'delete',
  maxBodyLength: Infinity,
  url: 'https://sandbox.ecartpay.com/api/templates/65a864a93df1d9cacf436c5a',
  headers: { 
    'Authorization': '<your_merchant_token>', 
    'Cookie': 'lang=en'
  }
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

// -------------------------------------------------------------

// Native

var https = require('follow-redirects').https;
var fs = require('fs');

var options = {
  'method': 'DELETE',
  'hostname': 'sandbox.ecartpay.com',
  'path': '/api/templates/65a864a93df1d9cacf436c5a',
  'headers': {
    'Authorization': '<your_merchant_token>',
    'Cookie': 'lang=en'
  },
  'maxRedirects': 20
};

var req = https.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function (chunk) {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });

  res.on("error", function (error) {
    console.error(error);
  });
});

req.end();

// -------------------------------------------------------------

// Request

var request = require('request');
var options = {
  'method': 'DELETE',
  'url': 'https://sandbox.ecartpay.com/api/templates/65a864a93df1d9cacf436c5a',
  'headers': {
    'Authorization': '<your_merchant_token>',
    'Cookie': 'lang=en'
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

// -------------------------------------------------------------

// Unirest

var unirest = require('unirest');
var req = unirest('DELETE', 'https://sandbox.ecartpay.com/api/templates/65a864a93df1d9cacf436c5a')
  .headers({
    'Authorization': '<your_merchant_token>',
    'Cookie': 'lang=en'
  })
  .end(function (res) { 
    if (res.error) throw new Error(res.error); 
    console.log(res.raw_body);
  });
#import <Foundation/Foundation.h>

dispatch_semaphore_t sema = dispatch_semaphore_create(0);

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://sandbox.ecartpay.com/api/templates/65a864a93df1d9cacf436c5a"]
  cachePolicy:NSURLRequestUseProtocolCachePolicy
  timeoutInterval:10.0];
NSDictionary *headers = @{
  @"Authorization": @"<your_merchant_token>",
  @"Cookie": @"lang=en"
};

[request setAllHTTPHeaderFields:headers];

[request setHTTPMethod:@"DELETE"];

NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
  if (error) {
    NSLog(@"%@", error);
    dispatch_semaphore_signal(sema);
  } else {
    NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
    NSError *parseError = nil;
    NSDictionary *responseDictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:&parseError];
    NSLog(@"%@",responseDictionary);
    dispatch_semaphore_signal(sema);
  }
}];
[dataTask resume];
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);
open Lwt
open Cohttp
open Cohttp_lwt_unix

let reqBody = 
  let uri = Uri.of_string "https://sandbox.ecartpay.com/api/templates/65a864a93df1d9cacf436c5a" in
  let headers = Header.init ()
    |> fun h -> Header.add h "Authorization" "<your_merchant_token>"
    |> fun h -> Header.add h "Cookie" "lang=en"
  in
  Client.call ~headers `DELETE uri >>= fun (_resp, body) ->
  body |> Cohttp_lwt.Body.to_string >|= fun body -> body

let () =
  let respBody = Lwt_main.run reqBody in
  print_endline (respBody)
// cURL

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://sandbox.ecartpay.com/api/templates/65a864a93df1d9cacf436c5a',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'DELETE',
  CURLOPT_HTTPHEADER => array(
    'Authorization: <your_merchant_token>',
    'Cookie: lang=en'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

// -------------------------------------------------------------

// Guzzle

<?php
$client = new Client();
$headers = [
  'Authorization' => '<your_merchant_token>',
  'Cookie' => 'lang=en'
];
$request = new Request('DELETE', 'https://sandbox.ecartpay.com/api/templates/65a864a93df1d9cacf436c5a', $headers);
$res = $client->sendAsync($request)->wait();
echo $res->getBody();

// -------------------------------------------------------------

// HTTP_Request2

<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('https://sandbox.ecartpay.com/api/templates/65a864a93df1d9cacf436c5a');
$request->setMethod(HTTP_Request2::METHOD_DELETE);
$request->setConfig(array(
  'follow_redirects' => TRUE
));
$request->setHeader(array(
  'Authorization' => '<your_merchant_token>',
  'Cookie' => 'lang=en'
));
try {
  $response = $request->send();
  if ($response->getStatus() == 200) {
    echo $response->getBody();
  }
  else {
    echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
    $response->getReasonPhrase();
  }
}
catch(HTTP_Request2_Exception $e) {
  echo 'Error: ' . $e->getMessage();
}

// -------------------------------------------------------------

// pecl_http

<?php
$client = new http\Client;
$request = new http\Client\Request;
$request->setRequestUrl('https://sandbox.ecartpay.com/api/templates/65a864a93df1d9cacf436c5a');
$request->setRequestMethod('DELETE');
$request->setOptions(array());
$request->setHeaders(array(
  'Authorization' => '<your_merchant_token>',
  'Cookie' => 'lang=en'
));
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Authorization", "<your_merchant_token>")
$headers.Add("Cookie", "lang=en")

$response = Invoke-RestMethod 'https://sandbox.ecartpay.com/api/templates/65a864a93df1d9cacf436c5a' -Method 'DELETE' -Headers $headers
$response | ConvertTo-Json
# http.client

import http.client

conn = http.client.HTTPSConnection("sandbox.ecartpay.com")
payload = ''
headers = {
  'Authorization': '<your_merchant_token>',
  'Cookie': 'lang=en'
}
conn.request("DELETE", "/api/templates/65a864a93df1d9cacf436c5a", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

// -------------------------------------------------------------

# Requests

import requests

url = "https://sandbox.ecartpay.com/api/templates/65a864a93df1d9cacf436c5a"

payload = {}
headers = {
  'Authorization': '<your_merchant_token>',
  'Cookie': 'lang=en'
}

response = requests.request("DELETE", url, headers=headers, data=payload)

print(response.text)
# httr

library(httr)

headers = c(
  'Authorization' = '<your_merchant_token>',
  'Cookie' = 'lang=en'
)

res <- VERB("DELETE", url = "https://sandbox.ecartpay.com/api/templates/65a864a93df1d9cacf436c5a", add_headers(headers))

cat(content(res, 'text'))

// -------------------------------------------------------------

# RCurl

library(RCurl)
headers = c(
  "Authorization" = "<your_merchant_token>",
  "Cookie" = "lang=en"
)
res <- httpDELETE("https://sandbox.ecartpay.com/api/templates/65a864a93df1d9cacf436c5a", httpheader = headers, followlocation = TRUE)
cat(res)
require "uri"
require "net/http"

url = URI("https://sandbox.ecartpay.com/api/templates/65a864a93df1d9cacf436c5a")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Delete.new(url)
request["Authorization"] = "<your_merchant_token>"
request["Cookie"] = "lang=en"

response = https.request(request)
puts response.read_body
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = reqwest::Client::builder()
        .build()?;

    let mut headers = reqwest::header::HeaderMap::new();
    headers.insert("Authorization", "<your_merchant_token>".parse()?);
    headers.insert("Cookie", "lang=en".parse()?);

    let request = client.request(reqwest::Method::DELETE, "https://sandbox.ecartpay.com/api/templates/65a864a93df1d9cacf436c5a")
        .headers(headers);

    let response = request.send().await?;
    let body = response.text().await?;

    println!("{}", body);

    Ok(())
}
# Httpie

http --follow --timeout 3600 DELETE 'https://sandbox.ecartpay.com/api/templates/65a864a93df1d9cacf436c5a' \
 Authorization:'<your_merchant_token>' \
 Cookie:'lang=en'
 
// -------------------------------------------------------------

# wget

wget --no-check-certificate --quiet \
  --method DELETE \
  --timeout=0 \
  --header 'Authorization: <your_merchant_token>' \
  --header 'Cookie: lang=en' \
   'https://sandbox.ecartpay.com/api/templates/65a864a93df1d9cacf436c5a'
var request = URLRequest(url: URL(string: "https://sandbox.ecartpay.com/api/templates/65a864a93df1d9cacf436c5a")!,timeoutInterval: Double.infinity)
request.addValue("<your_merchant_token>", forHTTPHeaderField: "Authorization")
request.addValue("lang=en", forHTTPHeaderField: "Cookie")

request.httpMethod = "DELETE"

let task = URLSession.shared.dataTask(with: request) { data, response, error in 
  guard let data = data else {
    print(String(describing: error))
    return
  }
  print(String(data: data, encoding: .utf8)!)
}

task.resume()

Response

This request does not return any response body. It only removes the corresponding Payment Link.

{
    "message": "Template removed successfully"
}
Image 1. Deleting a Payment Link

Image 2. Deleting a Payment Link


Did this page help you?