curl --request POST \
--url https://demo-api-harmony.compago.com/api/developer/v1/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,
"bankAccountId": "5b1d7c2e-8a34-4f6b-9c1d-0e2f3a4b5c61"
}
'import requests
url = "https://demo-api-harmony.compago.com/api/developer/v1/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,
"bankAccountId": "5b1d7c2e-8a34-4f6b-9c1d-0e2f3a4b5c61"
}
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,
bankAccountId: '5b1d7c2e-8a34-4f6b-9c1d-0e2f3a4b5c61'
})
};
fetch('https://demo-api-harmony.compago.com/api/developer/v1/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/developer/v1/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,
'bankAccountId' => '5b1d7c2e-8a34-4f6b-9c1d-0e2f3a4b5c61'
]),
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/developer/v1/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 \"bankAccountId\": \"5b1d7c2e-8a34-4f6b-9c1d-0e2f3a4b5c61\"\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/developer/v1/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 \"bankAccountId\": \"5b1d7c2e-8a34-4f6b-9c1d-0e2f3a4b5c61\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://demo-api-harmony.compago.com/api/developer/v1/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 \"bankAccountId\": \"5b1d7c2e-8a34-4f6b-9c1d-0e2f3a4b5c61\"\n}"
response = http.request(request)
puts response.read_body{
"id": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
"checkoutUrl": "<string>"
}{
"error": {
"code": "BANK_ACCOUNT_NOT_AVAILABLE",
"message": "That bank account cannot receive sales."
}
}Create
curl --request POST \
--url https://demo-api-harmony.compago.com/api/developer/v1/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,
"bankAccountId": "5b1d7c2e-8a34-4f6b-9c1d-0e2f3a4b5c61"
}
'import requests
url = "https://demo-api-harmony.compago.com/api/developer/v1/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,
"bankAccountId": "5b1d7c2e-8a34-4f6b-9c1d-0e2f3a4b5c61"
}
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,
bankAccountId: '5b1d7c2e-8a34-4f6b-9c1d-0e2f3a4b5c61'
})
};
fetch('https://demo-api-harmony.compago.com/api/developer/v1/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/developer/v1/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,
'bankAccountId' => '5b1d7c2e-8a34-4f6b-9c1d-0e2f3a4b5c61'
]),
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/developer/v1/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 \"bankAccountId\": \"5b1d7c2e-8a34-4f6b-9c1d-0e2f3a4b5c61\"\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/developer/v1/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 \"bankAccountId\": \"5b1d7c2e-8a34-4f6b-9c1d-0e2f3a4b5c61\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://demo-api-harmony.compago.com/api/developer/v1/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 \"bankAccountId\": \"5b1d7c2e-8a34-4f6b-9c1d-0e2f3a4b5c61\"\n}"
response = http.request(request)
puts response.read_body{
"id": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
"checkoutUrl": "<string>"
}{
"error": {
"code": "BANK_ACCOUNT_NOT_AVAILABLE",
"message": "That bank account cannot receive sales."
}
}Cuerpo
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.
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
Optional. The bank account that receives the money of this checkout's own charge or hold (collectFunds CHARGE or HOLD), for a business with more than one. It applies to that first charge only: later charges of the card send their own. It must be one of your verified accounts: list them with GET /developer/v1/bank-account. Omit it, or send null, and Compago applies your deposit rule. An id that is not one of your verified accounts fails with BANK_ACCOUNT_NOT_AVAILABLE and no checkout link is created.
"5b1d7c2e-8a34-4f6b-9c1d-0e2f3a4b5c61"