curl --request POST \
--url https://api.beta.suby.fi/v3/payments/off-session \
--header 'Content-Type: application/json' \
--header 'X-Suby-Api-Key: <api-key>' \
--data '
{
"offSession": true,
"customer": {
"id": "cus_k400aus0ky29qniksprwe7e4"
},
"customerPaymentMethodId": "pi_x2032ganpa44h2y7eums4f7p",
"productId": "pro_fk28xlirbl01eb52ukr0qp13",
"priceCents": "1250",
"displayName": "April usage"
}
'import requests
url = "https://api.beta.suby.fi/v3/payments/off-session"
payload = {
"offSession": True,
"customer": { "id": "cus_k400aus0ky29qniksprwe7e4" },
"customerPaymentMethodId": "pi_x2032ganpa44h2y7eums4f7p",
"productId": "pro_fk28xlirbl01eb52ukr0qp13",
"priceCents": "1250",
"displayName": "April usage"
}
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({
offSession: true,
customer: {id: 'cus_k400aus0ky29qniksprwe7e4'},
customerPaymentMethodId: 'pi_x2032ganpa44h2y7eums4f7p',
productId: 'pro_fk28xlirbl01eb52ukr0qp13',
priceCents: '1250',
displayName: 'April usage'
})
};
fetch('https://api.beta.suby.fi/v3/payments/off-session', 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/payments/off-session",
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([
'offSession' => true,
'customer' => [
'id' => 'cus_k400aus0ky29qniksprwe7e4'
],
'customerPaymentMethodId' => 'pi_x2032ganpa44h2y7eums4f7p',
'productId' => 'pro_fk28xlirbl01eb52ukr0qp13',
'priceCents' => '1250',
'displayName' => 'April usage'
]),
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/payments/off-session"
payload := strings.NewReader("{\n \"offSession\": true,\n \"customer\": {\n \"id\": \"cus_k400aus0ky29qniksprwe7e4\"\n },\n \"customerPaymentMethodId\": \"pi_x2032ganpa44h2y7eums4f7p\",\n \"productId\": \"pro_fk28xlirbl01eb52ukr0qp13\",\n \"priceCents\": \"1250\",\n \"displayName\": \"April usage\"\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/payments/off-session")
.header("X-Suby-Api-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"offSession\": true,\n \"customer\": {\n \"id\": \"cus_k400aus0ky29qniksprwe7e4\"\n },\n \"customerPaymentMethodId\": \"pi_x2032ganpa44h2y7eums4f7p\",\n \"productId\": \"pro_fk28xlirbl01eb52ukr0qp13\",\n \"priceCents\": \"1250\",\n \"displayName\": \"April usage\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.beta.suby.fi/v3/payments/off-session")
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 \"offSession\": true,\n \"customer\": {\n \"id\": \"cus_k400aus0ky29qniksprwe7e4\"\n },\n \"customerPaymentMethodId\": \"pi_x2032ganpa44h2y7eums4f7p\",\n \"productId\": \"pro_fk28xlirbl01eb52ukr0qp13\",\n \"priceCents\": \"1250\",\n \"displayName\": \"April usage\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"payment": {
"rail": "card",
"id": "pay_abc123",
"organizationId": "<string>",
"customerId": "<string>",
"productId": "<string>",
"subscriptionId": "<string>",
"status": "PENDING",
"paymentMethodCategory": "CARD",
"declineCode": "<string>",
"declineCategory": "SOFT",
"declineAdvice": "TRY_AGAIN_LATER",
"declineNetworkCode": "<string>",
"threeDSecureResult": "AUTHENTICATED",
"displayName": "<string>",
"displayDescription": "<string>",
"displayImageUrl": "<string>",
"priceCents": "<string>",
"currency": "<string>",
"tokenAmount": "<string>",
"tokenFeeAmount": "<string>",
"quoteFiatAmountCents": 123,
"quoteFiatCurrency": "<string>",
"grossAmountCents": 123,
"platformFeeCents": 123,
"merchantNetCents": 123,
"vatAmountCents": 123,
"vatRateBps": 123,
"taxInclusive": true,
"fxSurchargeCents": 123,
"internationalCardSurchargeCents": 123,
"rollingReserveCents": 123,
"refundedAmountCents": 123,
"refundedAt": "2023-11-07T05:31:56Z",
"cryptoSettlementMode": "<string>",
"settlementChainId": 123,
"settlementAsset": "<string>",
"settlementRecipient": "<string>",
"depositAddress": "<string>",
"settlementTxHash": "<string>",
"lifiTxHash": "<string>",
"lifiSubstatus": "<string>",
"successUrl": "<string>",
"cancelUrl": "<string>",
"externalRef": "<string>",
"paymentReceivedAt": "2023-11-07T05:31:56Z",
"paymentSettledAt": "2023-11-07T05:31:56Z",
"paymentConfirmedAt": "2023-11-07T05:31:56Z",
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z",
"expiresAt": "2023-11-07T05:31:56Z",
"statusTimeline": [
{
"status": "PENDING",
"at": "2023-11-07T05:31:56Z"
}
],
"items": [
{
"productId": "<string>",
"name": "<string>",
"quantity": 123,
"unitPriceCents": 123
}
],
"asset": {
"chainId": 123,
"chainName": "<string>",
"chainLogoUrl": "<string>",
"symbol": "<string>",
"decimals": 123,
"address": "<string>",
"logoUrl": "<string>"
},
"settlementChain": {
"chainId": 123,
"name": "<string>",
"logoUrl": "<string>"
},
"deposit": {
"expected": "<string>",
"received": "<string>",
"remaining": "<string>",
"confirmations": {
"observed": 123,
"required": 123,
"detectedAt": "2023-11-07T05:31:56Z"
},
"warnings": [
{
"code": "INSUFFICIENT_DEPOSIT_AMOUNT",
"message": "<string>",
"data": {}
}
]
}
},
"checkout": {
"providerPaymentId": "<string>",
"redirectUrl": "<string>",
"threeDsChallengeUrl": "<string>",
"clientSecret": "<string>"
},
"instruction": {
"kind": "qr_deposit",
"chainId": 123,
"depositAddress": "<string>",
"expectedAmount": "<string>",
"decimals": 123,
"symbol": "<string>",
"address": "<string>",
"bip21Uri": "<string>",
"surchargeNote": "<string>"
}
},
"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"
}
]
}
}{
"success": false,
"error": "RATE_LIMITED",
"message": "Too many requests"
}Debit a stored card, off-session
Debit a card already stored here, no payer present · metered billing, top-ups, a usage threshold crossed.
productId says what was consumed, priceCents how much. The product must be
billingMode: pay_as_you_go (422 PRODUCT_NOT_PRICED_PER_USE otherwise) and
the currency comes from it.
Collecting a NEW card is not possible here · open a checkout session.
Crypto has its own endpoint, POST /v3/crypto/charges.
curl --request POST \
--url https://api.beta.suby.fi/v3/payments/off-session \
--header 'Content-Type: application/json' \
--header 'X-Suby-Api-Key: <api-key>' \
--data '
{
"offSession": true,
"customer": {
"id": "cus_k400aus0ky29qniksprwe7e4"
},
"customerPaymentMethodId": "pi_x2032ganpa44h2y7eums4f7p",
"productId": "pro_fk28xlirbl01eb52ukr0qp13",
"priceCents": "1250",
"displayName": "April usage"
}
'import requests
url = "https://api.beta.suby.fi/v3/payments/off-session"
payload = {
"offSession": True,
"customer": { "id": "cus_k400aus0ky29qniksprwe7e4" },
"customerPaymentMethodId": "pi_x2032ganpa44h2y7eums4f7p",
"productId": "pro_fk28xlirbl01eb52ukr0qp13",
"priceCents": "1250",
"displayName": "April usage"
}
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({
offSession: true,
customer: {id: 'cus_k400aus0ky29qniksprwe7e4'},
customerPaymentMethodId: 'pi_x2032ganpa44h2y7eums4f7p',
productId: 'pro_fk28xlirbl01eb52ukr0qp13',
priceCents: '1250',
displayName: 'April usage'
})
};
fetch('https://api.beta.suby.fi/v3/payments/off-session', 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/payments/off-session",
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([
'offSession' => true,
'customer' => [
'id' => 'cus_k400aus0ky29qniksprwe7e4'
],
'customerPaymentMethodId' => 'pi_x2032ganpa44h2y7eums4f7p',
'productId' => 'pro_fk28xlirbl01eb52ukr0qp13',
'priceCents' => '1250',
'displayName' => 'April usage'
]),
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/payments/off-session"
payload := strings.NewReader("{\n \"offSession\": true,\n \"customer\": {\n \"id\": \"cus_k400aus0ky29qniksprwe7e4\"\n },\n \"customerPaymentMethodId\": \"pi_x2032ganpa44h2y7eums4f7p\",\n \"productId\": \"pro_fk28xlirbl01eb52ukr0qp13\",\n \"priceCents\": \"1250\",\n \"displayName\": \"April usage\"\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/payments/off-session")
.header("X-Suby-Api-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"offSession\": true,\n \"customer\": {\n \"id\": \"cus_k400aus0ky29qniksprwe7e4\"\n },\n \"customerPaymentMethodId\": \"pi_x2032ganpa44h2y7eums4f7p\",\n \"productId\": \"pro_fk28xlirbl01eb52ukr0qp13\",\n \"priceCents\": \"1250\",\n \"displayName\": \"April usage\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.beta.suby.fi/v3/payments/off-session")
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 \"offSession\": true,\n \"customer\": {\n \"id\": \"cus_k400aus0ky29qniksprwe7e4\"\n },\n \"customerPaymentMethodId\": \"pi_x2032ganpa44h2y7eums4f7p\",\n \"productId\": \"pro_fk28xlirbl01eb52ukr0qp13\",\n \"priceCents\": \"1250\",\n \"displayName\": \"April usage\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"payment": {
"rail": "card",
"id": "pay_abc123",
"organizationId": "<string>",
"customerId": "<string>",
"productId": "<string>",
"subscriptionId": "<string>",
"status": "PENDING",
"paymentMethodCategory": "CARD",
"declineCode": "<string>",
"declineCategory": "SOFT",
"declineAdvice": "TRY_AGAIN_LATER",
"declineNetworkCode": "<string>",
"threeDSecureResult": "AUTHENTICATED",
"displayName": "<string>",
"displayDescription": "<string>",
"displayImageUrl": "<string>",
"priceCents": "<string>",
"currency": "<string>",
"tokenAmount": "<string>",
"tokenFeeAmount": "<string>",
"quoteFiatAmountCents": 123,
"quoteFiatCurrency": "<string>",
"grossAmountCents": 123,
"platformFeeCents": 123,
"merchantNetCents": 123,
"vatAmountCents": 123,
"vatRateBps": 123,
"taxInclusive": true,
"fxSurchargeCents": 123,
"internationalCardSurchargeCents": 123,
"rollingReserveCents": 123,
"refundedAmountCents": 123,
"refundedAt": "2023-11-07T05:31:56Z",
"cryptoSettlementMode": "<string>",
"settlementChainId": 123,
"settlementAsset": "<string>",
"settlementRecipient": "<string>",
"depositAddress": "<string>",
"settlementTxHash": "<string>",
"lifiTxHash": "<string>",
"lifiSubstatus": "<string>",
"successUrl": "<string>",
"cancelUrl": "<string>",
"externalRef": "<string>",
"paymentReceivedAt": "2023-11-07T05:31:56Z",
"paymentSettledAt": "2023-11-07T05:31:56Z",
"paymentConfirmedAt": "2023-11-07T05:31:56Z",
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z",
"expiresAt": "2023-11-07T05:31:56Z",
"statusTimeline": [
{
"status": "PENDING",
"at": "2023-11-07T05:31:56Z"
}
],
"items": [
{
"productId": "<string>",
"name": "<string>",
"quantity": 123,
"unitPriceCents": 123
}
],
"asset": {
"chainId": 123,
"chainName": "<string>",
"chainLogoUrl": "<string>",
"symbol": "<string>",
"decimals": 123,
"address": "<string>",
"logoUrl": "<string>"
},
"settlementChain": {
"chainId": 123,
"name": "<string>",
"logoUrl": "<string>"
},
"deposit": {
"expected": "<string>",
"received": "<string>",
"remaining": "<string>",
"confirmations": {
"observed": 123,
"required": 123,
"detectedAt": "2023-11-07T05:31:56Z"
},
"warnings": [
{
"code": "INSUFFICIENT_DEPOSIT_AMOUNT",
"message": "<string>",
"data": {}
}
]
}
},
"checkout": {
"providerPaymentId": "<string>",
"redirectUrl": "<string>",
"threeDsChallengeUrl": "<string>",
"clientSecret": "<string>"
},
"instruction": {
"kind": "qr_deposit",
"chainId": 123,
"depositAddress": "<string>",
"expectedAmount": "<string>",
"decimals": 123,
"symbol": "<string>",
"address": "<string>",
"bip21Uri": "<string>",
"surchargeNote": "<string>"
}
},
"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"
}
]
}
}{
"success": false,
"error": "RATE_LIMITED",
"message": "Too many requests"
}Authorizations
Secret API key. sk_live_… (production) or sk_sandbox_… (sandbox).
Headers
Optional key (≤255 chars, e.g. a UUID v4) making this POST safe to retry · the response is cached 24h and a retry with the SAME key replays it instead of re-executing. The same key with a different body → 422 IDEMPOTENCY_KEY_CONFLICT; a retry while the first is in flight → 409.
255"5f3b9c2e-1a4d-4f2b-9c31-7e2a1b6d8c04"
Body
One shape only · an off-session debit of a stored card against a pay_as_you_go product. There is no method: customerPaymentMethodId names the instrument, and the instrument decides. A payer-present charge goes through the hosted checkout, crypto through POST /v3/crypto/charges.
Always true.
true The customer must already exist · there is nothing stored to debit otherwise.
Show child attributes
Show child attributes
The stored card to debit, from GET /v3/customers/{id}/payment-methods.
"pi_abc123"
A pay_as_you_go product · what the usage belongs to, and what product_id carries on payment.succeeded.
"pro_abc123"
Minor units as a string of digits · "1250" = 12.50. The currency is the product's. Under 1.00 (VAT included) is refused with CARD_PAYMENT_BELOW_MIN.
^[1-9]\d*$"1250"
Receipt label for this period. Defaults to the product name.
200"April usage"
500MoR VAT · defaults to the product's. Inert when no VAT applies.
inclusive, exclusive Required when the customer has none on file · acquirers reject an empty country.
Show child attributes
Show child attributes
Optional · omit it and the customer's stored isBusiness decides. Send it only to state something different for this debit.
Show child attributes
Show child attributes
Your reference · stored, echoed, filterable.
120Key-value pairs. ≤50 keys, keys ≤40 chars, values are
strings ≤500 chars (or null to clear). Nested structures must be
JSON-stringified into a single string value.
Show child attributes
Show child attributes
Was this page helpful?

