Save a payment method to a customer
curl --request POST \
--url https://api.beta.suby.fi/v3/setup-intents \
--header 'Content-Type: application/json' \
--header 'X-Suby-Api-Key: <api-key>' \
--data '
{
"customerId": "cus_abc123",
"paymentMethod": {
"tokenizedInstrument": "<string>",
"isPreferred": false
},
"threedsSessionData": {}
}
'import requests
url = "https://api.beta.suby.fi/v3/setup-intents"
payload = {
"customerId": "cus_abc123",
"paymentMethod": {
"tokenizedInstrument": "<string>",
"isPreferred": False
},
"threedsSessionData": {}
}
headers = {
"X-Suby-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-Suby-Api-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
customerId: 'cus_abc123',
paymentMethod: {tokenizedInstrument: '<string>', isPreferred: false},
threedsSessionData: {}
})
};
fetch('https://api.beta.suby.fi/v3/setup-intents', 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.beta.suby.fi/v3/setup-intents",
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([
'customerId' => 'cus_abc123',
'paymentMethod' => [
'tokenizedInstrument' => '<string>',
'isPreferred' => false
],
'threedsSessionData' => [
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-Suby-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://api.beta.suby.fi/v3/setup-intents"
payload := strings.NewReader("{\n \"customerId\": \"cus_abc123\",\n \"paymentMethod\": {\n \"tokenizedInstrument\": \"<string>\",\n \"isPreferred\": false\n },\n \"threedsSessionData\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Suby-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://api.beta.suby.fi/v3/setup-intents")
.header("X-Suby-Api-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"customerId\": \"cus_abc123\",\n \"paymentMethod\": {\n \"tokenizedInstrument\": \"<string>\",\n \"isPreferred\": false\n },\n \"threedsSessionData\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.beta.suby.fi/v3/setup-intents")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Suby-Api-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"customerId\": \"cus_abc123\",\n \"paymentMethod\": {\n \"tokenizedInstrument\": \"<string>\",\n \"isPreferred\": false\n },\n \"threedsSessionData\": {}\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"setupIntent": {
"id": "<string>",
"customerId": "<string>",
"paymentMethodId": "<string>",
"threeDsChallengeUrl": "<string>",
"createdAt": 123
},
"paymentMethod": {
"id": "pi_abc123",
"customerId": "<string>",
"brand": "<string>",
"last4": "<string>",
"expiryMonth": 123,
"expiryYear": 123,
"isPreferred": true,
"revokedAt": "2023-11-07T05:31:56Z",
"createdAt": "2023-11-07T05:31:56Z"
}
},
"message": "<string>"
}{
"success": false,
"error": "UNAUTHORIZED",
"message": "Invalid or missing API key"
}{
"success": false,
"error": "NOT_FOUND",
"message": "Resource not found"
}{
"success": false,
"error": "VALIDATION_ERROR",
"message": "Validation failed",
"data": {
"fieldErrors": [
{
"field": "method",
"message": "method is a required field"
}
]
}
}Payment Methods
Save a payment method to a customer
Attach a tokenized payment method to a customer for later off-session
charges. May return REQUIRES_ACTION with a 3DS challenge URL.
POST
/
v3
/
setup-intents
Save a payment method to a customer
curl --request POST \
--url https://api.beta.suby.fi/v3/setup-intents \
--header 'Content-Type: application/json' \
--header 'X-Suby-Api-Key: <api-key>' \
--data '
{
"customerId": "cus_abc123",
"paymentMethod": {
"tokenizedInstrument": "<string>",
"isPreferred": false
},
"threedsSessionData": {}
}
'import requests
url = "https://api.beta.suby.fi/v3/setup-intents"
payload = {
"customerId": "cus_abc123",
"paymentMethod": {
"tokenizedInstrument": "<string>",
"isPreferred": False
},
"threedsSessionData": {}
}
headers = {
"X-Suby-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-Suby-Api-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
customerId: 'cus_abc123',
paymentMethod: {tokenizedInstrument: '<string>', isPreferred: false},
threedsSessionData: {}
})
};
fetch('https://api.beta.suby.fi/v3/setup-intents', 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.beta.suby.fi/v3/setup-intents",
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([
'customerId' => 'cus_abc123',
'paymentMethod' => [
'tokenizedInstrument' => '<string>',
'isPreferred' => false
],
'threedsSessionData' => [
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-Suby-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://api.beta.suby.fi/v3/setup-intents"
payload := strings.NewReader("{\n \"customerId\": \"cus_abc123\",\n \"paymentMethod\": {\n \"tokenizedInstrument\": \"<string>\",\n \"isPreferred\": false\n },\n \"threedsSessionData\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Suby-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://api.beta.suby.fi/v3/setup-intents")
.header("X-Suby-Api-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"customerId\": \"cus_abc123\",\n \"paymentMethod\": {\n \"tokenizedInstrument\": \"<string>\",\n \"isPreferred\": false\n },\n \"threedsSessionData\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.beta.suby.fi/v3/setup-intents")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Suby-Api-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"customerId\": \"cus_abc123\",\n \"paymentMethod\": {\n \"tokenizedInstrument\": \"<string>\",\n \"isPreferred\": false\n },\n \"threedsSessionData\": {}\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"setupIntent": {
"id": "<string>",
"customerId": "<string>",
"paymentMethodId": "<string>",
"threeDsChallengeUrl": "<string>",
"createdAt": 123
},
"paymentMethod": {
"id": "pi_abc123",
"customerId": "<string>",
"brand": "<string>",
"last4": "<string>",
"expiryMonth": 123,
"expiryYear": 123,
"isPreferred": true,
"revokedAt": "2023-11-07T05:31:56Z",
"createdAt": "2023-11-07T05:31:56Z"
}
},
"message": "<string>"
}{
"success": false,
"error": "UNAUTHORIZED",
"message": "Invalid or missing API key"
}{
"success": false,
"error": "NOT_FOUND",
"message": "Resource not found"
}{
"success": false,
"error": "VALIDATION_ERROR",
"message": "Validation failed",
"data": {
"fieldErrors": [
{
"field": "method",
"message": "method is a required field"
}
]
}
}Authorizations
Secret API key. sk_live_… (production) or sk_sandbox_… (sandbox).
Body
application/json
Was this page helpful?
⌘I

