palbaseDocs

Palbase IAP · API

POST/iap/portal

Manage what was bought on the web

Opens the payment provider's customer portal, where a customer changes, cancels or renews what they bought on the web and how they pay: send them to url. With a customer's session it is their own; the project's server, with its secret key, names the customer in customer_id — a team's or a company's billing page, opened for whoever manages it. The portal is of the payment channel the customer bought on, unless channel names another. return_url goes back to one of the project's registered apps. Closed to an environment's token (403 token_out_of_scope): whoever holds the link manages the customer's subscriptions and cards at the provider, for as long as the provider keeps it open.

Called by a signed-in user of your app, with their token and the publishable key; or your server, with the project's secret key.

Request body

channelstring · optionalThe payment channel whose portal to open. When absent: the channel of the customer's newest web subscription — the provider that knows them.
customer_idstring · optionalThe customer whose portal to open, named by the project's server (its secret key): required with the secret key (400 `customer_id_required`), refused with a customer's own session (403 `customer_id_not_allowed`), which opens their own.
return_urlstring · requiredA registered web app's origin, or a native app's own scheme.
curl
curl -X POST "https://<your-ref>.palbase.studio/iap/portal" \
  -H "apikey: $PALBASE_SECRET_KEY" \
  -H "content-type: application/json" \
  -d '{"return_url":"string"}'

Responses

201The portal

400`return_url` goes elsewhere than the project's apps (`return_url_not_allowed`), the project's server named no customer (`customer_id_required`), or the body is not the request

401Neither a customer's session nor the project's secret key (`session_required`): a customer's own is reached with the publishable key and their access token; or the edge refused the key or token

403`customer_id` was given with a customer's own session (`customer_id_not_allowed`): they open their own portal; or an environment's token (`token_out_of_scope`): the link would outlive it

409The user bought nothing on the web (`no_web_customer`), this guest's purchases went to an account (`customer_merged`: open it with the account's session), or the payments module refused it, its code and words passed on as it answered them

413The request body is too large (`request_too_large`)

422The payments module refused it, its code and words passed on as it answered them: the provider's refusal of the portal

429Over the project's request limit; Retry-After says when to try again

502Stripe could not be reached (`stripe_unreachable`); retrying is safe after Retry-After

503Temporarily unavailable; retrying is safe after Retry-After

defaultAn error: the envelope names it (`error`) and explains it (`error_description`).

Operation CreatePortalSession of iap's contract.