curl --request POST \
--url https://api.sandbox.cheqpay.mx/pos/payment-methods \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--header 'x-merchant-id: <api-key>' \
--data '
{
"type": "CARD",
"cardDetails": {
"cardNumber": "4111111111111111",
"cvc": "123",
"expMonth": 12,
"expYear": 25
},
"customerId": "123e4567-e89b-12d3-a456-426614174000",
"merchantId": "merchant_123",
"isDefault": false,
"nickname": "My Visa Card",
"billingFirstName": "John",
"billingLastName": "Doe",
"billingPhoneNumber": "+525512345678",
"billingEmail": "john.doe@example.com",
"billingAddressLine1": "123 Main St",
"billingAddressLine2": "Apt 4B",
"billingCity": "Mexico City",
"billingState": "CDMX",
"billingPostalCode": "12345",
"billingCountry": "MX",
"persist": true
}
'import requests
url = "https://api.sandbox.cheqpay.mx/pos/payment-methods"
payload = {
"type": "CARD",
"cardDetails": {
"cardNumber": "4111111111111111",
"cvc": "123",
"expMonth": 12,
"expYear": 25
},
"customerId": "123e4567-e89b-12d3-a456-426614174000",
"merchantId": "merchant_123",
"isDefault": False,
"nickname": "My Visa Card",
"billingFirstName": "John",
"billingLastName": "Doe",
"billingPhoneNumber": "+525512345678",
"billingEmail": "john.doe@example.com",
"billingAddressLine1": "123 Main St",
"billingAddressLine2": "Apt 4B",
"billingCity": "Mexico City",
"billingState": "CDMX",
"billingPostalCode": "12345",
"billingCountry": "MX",
"persist": True
}
headers = {
"x-api-key": "<api-key>",
"x-merchant-id": "<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>',
'x-merchant-id': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
type: 'CARD',
cardDetails: {cardNumber: '4111111111111111', cvc: '123', expMonth: 12, expYear: 25},
customerId: '123e4567-e89b-12d3-a456-426614174000',
merchantId: 'merchant_123',
isDefault: false,
nickname: 'My Visa Card',
billingFirstName: 'John',
billingLastName: 'Doe',
billingPhoneNumber: '+525512345678',
billingEmail: 'john.doe@example.com',
billingAddressLine1: '123 Main St',
billingAddressLine2: 'Apt 4B',
billingCity: 'Mexico City',
billingState: 'CDMX',
billingPostalCode: '12345',
billingCountry: 'MX',
persist: true
})
};
fetch('https://api.sandbox.cheqpay.mx/pos/payment-methods', 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://api.sandbox.cheqpay.mx/pos/payment-methods",
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([
'type' => 'CARD',
'cardDetails' => [
'cardNumber' => '4111111111111111',
'cvc' => '123',
'expMonth' => 12,
'expYear' => 25
],
'customerId' => '123e4567-e89b-12d3-a456-426614174000',
'merchantId' => 'merchant_123',
'isDefault' => false,
'nickname' => 'My Visa Card',
'billingFirstName' => 'John',
'billingLastName' => 'Doe',
'billingPhoneNumber' => '+525512345678',
'billingEmail' => 'john.doe@example.com',
'billingAddressLine1' => '123 Main St',
'billingAddressLine2' => 'Apt 4B',
'billingCity' => 'Mexico City',
'billingState' => 'CDMX',
'billingPostalCode' => '12345',
'billingCountry' => 'MX',
'persist' => true
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>",
"x-merchant-id: <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://api.sandbox.cheqpay.mx/pos/payment-methods"
payload := strings.NewReader("{\n \"type\": \"CARD\",\n \"cardDetails\": {\n \"cardNumber\": \"4111111111111111\",\n \"cvc\": \"123\",\n \"expMonth\": 12,\n \"expYear\": 25\n },\n \"customerId\": \"123e4567-e89b-12d3-a456-426614174000\",\n \"merchantId\": \"merchant_123\",\n \"isDefault\": false,\n \"nickname\": \"My Visa Card\",\n \"billingFirstName\": \"John\",\n \"billingLastName\": \"Doe\",\n \"billingPhoneNumber\": \"+525512345678\",\n \"billingEmail\": \"john.doe@example.com\",\n \"billingAddressLine1\": \"123 Main St\",\n \"billingAddressLine2\": \"Apt 4B\",\n \"billingCity\": \"Mexico City\",\n \"billingState\": \"CDMX\",\n \"billingPostalCode\": \"12345\",\n \"billingCountry\": \"MX\",\n \"persist\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("x-merchant-id", "<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://api.sandbox.cheqpay.mx/pos/payment-methods")
.header("x-api-key", "<api-key>")
.header("x-merchant-id", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"type\": \"CARD\",\n \"cardDetails\": {\n \"cardNumber\": \"4111111111111111\",\n \"cvc\": \"123\",\n \"expMonth\": 12,\n \"expYear\": 25\n },\n \"customerId\": \"123e4567-e89b-12d3-a456-426614174000\",\n \"merchantId\": \"merchant_123\",\n \"isDefault\": false,\n \"nickname\": \"My Visa Card\",\n \"billingFirstName\": \"John\",\n \"billingLastName\": \"Doe\",\n \"billingPhoneNumber\": \"+525512345678\",\n \"billingEmail\": \"john.doe@example.com\",\n \"billingAddressLine1\": \"123 Main St\",\n \"billingAddressLine2\": \"Apt 4B\",\n \"billingCity\": \"Mexico City\",\n \"billingState\": \"CDMX\",\n \"billingPostalCode\": \"12345\",\n \"billingCountry\": \"MX\",\n \"persist\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sandbox.cheqpay.mx/pos/payment-methods")
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["x-merchant-id"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"type\": \"CARD\",\n \"cardDetails\": {\n \"cardNumber\": \"4111111111111111\",\n \"cvc\": \"123\",\n \"expMonth\": 12,\n \"expYear\": 25\n },\n \"customerId\": \"123e4567-e89b-12d3-a456-426614174000\",\n \"merchantId\": \"merchant_123\",\n \"isDefault\": false,\n \"nickname\": \"My Visa Card\",\n \"billingFirstName\": \"John\",\n \"billingLastName\": \"Doe\",\n \"billingPhoneNumber\": \"+525512345678\",\n \"billingEmail\": \"john.doe@example.com\",\n \"billingAddressLine1\": \"123 Main St\",\n \"billingAddressLine2\": \"Apt 4B\",\n \"billingCity\": \"Mexico City\",\n \"billingState\": \"CDMX\",\n \"billingPostalCode\": \"12345\",\n \"billingCountry\": \"MX\",\n \"persist\": true\n}"
response = http.request(request)
puts response.read_body{
"id": "123e4567-e89b-12d3-a456-426614174000",
"type": "CARD",
"isDefault": false,
"createdAt": "2025-01-15T10:00:00.000Z",
"updatedAt": "2025-01-15T10:00:00.000Z",
"nickname": "My Visa Card",
"billingFirstName": "John",
"billingLastName": "Doe",
"billingPhoneNumber": "+525512345678",
"billingEmail": "john.doe@example.com",
"billingAddressLine1": "123 Main St",
"billingAddressLine2": "Apt 4B",
"billingCity": "Mexico City",
"billingState": "CDMX",
"billingPostalCode": "12345",
"billingCountry": "MX",
"cardDetails": {
"last4": "1111",
"bin": "411111",
"expMonth": 12,
"expYear": 25,
"type": "credit",
"brand": "VISA",
"country": "US",
"issuerBank": "Chase Bank"
}
}{
"message": "Validation failed",
"errors": [
{
"field": "name",
"message": "Required"
}
]
}{
"message": "Invalid api key"
}{
"message": "Merchant not found"
}{
"message": "Error message"
}Create a payment method
Creates a new payment method (currently only CARD type is supported). The payment method can be associated with a customer by providing customerId. If persist is true, customerId is required.
curl --request POST \
--url https://api.sandbox.cheqpay.mx/pos/payment-methods \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--header 'x-merchant-id: <api-key>' \
--data '
{
"type": "CARD",
"cardDetails": {
"cardNumber": "4111111111111111",
"cvc": "123",
"expMonth": 12,
"expYear": 25
},
"customerId": "123e4567-e89b-12d3-a456-426614174000",
"merchantId": "merchant_123",
"isDefault": false,
"nickname": "My Visa Card",
"billingFirstName": "John",
"billingLastName": "Doe",
"billingPhoneNumber": "+525512345678",
"billingEmail": "john.doe@example.com",
"billingAddressLine1": "123 Main St",
"billingAddressLine2": "Apt 4B",
"billingCity": "Mexico City",
"billingState": "CDMX",
"billingPostalCode": "12345",
"billingCountry": "MX",
"persist": true
}
'import requests
url = "https://api.sandbox.cheqpay.mx/pos/payment-methods"
payload = {
"type": "CARD",
"cardDetails": {
"cardNumber": "4111111111111111",
"cvc": "123",
"expMonth": 12,
"expYear": 25
},
"customerId": "123e4567-e89b-12d3-a456-426614174000",
"merchantId": "merchant_123",
"isDefault": False,
"nickname": "My Visa Card",
"billingFirstName": "John",
"billingLastName": "Doe",
"billingPhoneNumber": "+525512345678",
"billingEmail": "john.doe@example.com",
"billingAddressLine1": "123 Main St",
"billingAddressLine2": "Apt 4B",
"billingCity": "Mexico City",
"billingState": "CDMX",
"billingPostalCode": "12345",
"billingCountry": "MX",
"persist": True
}
headers = {
"x-api-key": "<api-key>",
"x-merchant-id": "<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>',
'x-merchant-id': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
type: 'CARD',
cardDetails: {cardNumber: '4111111111111111', cvc: '123', expMonth: 12, expYear: 25},
customerId: '123e4567-e89b-12d3-a456-426614174000',
merchantId: 'merchant_123',
isDefault: false,
nickname: 'My Visa Card',
billingFirstName: 'John',
billingLastName: 'Doe',
billingPhoneNumber: '+525512345678',
billingEmail: 'john.doe@example.com',
billingAddressLine1: '123 Main St',
billingAddressLine2: 'Apt 4B',
billingCity: 'Mexico City',
billingState: 'CDMX',
billingPostalCode: '12345',
billingCountry: 'MX',
persist: true
})
};
fetch('https://api.sandbox.cheqpay.mx/pos/payment-methods', 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://api.sandbox.cheqpay.mx/pos/payment-methods",
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([
'type' => 'CARD',
'cardDetails' => [
'cardNumber' => '4111111111111111',
'cvc' => '123',
'expMonth' => 12,
'expYear' => 25
],
'customerId' => '123e4567-e89b-12d3-a456-426614174000',
'merchantId' => 'merchant_123',
'isDefault' => false,
'nickname' => 'My Visa Card',
'billingFirstName' => 'John',
'billingLastName' => 'Doe',
'billingPhoneNumber' => '+525512345678',
'billingEmail' => 'john.doe@example.com',
'billingAddressLine1' => '123 Main St',
'billingAddressLine2' => 'Apt 4B',
'billingCity' => 'Mexico City',
'billingState' => 'CDMX',
'billingPostalCode' => '12345',
'billingCountry' => 'MX',
'persist' => true
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>",
"x-merchant-id: <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://api.sandbox.cheqpay.mx/pos/payment-methods"
payload := strings.NewReader("{\n \"type\": \"CARD\",\n \"cardDetails\": {\n \"cardNumber\": \"4111111111111111\",\n \"cvc\": \"123\",\n \"expMonth\": 12,\n \"expYear\": 25\n },\n \"customerId\": \"123e4567-e89b-12d3-a456-426614174000\",\n \"merchantId\": \"merchant_123\",\n \"isDefault\": false,\n \"nickname\": \"My Visa Card\",\n \"billingFirstName\": \"John\",\n \"billingLastName\": \"Doe\",\n \"billingPhoneNumber\": \"+525512345678\",\n \"billingEmail\": \"john.doe@example.com\",\n \"billingAddressLine1\": \"123 Main St\",\n \"billingAddressLine2\": \"Apt 4B\",\n \"billingCity\": \"Mexico City\",\n \"billingState\": \"CDMX\",\n \"billingPostalCode\": \"12345\",\n \"billingCountry\": \"MX\",\n \"persist\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("x-merchant-id", "<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://api.sandbox.cheqpay.mx/pos/payment-methods")
.header("x-api-key", "<api-key>")
.header("x-merchant-id", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"type\": \"CARD\",\n \"cardDetails\": {\n \"cardNumber\": \"4111111111111111\",\n \"cvc\": \"123\",\n \"expMonth\": 12,\n \"expYear\": 25\n },\n \"customerId\": \"123e4567-e89b-12d3-a456-426614174000\",\n \"merchantId\": \"merchant_123\",\n \"isDefault\": false,\n \"nickname\": \"My Visa Card\",\n \"billingFirstName\": \"John\",\n \"billingLastName\": \"Doe\",\n \"billingPhoneNumber\": \"+525512345678\",\n \"billingEmail\": \"john.doe@example.com\",\n \"billingAddressLine1\": \"123 Main St\",\n \"billingAddressLine2\": \"Apt 4B\",\n \"billingCity\": \"Mexico City\",\n \"billingState\": \"CDMX\",\n \"billingPostalCode\": \"12345\",\n \"billingCountry\": \"MX\",\n \"persist\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sandbox.cheqpay.mx/pos/payment-methods")
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["x-merchant-id"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"type\": \"CARD\",\n \"cardDetails\": {\n \"cardNumber\": \"4111111111111111\",\n \"cvc\": \"123\",\n \"expMonth\": 12,\n \"expYear\": 25\n },\n \"customerId\": \"123e4567-e89b-12d3-a456-426614174000\",\n \"merchantId\": \"merchant_123\",\n \"isDefault\": false,\n \"nickname\": \"My Visa Card\",\n \"billingFirstName\": \"John\",\n \"billingLastName\": \"Doe\",\n \"billingPhoneNumber\": \"+525512345678\",\n \"billingEmail\": \"john.doe@example.com\",\n \"billingAddressLine1\": \"123 Main St\",\n \"billingAddressLine2\": \"Apt 4B\",\n \"billingCity\": \"Mexico City\",\n \"billingState\": \"CDMX\",\n \"billingPostalCode\": \"12345\",\n \"billingCountry\": \"MX\",\n \"persist\": true\n}"
response = http.request(request)
puts response.read_body{
"id": "123e4567-e89b-12d3-a456-426614174000",
"type": "CARD",
"isDefault": false,
"createdAt": "2025-01-15T10:00:00.000Z",
"updatedAt": "2025-01-15T10:00:00.000Z",
"nickname": "My Visa Card",
"billingFirstName": "John",
"billingLastName": "Doe",
"billingPhoneNumber": "+525512345678",
"billingEmail": "john.doe@example.com",
"billingAddressLine1": "123 Main St",
"billingAddressLine2": "Apt 4B",
"billingCity": "Mexico City",
"billingState": "CDMX",
"billingPostalCode": "12345",
"billingCountry": "MX",
"cardDetails": {
"last4": "1111",
"bin": "411111",
"expMonth": 12,
"expYear": 25,
"type": "credit",
"brand": "VISA",
"country": "US",
"issuerBank": "Chase Bank"
}
}{
"message": "Validation failed",
"errors": [
{
"field": "name",
"message": "Required"
}
]
}{
"message": "Invalid api key"
}{
"message": "Merchant not found"
}{
"message": "Error message"
}Authorizations
API key for authentication (required)
Merchant ID for identifying the merchant (required)
Body
Payment method type (currently only CARD is supported)
CARD "CARD"
Show child attributes
Show child attributes
Customer ID to associate this payment method with
"123e4567-e89b-12d3-a456-426614174000"
Merchant ID (optional, defaults to global merchant ID)
"merchant_123"
Whether this is the default payment method for the customer
false
Optional nickname for the payment method
"My Visa Card"
Billing first name
"John"
Billing last name
"Doe"
Billing phone number
"+525512345678"
Billing email address
"john.doe@example.com"
Billing address line 1
"123 Main St"
Billing address line 2
"Apt 4B"
Billing city
"Mexico City"
Billing state
"CDMX"
Billing postal code
"12345"
Billing country code (2 characters)
2"MX"
Whether to persist the payment method (requires customerId if true)
true
Response
Payment method created successfully
Payment method ID
"123e4567-e89b-12d3-a456-426614174000"
Payment method type
"CARD"
Whether this is the default payment method
false
Creation timestamp
"2025-01-15T10:00:00.000Z"
Last update timestamp
"2025-01-15T10:00:00.000Z"
Payment method nickname
"My Visa Card"
Billing first name
"John"
Billing last name
"Doe"
Billing phone number
"+525512345678"
Billing email address
"john.doe@example.com"
Billing address line 1
"123 Main St"
Billing address line 2
"Apt 4B"
Billing city
"Mexico City"
Billing state
"CDMX"
Billing postal code
"12345"
Billing country code
"MX"
Show child attributes
Show child attributes