Documentation Index
Fetch the complete documentation index at: https://docs.fype.dev/llms.txt
Use this file to discover all available pages before exploring further.
Step-by-Step Integration Guide
This guide provides a linear, definitive path to integrating Fype into your application. Following these steps ensures a secure and resilient implementation.1. Initial Configuration
Before writing any code, prepare your Fype environment:- Create a Merchant Account: Sign up at dashboard.fype.dev.
- Obtain Test Keys: Go to Developers > API Keys and generate a test key (
fype_test_...). - Connect a Provider: Even for testing, ensure a provider is “connected.” Use the Simulator for zero-config testing or connect Razorpay Sandbox for a more realistic flow.
- Configure a Local Webhook Tunnel: Use a tool like
ngrokorlocaltunnelto expose your local server (e.g.,https://your-tunnel.ngrok-free.app/webhooks/fype). Add this URL in Developers > Webhooks.
2. Server-Side: Create a Payment
When a customer clicks “Checkout” on your site, your backend must call Fype to create a payment intent. Never call this API from the frontend/browser.Request Construction
- Amount: Must be in subunits (e.g.,
50000for ₹500.00). - Reference ID: Pass your internal Order ID for reconciliation.
- Idempotency: Always send an
Idempotency-Keyto prevent duplicate charges.
Example (Node.js)
3. Client-Side: Redirection
Once your server receives thecheckout_url, send it to your frontend and redirect the customer.
Example (Frontend JS)
4. Handle Redirection Back to Your Site
After the payment is processed (or cancelled), Fype redirects the customer back to yoursuccess_url or cancel_url.
- Success URL: Use this page to show a “Payment Received” message. Do not fulfill the order yet. Statuses can still change (e.g., a capture could fail later).
- Placeholders: Use
{PAYMENT_ID}in your URL to know which order the user is returning from.
5. Secure Order Fulfillment (Webhooks)
This is the most critical step. Your server must listen for Fype webhooks to update your database and trigger fulfillment (shipping, digital access, etc.).- Receive the POST request: Listen on your configured webhook URL.
- Verify the Signature: Use the
X-Fype-Signatureand yourwhsec_secret. If invalid, return401. - Check the Event Type:
payment.succeeded: Mark the order as PAID in your DB.payment.failed: Notify the user or mark the order as FAILED.
- Acknowledge: Return a
200 OKresponse immediately to stop Fype from retrying.
6. Testing the Flow
- Use the Simulator: In the Fype Checkout page (Test Mode), click Simulate Success.
- Verify Webhook: Check your server logs to ensure the signature was verified and the database was updated.
- Verify Dashboard: Go to the Fype Dashboard and ensure the payment status shows as
Succeeded.
7. Moving to Production
- Switch Modes: Toggle to Live Mode in the Fype Dashboard.
- Connect Live Provider: Add your production Razorpay
Key IDandKey Secret. - Generate Live API Key: Use this key (
fype_live_...) in your production environment variables. - Live Webhook: Add your production webhook URL and update your
FYPE_WEBHOOK_SECRET.