Portal
Start Card Update
Create a Stripe SetupIntent for the logged-in portal customer
POST
/
portal
/
api
/
payment-method
/
setup-intent
Start a card update (Stripe SetupIntent)
curl --request POST \
--url https://billing.example.com/portal/api/payment-method/setup-intent \
--cookie portal_session=import requests
url = "https://billing.example.com/portal/api/payment-method/setup-intent"
headers = {"cookie": "portal_session="}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {cookie: 'portal_session='}};
fetch('https://billing.example.com/portal/api/payment-method/setup-intent', 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/setup-intent",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_COOKIE => "portal_session=",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://billing.example.com/portal/api/payment-method/setup-intent"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("cookie", "portal_session=")
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/setup-intent")
.header("cookie", "portal_session=")
.asString();require 'uri'
require 'net/http'
url = URI("https://billing.example.com/portal/api/payment-method/setup-intent")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["cookie"] = 'portal_session='
response = http.request(request)
puts response.read_body{
"data": {
"client_secret": "<string>",
"publishable_key": "<string>"
}
}{
"error": {
"code": "validation_failed",
"message": "<string>"
}
}{
"error": {
"code": "validation_failed",
"message": "<string>"
}
}Requires a portal session (
X-Portal-Session header from magic-link login).client_secret the Payment Element confirms in the browser. Card data goes browser → Stripe directly — no PAN ever reaches Recurso (PCI SAQ-A preserved). After stripe.confirmSetup, finalize with POST /portal/api/payment-method/confirm.
On deployments without Stripe configured this returns 503; UPI-mandate customers should use mandate re-authorization instead.
Example
curl -X POST https://api.recurso.dev/portal/api/payment-method/setup-intent \
-H "X-Portal-Session: <session token>"
{
"data": {
"client_secret": "seti_1Tra..._secret_...",
"publishable_key": "pk_live_..."
}
}
⌘I
Start a card update (Stripe SetupIntent)
curl --request POST \
--url https://billing.example.com/portal/api/payment-method/setup-intent \
--cookie portal_session=import requests
url = "https://billing.example.com/portal/api/payment-method/setup-intent"
headers = {"cookie": "portal_session="}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {cookie: 'portal_session='}};
fetch('https://billing.example.com/portal/api/payment-method/setup-intent', 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/setup-intent",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_COOKIE => "portal_session=",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://billing.example.com/portal/api/payment-method/setup-intent"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("cookie", "portal_session=")
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/setup-intent")
.header("cookie", "portal_session=")
.asString();require 'uri'
require 'net/http'
url = URI("https://billing.example.com/portal/api/payment-method/setup-intent")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["cookie"] = 'portal_session='
response = http.request(request)
puts response.read_body{
"data": {
"client_secret": "<string>",
"publishable_key": "<string>"
}
}{
"error": {
"code": "validation_failed",
"message": "<string>"
}
}{
"error": {
"code": "validation_failed",
"message": "<string>"
}
}