Skip to main content

Initiate Payment

Creates a new transaction record and returns details required to proceed with payment via the chosen processor (e.g., an authorization URL for Paystack).

This endpoint likely requires API Key Authentication (using your Test or Live Secret Key) in a real implementation, although the current backend example doesn't enforce it yet.

POST /api/transactions/initiate

Request Body

{
"merchantId": "uuid-merchant-456", // Required (How this is identified needs clarification - API key?)
"amount": 500000, // Required, Integer (kobo/cents)
"email": "customer@example.com", // Required
"firstName": "John", // Optional
"lastName": "Doe", // Optional
"channel": "card", // Optional (card, bank_transfer, ussd)
"reference": "your-order-ref-123", // Optional merchant reference prefix
"callbackUrl": "https://yourdomain.com/payment/callback", // Optional URL for frontend redirect
"paymentLinkId": "uuid-link-123", // Optional if initiated from a link
"invoiceId": "uuid-invoice-789", // Optional if initiated from an invoice
"metadata": { // Optional
"custom_field": "custom_value",
"cart_id": "xyz789"
}
}
FieldTypeRequiredDescription
merchantIdStringYesThe ID of the merchant initiating the payment. (Authentication TBD)
amountIntegerYesAmount in the lowest currency unit (kobo/cents). Min 5000 (50 NGN).
emailStringYesCustomer's email address.
firstNameStringNoCustomer's first name.
lastNameStringNoCustomer's last name.
channelStringNoPayment channel (card, bank_transfer, ussd). Defaults may apply.
referenceStringNoOptional base reference from the merchant. SkyPay generates a unique full ref.
callbackUrlString (URL)NoURL to redirect the user to on your frontend after payment attempt.
paymentLinkIdString (UUID)NoID of the source PaymentLink if applicable.
invoiceIdString (UUID)NoID of the source Invoice if applicable.
metadataObjectNoAn object containing any additional data you want to associate.

Responses

Success 201 Created

Returns details needed for the next step in the payment flow.

{
"message": "Payment initiated successfully",
"reference": "SKP-1678886400000-a1b2c3d4", // SkyPay's unique transaction reference
// Details below depend on the payment processor used:
"authorizationUrl": "https://checkout.skypay.com/simulated_url", // Example for Paystack
"accessCode": "simulated_code" // Example for Paystack
}

Error 400 Bad Request

Returned for invalid input data.

{
"message": "Validation failed",
"errors": [ /* ... details ... */ ]
}

Error 404 Not Found

Returned if the specified merchantId is invalid.

{
"message": "Merchant not found"
}

Error 502 Bad Gateway

Returned if the downstream payment processor fails during initiation.

{
"message": "Payment processor interaction failed: [Processor Error Message]"
}