curl --request POST \
--url https://demo-api-harmony.compago.com/api/payment-method \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"billingInformation": {
"email": "maria.gonzalez@example.com",
"firstName": "María",
"lastName": "González",
"phoneNumber": "+5215512345678"
},
"externalId": "customer_12345",
"collectFunds": "NONE",
"verificationAmount": 1,
"amount": 1200,
"displayMode": "LINK",
"buttonText": "<string>",
"buttonColor": "<string>",
"redirectUrl": "https://yourstore.com/cards/saved",
"ttlMinutes": 2880
}
'import requests
url = "https://demo-api-harmony.compago.com/api/payment-method"
payload = {
"billingInformation": {
"email": "maria.gonzalez@example.com",
"firstName": "María",
"lastName": "González",
"phoneNumber": "+5215512345678"
},
"externalId": "customer_12345",
"collectFunds": "NONE",
"verificationAmount": 1,
"amount": 1200,
"displayMode": "LINK",
"buttonText": "<string>",
"buttonColor": "<string>",
"redirectUrl": "https://yourstore.com/cards/saved",
"ttlMinutes": 2880
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
billingInformation: {
email: 'maria.gonzalez@example.com',
firstName: 'María',
lastName: 'González',
phoneNumber: '+5215512345678'
},
externalId: 'customer_12345',
collectFunds: 'NONE',
verificationAmount: 1,
amount: 1200,
displayMode: 'LINK',
buttonText: '<string>',
buttonColor: '<string>',
redirectUrl: 'https://yourstore.com/cards/saved',
ttlMinutes: 2880
})
};
fetch('https://demo-api-harmony.compago.com/api/payment-method', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://demo-api-harmony.compago.com/api/payment-method",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'billingInformation' => [
'email' => 'maria.gonzalez@example.com',
'firstName' => 'María',
'lastName' => 'González',
'phoneNumber' => '+5215512345678'
],
'externalId' => 'customer_12345',
'collectFunds' => 'NONE',
'verificationAmount' => 1,
'amount' => 1200,
'displayMode' => 'LINK',
'buttonText' => '<string>',
'buttonColor' => '<string>',
'redirectUrl' => 'https://yourstore.com/cards/saved',
'ttlMinutes' => 2880
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://demo-api-harmony.compago.com/api/payment-method"
payload := strings.NewReader("{\n \"billingInformation\": {\n \"email\": \"maria.gonzalez@example.com\",\n \"firstName\": \"María\",\n \"lastName\": \"González\",\n \"phoneNumber\": \"+5215512345678\"\n },\n \"externalId\": \"customer_12345\",\n \"collectFunds\": \"NONE\",\n \"verificationAmount\": 1,\n \"amount\": 1200,\n \"displayMode\": \"LINK\",\n \"buttonText\": \"<string>\",\n \"buttonColor\": \"<string>\",\n \"redirectUrl\": \"https://yourstore.com/cards/saved\",\n \"ttlMinutes\": 2880\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://demo-api-harmony.compago.com/api/payment-method")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"billingInformation\": {\n \"email\": \"maria.gonzalez@example.com\",\n \"firstName\": \"María\",\n \"lastName\": \"González\",\n \"phoneNumber\": \"+5215512345678\"\n },\n \"externalId\": \"customer_12345\",\n \"collectFunds\": \"NONE\",\n \"verificationAmount\": 1,\n \"amount\": 1200,\n \"displayMode\": \"LINK\",\n \"buttonText\": \"<string>\",\n \"buttonColor\": \"<string>\",\n \"redirectUrl\": \"https://yourstore.com/cards/saved\",\n \"ttlMinutes\": 2880\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://demo-api-harmony.compago.com/api/payment-method")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"billingInformation\": {\n \"email\": \"maria.gonzalez@example.com\",\n \"firstName\": \"María\",\n \"lastName\": \"González\",\n \"phoneNumber\": \"+5215512345678\"\n },\n \"externalId\": \"customer_12345\",\n \"collectFunds\": \"NONE\",\n \"verificationAmount\": 1,\n \"amount\": 1200,\n \"displayMode\": \"LINK\",\n \"buttonText\": \"<string>\",\n \"buttonColor\": \"<string>\",\n \"redirectUrl\": \"https://yourstore.com/cards/saved\",\n \"ttlMinutes\": 2880\n}"
response = http.request(request)
puts response.read_body{
"id": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
"checkoutUrl": "<string>"
}Create
curl --request POST \
--url https://demo-api-harmony.compago.com/api/payment-method \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"billingInformation": {
"email": "maria.gonzalez@example.com",
"firstName": "María",
"lastName": "González",
"phoneNumber": "+5215512345678"
},
"externalId": "customer_12345",
"collectFunds": "NONE",
"verificationAmount": 1,
"amount": 1200,
"displayMode": "LINK",
"buttonText": "<string>",
"buttonColor": "<string>",
"redirectUrl": "https://yourstore.com/cards/saved",
"ttlMinutes": 2880
}
'import requests
url = "https://demo-api-harmony.compago.com/api/payment-method"
payload = {
"billingInformation": {
"email": "maria.gonzalez@example.com",
"firstName": "María",
"lastName": "González",
"phoneNumber": "+5215512345678"
},
"externalId": "customer_12345",
"collectFunds": "NONE",
"verificationAmount": 1,
"amount": 1200,
"displayMode": "LINK",
"buttonText": "<string>",
"buttonColor": "<string>",
"redirectUrl": "https://yourstore.com/cards/saved",
"ttlMinutes": 2880
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
billingInformation: {
email: 'maria.gonzalez@example.com',
firstName: 'María',
lastName: 'González',
phoneNumber: '+5215512345678'
},
externalId: 'customer_12345',
collectFunds: 'NONE',
verificationAmount: 1,
amount: 1200,
displayMode: 'LINK',
buttonText: '<string>',
buttonColor: '<string>',
redirectUrl: 'https://yourstore.com/cards/saved',
ttlMinutes: 2880
})
};
fetch('https://demo-api-harmony.compago.com/api/payment-method', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://demo-api-harmony.compago.com/api/payment-method",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'billingInformation' => [
'email' => 'maria.gonzalez@example.com',
'firstName' => 'María',
'lastName' => 'González',
'phoneNumber' => '+5215512345678'
],
'externalId' => 'customer_12345',
'collectFunds' => 'NONE',
'verificationAmount' => 1,
'amount' => 1200,
'displayMode' => 'LINK',
'buttonText' => '<string>',
'buttonColor' => '<string>',
'redirectUrl' => 'https://yourstore.com/cards/saved',
'ttlMinutes' => 2880
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://demo-api-harmony.compago.com/api/payment-method"
payload := strings.NewReader("{\n \"billingInformation\": {\n \"email\": \"maria.gonzalez@example.com\",\n \"firstName\": \"María\",\n \"lastName\": \"González\",\n \"phoneNumber\": \"+5215512345678\"\n },\n \"externalId\": \"customer_12345\",\n \"collectFunds\": \"NONE\",\n \"verificationAmount\": 1,\n \"amount\": 1200,\n \"displayMode\": \"LINK\",\n \"buttonText\": \"<string>\",\n \"buttonColor\": \"<string>\",\n \"redirectUrl\": \"https://yourstore.com/cards/saved\",\n \"ttlMinutes\": 2880\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://demo-api-harmony.compago.com/api/payment-method")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"billingInformation\": {\n \"email\": \"maria.gonzalez@example.com\",\n \"firstName\": \"María\",\n \"lastName\": \"González\",\n \"phoneNumber\": \"+5215512345678\"\n },\n \"externalId\": \"customer_12345\",\n \"collectFunds\": \"NONE\",\n \"verificationAmount\": 1,\n \"amount\": 1200,\n \"displayMode\": \"LINK\",\n \"buttonText\": \"<string>\",\n \"buttonColor\": \"<string>\",\n \"redirectUrl\": \"https://yourstore.com/cards/saved\",\n \"ttlMinutes\": 2880\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://demo-api-harmony.compago.com/api/payment-method")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"billingInformation\": {\n \"email\": \"maria.gonzalez@example.com\",\n \"firstName\": \"María\",\n \"lastName\": \"González\",\n \"phoneNumber\": \"+5215512345678\"\n },\n \"externalId\": \"customer_12345\",\n \"collectFunds\": \"NONE\",\n \"verificationAmount\": 1,\n \"amount\": 1200,\n \"displayMode\": \"LINK\",\n \"buttonText\": \"<string>\",\n \"buttonColor\": \"<string>\",\n \"redirectUrl\": \"https://yourstore.com/cards/saved\",\n \"ttlMinutes\": 2880\n}"
response = http.request(request)
puts response.read_body{
"id": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
"checkoutUrl": "<string>"
}Authorizations
Body
Request body for creating a payment method. The customer will be directed to the checkout URL to securely save their card. By default a small verification charge is placed and then voided to validate the card; collectFunds can instead charge or hold a real amount at that moment.
Billing information for the payment method
Show child attributes
Show child attributes
Optional external ID to track the payment method in your system.
"customer_12345"
What happens to the customer's money at checkout, on top of saving the card. NONE (the default) places the small verification charge and refunds it immediately, which is the historical behaviour. CHARGE keeps the money: a real sale, ending CONFIRMED. HOLD blocks the money without capturing it, ending HELD, to be captured or released later through the hold endpoints. All three modes are available to every organization.
NONE, CHARGE, HOLD "NONE"
Amount in MXN used for the verification charge. This charge is placed and then voided. Defaults to $1 MXN. Allowed ONLY when collectFunds is NONE, the only mode that gives the money back; sending it with CHARGE or HOLD is a 400 telling you to use amount instead.
x >= 0.011
The money that is actually charged (CHARGE) or held (HOLD) at checkout, in MXN. REQUIRED when collectFunds is CHARGE or HOLD, and rejected when collectFunds is NONE. Unlike verificationAmount, this money is not given back.
x >= 0.011200
How the checkout is displayed. LINK redirects the customer to a full-page checkout. EMBEDDED allows embedding in an iframe.
LINK, EMBEDDED Custom text for the checkout button (EMBEDDED mode only).
Custom hex color for the checkout button (EMBEDDED mode only).
URL where the customer is redirected after successfully saving their card. Compago appends id and externalId as query parameters.
"https://yourstore.com/cards/saved"
Time-to-live in minutes for the checkout link. Defaults to 2,880 minutes (48 hours).
x >= 12880