Payments
Payments are the core entity in fype. They represent an intent to collect money from a customer.Payment Lifecycle
A payment can transition through the following states:- Created: The payment intent has been created in fype.
- Processing: The customer has initiated the payment on the gateway, and fype is waiting for confirmation.
- Succeeded: The payment was successfully captured.
- Failed: The payment attempt failed or was declined.
- Cancelled: The customer cancelled the payment session.
- Expired: The checkout session expired before the payment was completed.
Creating a Payment
Payments are created via thePOST /v1/payments endpoint. When you create a payment, fype:
- Validates your request.
- Generates a unique
checkout_session. - Returns a
checkout_url.
Gateway Selection (Provider)
By default, Fype uses its internal routing logic to choose the best gateway for a payment. However, you can explicitly choose a gateway by passing theprovider field in your request:
razorpay: Routes the payment through Razorpay.cashfree: Routes the payment through Cashfree.
Monitoring Payments
Via Dashboard
The Payments tab in the dashboard provides a real-time view of all transactions. You can filter by status and date range.Via API
You can fetch the latest status of any payment using its ID:GET /v1/payments/{payment_id}
Via Webhooks (Recommended)
Configure a webhook listener forpayment.succeeded and payment.failed events to automate your business logic.
Best Practices
- Use Reference IDs: Always provide your own
reference_id(e.g., your Order ID) to make reconciliation easier. - Store fype IDs: Save the fype
payment_idin your database alongside your order record. - Implement Idempotency: Use the
Idempotency-Keyheader to safely retry requests if you experience network issues. - Handle All States: Ensure your application logic can handle
processing,failed, andexpiredstates gracefully.