Skip to main content

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:
  1. Created: The payment intent has been created in fype.
  2. Processing: The customer has initiated the payment on the gateway, and fype is waiting for confirmation.
  3. Succeeded: The payment was successfully captured.
  4. Failed: The payment attempt failed or was declined.
  5. Cancelled: The customer cancelled the payment session.
  6. Expired: The checkout session expired before the payment was completed.

Creating a Payment

Payments are created via the POST /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 the provider field in your request:
  • razorpay: Routes the payment through Razorpay.
  • cashfree: Routes the payment through Cashfree.
If both are connected and no provider is specified, Fype defaults to Razorpay.

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} Configure a webhook listener for payment.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_id in your database alongside your order record.
  • Implement Idempotency: Use the Idempotency-Key header to safely retry requests if you experience network issues.
  • Handle All States: Ensure your application logic can handle processing, failed, and expired states gracefully.