Portal
Confirm Card Update
Finalize a confirmed SetupIntent and save the card as default
POST
/
portal
/
api
/
payment-method
/
confirm
Finalize a confirmed SetupIntent
curl --request POST \
--url https://billing.example.com/portal/api/payment-method/confirm \
--header 'Content-Type: application/json' \
--cookie portal_session= \
--data '
{
"setup_intent_id": "<string>"
}
'import requests
url = "https://billing.example.com/portal/api/payment-method/confirm"
payload = { "setup_intent_id": "<string>" }
headers = {
"cookie": "portal_session=",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {cookie: 'portal_session=', 'Content-Type': 'application/json'},
body: JSON.stringify({setup_intent_id: '<string>'})
};
fetch('https://billing.example.com/portal/api/payment-method/confirm', 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://billing.example.com/portal/api/payment-method/confirm",
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([
'setup_intent_id' => '<string>'
]),
CURLOPT_COOKIE => "portal_session=",
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$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://billing.example.com/portal/api/payment-method/confirm"
payload := strings.NewReader("{\n \"setup_intent_id\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("cookie", "portal_session=")
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://billing.example.com/portal/api/payment-method/confirm")
.header("cookie", "portal_session=")
.header("Content-Type", "application/json")
.body("{\n \"setup_intent_id\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://billing.example.com/portal/api/payment-method/confirm")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["cookie"] = 'portal_session='
request["Content-Type"] = 'application/json'
request.body = "{\n \"setup_intent_id\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"status": "saved",
"card": {
"brand": "<string>",
"last4": "<string>",
"exp_month": 123,
"exp_year": 123
}
}
}{
"error": {
"code": "BAD_REQUEST",
"message": "<string>"
}
}{
"error": {
"code": "BAD_REQUEST",
"message": "<string>"
}
}{
"error": {
"code": "BAD_REQUEST",
"message": "<string>"
}
}Requires a portal session. Call after
stripe.confirmSetup succeeds — inline, or on return from a 3DS/bank redirect (Stripe appends ?setup_intent= to the return URL; the portal dashboard forwards it here).customer_id matches the authenticated customer — a SetupIntent for someone else can never update this customer’s card — then records the saved method as the default used by dunning retries and off-session charges.
Request Body
| Parameter | Type | Required |
|---|---|---|
setup_intent_id | string (seti_*) | Yes |
Example
curl -X POST https://api.recurso.dev/portal/api/payment-method/confirm \
-H "X-Portal-Session: <session token>" \
-H "Content-Type: application/json" \
-d '{"setup_intent_id": "seti_1Tra..."}'
{
"data": {
"status": "saved",
"card": { "brand": "visa", "last4": "4242", "exp_month": 12, "exp_year": 2029 }
}
}
⌘I
Finalize a confirmed SetupIntent
curl --request POST \
--url https://billing.example.com/portal/api/payment-method/confirm \
--header 'Content-Type: application/json' \
--cookie portal_session= \
--data '
{
"setup_intent_id": "<string>"
}
'import requests
url = "https://billing.example.com/portal/api/payment-method/confirm"
payload = { "setup_intent_id": "<string>" }
headers = {
"cookie": "portal_session=",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {cookie: 'portal_session=', 'Content-Type': 'application/json'},
body: JSON.stringify({setup_intent_id: '<string>'})
};
fetch('https://billing.example.com/portal/api/payment-method/confirm', 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://billing.example.com/portal/api/payment-method/confirm",
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([
'setup_intent_id' => '<string>'
]),
CURLOPT_COOKIE => "portal_session=",
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$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://billing.example.com/portal/api/payment-method/confirm"
payload := strings.NewReader("{\n \"setup_intent_id\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("cookie", "portal_session=")
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://billing.example.com/portal/api/payment-method/confirm")
.header("cookie", "portal_session=")
.header("Content-Type", "application/json")
.body("{\n \"setup_intent_id\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://billing.example.com/portal/api/payment-method/confirm")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["cookie"] = 'portal_session='
request["Content-Type"] = 'application/json'
request.body = "{\n \"setup_intent_id\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"status": "saved",
"card": {
"brand": "<string>",
"last4": "<string>",
"exp_month": 123,
"exp_year": 123
}
}
}{
"error": {
"code": "BAD_REQUEST",
"message": "<string>"
}
}{
"error": {
"code": "BAD_REQUEST",
"message": "<string>"
}
}{
"error": {
"code": "BAD_REQUEST",
"message": "<string>"
}
}