diff --git a/api-reference/openapi/accounts.json b/api-reference/openapi/accounts.json index 4ad8434..ffbe4a9 100644 --- a/api-reference/openapi/accounts.json +++ b/api-reference/openapi/accounts.json @@ -415,6 +415,77 @@ } } }, + "/api/stripe/session/status": { + "post": { + "servers": [ + { + "url": "https://api.recoupable.com" + } + ], + "description": "Confirm that a Stripe checkout session has been processed and credits have been applied. Updates the session metadata with a `credit_updated` marker. Should be called once after a successful checkout redirect to trigger credit provisioning for the account.", + "security": [ + { + "apiKeyAuth": [] + }, + { + "bearerAuth": [] + } + ], + "requestBody": { + "description": "Session confirmation parameters", + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ConfirmStripeSessionRequest" + } + } + } + }, + "responses": { + "200": { + "description": "Session confirmed and credit metadata updated successfully", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/StripeSessionStatusResponse" + } + } + } + }, + "400": { + "description": "Bad request — missing `sessionId` or Stripe API error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AccountErrorResponse" + } + } + } + }, + "401": { + "description": "Unauthorized — invalid or missing authentication", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AccountErrorResponse" + } + } + } + }, + "403": { + "description": "Forbidden - account override not permitted", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AccountErrorResponse" + } + } + } + } + } + } + }, "/api/workspaces": { "post": { "description": "Create a new workspace account. Workspaces can optionally be linked to an organization.", @@ -2934,6 +3005,57 @@ "example": "Verified" } } + }, + "ConfirmStripeSessionRequest": { + "type": "object", + "required": [ + "sessionId" + ], + "properties": { + "sessionId": { + "type": "string", + "description": "The Stripe checkout session ID to confirm (e.g. `cs_test_...`).", + "example": "cs_test_a1b2c3d4e5f6g7h8i9j0" + }, + "accountId": { + "type": "string", + "format": "uuid", + "description": "Used for authorization scoping when the API key has access to multiple accounts via organization membership. Must match the account already associated with the session via `metadata.accountId`. If not provided, the API key's own account is used.", + "example": "123e4567-e89b-12d3-a456-426614174000" + } + } + }, + "StripeSessionStatusResponse": { + "type": "object", + "description": "The updated Stripe checkout session object. For the full list of available properties, see the [Stripe Checkout Session API documentation](https://docs.stripe.com/api/checkout/sessions/object).", + "required": [ + "id", + "status" + ], + "properties": { + "id": { + "type": "string", + "description": "Unique identifier for the Stripe checkout session.", + "example": "cs_test_a1b2c3d4e5f6g7h8i9j0" + }, + "status": { + "type": "string", + "enum": ["open", "complete", "expired"], + "description": "Current status of the checkout session.", + "example": "complete" + }, + "metadata": { + "type": "object", + "description": "Session metadata, including `credit_updated` once this endpoint has been called.", + "additionalProperties": { + "type": "string" + }, + "example": { + "accountId": "123e4567-e89b-12d3-a456-426614174000", + "credit_updated": "credit_updated" + } + } + } } } } diff --git a/api-reference/stripe/session-status.mdx b/api-reference/stripe/session-status.mdx new file mode 100644 index 0000000..922be98 --- /dev/null +++ b/api-reference/stripe/session-status.mdx @@ -0,0 +1,4 @@ +--- +title: 'Confirm Stripe Session' +openapi: '/api-reference/openapi/accounts.json POST /api/stripe/session/status' +--- diff --git a/docs.json b/docs.json index 997442c..3d5b835 100644 --- a/docs.json +++ b/docs.json @@ -331,6 +331,12 @@ "api-reference/subscriptions/get" ] }, + { + "group": "Stripe", + "pages": [ + "api-reference/stripe/session-status" + ] + }, { "group": "Admins", "pages": [