Attach Payment Method to Customer
curl --request POST \
--url https://sandbox.api.hixbe.com/payment/customers/{id}/payment_methods \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'Xerobi-Version: <xerobi-version>' \
--data '
{
"payment_method": "pm_card_123",
"set_default": true
}
'import requests
url = "https://sandbox.api.hixbe.com/payment/customers/{id}/payment_methods"
payload = {
"payment_method": "pm_card_123",
"set_default": True
}
headers = {
"Xerobi-Version": "<xerobi-version>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'Xerobi-Version': '<xerobi-version>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({payment_method: 'pm_card_123', set_default: true})
};
fetch('https://sandbox.api.hixbe.com/payment/customers/{id}/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://sandbox.api.hixbe.com/payment/customers/{id}/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([
'payment_method' => 'pm_card_123',
'set_default' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"Xerobi-Version: <xerobi-version>"
],
]);
$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://sandbox.api.hixbe.com/payment/customers/{id}/payment_methods"
payload := strings.NewReader("{\n \"payment_method\": \"pm_card_123\",\n \"set_default\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Xerobi-Version", "<xerobi-version>")
req.Header.Add("Authorization", "Bearer <token>")
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://sandbox.api.hixbe.com/payment/customers/{id}/payment_methods")
.header("Xerobi-Version", "<xerobi-version>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"payment_method\": \"pm_card_123\",\n \"set_default\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://sandbox.api.hixbe.com/payment/customers/{id}/payment_methods")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Xerobi-Version"] = '<xerobi-version>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"payment_method\": \"pm_card_123\",\n \"set_default\": true\n}"
response = http.request(request)
puts response.read_body{
"id": "cus_123",
"email": "[email protected]",
"name": "<string>",
"phone": "<string>",
"metadata": {},
"default_payment_method": "<string>",
"created_at": "2023-11-07T05:31:56Z"
}{
"error": {
"type": "<string>",
"code": "<string>",
"message": "<string>",
"param": "<string>",
"request_id": "<string>"
}
}Attach Payment Method to Customer
POST
/
customers
/
{id}
/
payment_methods
Attach Payment Method to Customer
curl --request POST \
--url https://sandbox.api.hixbe.com/payment/customers/{id}/payment_methods \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'Xerobi-Version: <xerobi-version>' \
--data '
{
"payment_method": "pm_card_123",
"set_default": true
}
'import requests
url = "https://sandbox.api.hixbe.com/payment/customers/{id}/payment_methods"
payload = {
"payment_method": "pm_card_123",
"set_default": True
}
headers = {
"Xerobi-Version": "<xerobi-version>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'Xerobi-Version': '<xerobi-version>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({payment_method: 'pm_card_123', set_default: true})
};
fetch('https://sandbox.api.hixbe.com/payment/customers/{id}/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://sandbox.api.hixbe.com/payment/customers/{id}/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([
'payment_method' => 'pm_card_123',
'set_default' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"Xerobi-Version: <xerobi-version>"
],
]);
$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://sandbox.api.hixbe.com/payment/customers/{id}/payment_methods"
payload := strings.NewReader("{\n \"payment_method\": \"pm_card_123\",\n \"set_default\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Xerobi-Version", "<xerobi-version>")
req.Header.Add("Authorization", "Bearer <token>")
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://sandbox.api.hixbe.com/payment/customers/{id}/payment_methods")
.header("Xerobi-Version", "<xerobi-version>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"payment_method\": \"pm_card_123\",\n \"set_default\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://sandbox.api.hixbe.com/payment/customers/{id}/payment_methods")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Xerobi-Version"] = '<xerobi-version>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"payment_method\": \"pm_card_123\",\n \"set_default\": true\n}"
response = http.request(request)
puts response.read_body{
"id": "cus_123",
"email": "[email protected]",
"name": "<string>",
"phone": "<string>",
"metadata": {},
"default_payment_method": "<string>",
"created_at": "2023-11-07T05:31:56Z"
}{
"error": {
"type": "<string>",
"code": "<string>",
"message": "<string>",
"param": "<string>",
"request_id": "<string>"
}
}Authorizations
Use your secret API key. Example: Authorization: Bearer sk_test_xxx
Headers
API version header. Use '2026-01-01' for the latest version.