Skip to main content

Create Payment

POST /paiement/:provider

Creates a payment invoice for purchasing items or adding balance using the specified payment provider.
POST /paiement/{provider}
Authentication: connected Path Parameters
provider
string
required
The payment provider to use (e.g., "stripe", "paypal", etc.).
Body Parameters
type
string
required
Payment type: "balance" for adding funds, or "items" for purchasing specific items.
amount
integer
Amount in cents (required when type is "balance").
items
array
Array of item details (required when type is "items").
payment_method_id
string
Specific payment method identifier (provider-dependent).

Payment Flow

  1. The server validates the user and request parameters
  2. Generates a unique transaction UUID
  3. For "balance" type: prepares a balance top-up payment
  4. For "items" type: validates items availability and prepares item purchase
  5. Records the transaction in the database
  6. Creates an invoice with the payment provider
Response — Redirect Payment
{
  "status": "success",
  "data": {
    "url": "https://checkout.stripe.com/pay/..."
  }
}
data.url
string
Redirect URL to the payment provider’s checkout page.
Response — Direct Payment
{
  "status": "success",
  "data": {
    "message": "Payment processed successfully"
  }
}
Errors
StatusMessage
errorProvider is required
errorInvalid user
errorInvalid provider
errorInvalid request parameters
errorNo items found
errorFailed to save transaction
errorFailed to process payment