Skip to content

Payments API ​

The Payments API allows you to create, manage, and track payment transactions for both authenticated users and guest customers.

Base URL ​

https://your-instance.pubflow.com/bridge-payment

Authentication ​

Include one of the following in your requests:

  • Header: X-Session-ID: <session_id> (recommended)
  • Header: Authorization: Bearer <token>
  • Query Parameter: ?session_id=<session_id> (alternative method)
  • Guest: Provide guest_data in request body (no auth required)

Query Parameter Authentication

You can pass the session ID as a query parameter for convenience:

POST /bridge-payment/payments/intents?session_id=your_session_id

This is useful for testing but the header method is recommended for production.

Endpoints Overview ​

MethodEndpointDescription
POST/payments/intentsCreate payment intent
PUT/payments/intents/:idUpdate payment intent
POST/payments/confirm/:idConfirm payment
POST/payments/sync/:provider_payment_idSync payment status
GET/payments/:idGet payment by ID
GET/paymentsList user payments
GET/payments/guest/:emailList guest payments

Create Payment Intent ​

Create a new payment intent to start a payment transaction.

Request ​

http
POST /bridge-payment/payments/intents
Content-Type: application/json
X-Session-ID: <session_id>

Request Body ​

FieldTypeRequiredDescription
subtotal_centsnumberYesSubtotal amount in cents
tax_centsnumberNoTax amount in cents (default: 0)
discount_centsnumberNoDiscount amount in cents (default: 0)
total_centsnumberYesTotal amount in cents
currencystringYesCurrency code (USD, EUR, etc.)
provider_idstringNoPayment provider (default: "stripe")
descriptionstringNoPayment description
conceptstringNoPayment concept/title
reference_codestringNoYour internal reference
categorystringNoPayment category
tagsstringNoComma-separated tags
setup_future_usagestringNo"off_session" to save payment method
payment_method_idstringNoUse saved payment method
customer_idstringNoCustomer ID (auto-detected if not provided)
organization_idstringNoOrganization ID
metadataobjectNoAdditional metadata
guest_dataobjectNo*Guest customer data (*required for guests)
guest_data.emailstringYesGuest email
guest_data.namestringYesGuest name
guest_data.phonestringNoGuest phone

Response ​

json
{
  "id": "pay_1234567890",
  "provider_payment_id": "pi_stripe_abc123",
  "client_secret": "pi_stripe_abc123_secret_xyz",
  "status": "created",
  "subtotal_cents": 1800,
  "tax_cents": 200,
  "discount_cents": 0,
  "total_cents": 2000,
  "currency": "USD",
  "provider_id": "stripe",
  "concept": "Premium Subscription",
  "description": "Monthly premium plan",
  "is_guest_payment": false,
  "created_at": "2025-01-15T10:30:00Z"
}

Client Secret Security

The client_secret is automatically deleted after 24 hours for security. Use it immediately on the frontend to confirm payment.

Examples ​

Authenticated User Payment ​

bash
curl -X POST "https://your-instance.pubflow.com/bridge-payment/payments/intents" \
  -H "Content-Type: application/json" \
  -H "X-Session-ID: session_abc123" \
  -d '{
    "subtotal_cents": 1800,
    "tax_cents": 200,
    "total_cents": 2000,
    "currency": "USD",
    "concept": "Premium Subscription",
    "description": "Monthly premium plan",
    "provider_id": "stripe",
    "setup_future_usage": "off_session"
  }'

Guest Payment ​

bash
curl -X POST "https://your-instance.pubflow.com/bridge-payment/payments/intents" \
  -H "Content-Type: application/json" \
  -d '{
    "subtotal_cents": 5000,
    "tax_cents": 500,
    "total_cents": 5500,
    "currency": "USD",
    "concept": "Donation",
    "provider_id": "stripe",
    "guest_data": {
      "email": "donor@example.com",
      "name": "John Doe",
      "phone": "+1234567890"
    }
  }'

Payment with Saved Method ​

bash
curl -X POST "https://your-instance.pubflow.com/bridge-payment/payments/intents" \
  -H "Content-Type: application/json" \
  -H "X-Session-ID: session_abc123" \
  -d '{
    "total_cents": 2000,
    "currency": "USD",
    "concept": "Subscription Renewal",
    "provider_id": "stripe",
    "payment_method_id": "pm_saved_card_123"
  }'

Update Payment Intent ​

Update an existing payment intent before confirmation.

Request ​

http
PUT /bridge-payment/payments/intents/:id
Content-Type: application/json
X-Session-ID: <session_id>

Request Body ​

Same fields as Create Payment Intent (all optional).

Response ​

Returns updated payment intent object.


Confirm Payment ​

Confirm a payment intent (backend confirmation).

Request ​

http
POST /bridge-payment/payments/confirm/:id
Content-Type: application/json
X-Session-ID: <session_id>

Request Body ​

FieldTypeRequiredDescription
payment_method_idstringNoPayment method to use

Response ​

json
{
  "id": "pay_1234567890",
  "status": "succeeded",
  "provider_payment_id": "pi_stripe_abc123",
  "completed_at": "2025-01-15T10:35:00Z"
}

Frontend Confirmation

Most integrations use Stripe Elements for frontend confirmation. Use this endpoint only for backend-only flows.


Sync Payment Status ​

Sync payment status from provider after frontend confirmation.

Request ​

http
POST /bridge-payment/payments/sync/:provider_payment_id
X-Session-ID: <session_id>

Response ​

Returns updated payment object with current status from provider.

Example ​

bash
# After Stripe redirects to return_url with payment_intent parameter
curl -X POST "https://your-instance.pubflow.com/bridge-payment/payments/sync/pi_stripe_abc123" \
  -H "X-Session-ID: session_abc123"

Get Payment ​

Retrieve a specific payment by ID.

Request ​

http
GET /bridge-payment/payments/:id
X-Session-ID: <session_id>

Response ​

Returns complete payment object.


List Payments ​

List all payments for authenticated user.

Request ​

http
GET /bridge-payment/payments
X-Session-ID: <session_id>

Response ​

json
[
  {
    "id": "pay_123",
    "total_cents": 2000,
    "status": "succeeded",
    "created_at": "2025-01-15T10:30:00Z"
  }
]

List Guest Payments ​

List payments for a guest email.

Request ​

http
GET /bridge-payment/payments/guest/:email

No authentication required.


Next Steps ​