Help & Support
The Fapshi API offers two powerful methods for collecting payments: Direct Pay and Initiate Pay. Each serves distinct use cases, balancing control, ease of integration, and user experience. This article breaks down the differences, benefits, and ideal scenarios for using Direct Pay and Initiate Pay, helping you choose the right approach for your application. Whether you're building a custom payment flow or need a quick solution, Fapshi's API has you covered. For more details, check the official Fapshi API documentation.
Understanding Direct Pay
Direct Pay allows developers to initiate payments directly from a user's mobile wallet without redirecting them to an external page. With this method, you have full control over the payment form and user experience, building a seamless checkout process within your application. However, this comes with the responsibility of handling validations, user input, and the payment flow on your end. The Fapshi backend processes the transaction, ensuring security and reliability, while you manage the front-end experience.
Key Features of Direct Pay
- Full Customization: Design the payment form to match your brand and user interface.
- No Redirects: Users stay within your app or website, creating a frictionless experience.
- Developer Responsibility: You handle input validation, error handling, and transaction status verification.
- Use Case Flexibility: Ideal for apps requiring tailored payment flows, such as in-app purchases or integrated checkout systems.
How It Works
- Your application collects payment details (e.g., phone number, amount) via a custom form.
- The app sends a payment request to Fapshi's API using your
apiuser
andapikey
for authentication. - Fapshi processes the request and prompts the user to confirm the transaction on their mobile wallet.
- Upon completion, you receive a
transId
(transaction ID) with a status code of 200 for successful requests or a 4XX code with an error message for failures. - You can use the
transId
to check the transaction status (SUCCESSFUL or FAILED) via the API or receive updates through a configured webhook.
Note: Direct Pay transactions do not expire, and their final state is either SUCCESSFUL or FAILED. Ensure secure handling of credentials, as misuse may lead to account suspension per Fapshi's Terms & Conditions.
Understanding Initiate Pay
Initiate Pay simplifies the payment process by providing a prebuilt, Fapshi-hosted checkout page. Users are redirected to this page to complete their payment, and Fapshi handles the entire payment flow, including validations and user prompts. This method is ideal for developers who want a quick, low-effort integration without building a custom payment interface.
Key Features of Initiate Pay
- Prebuilt Checkout: Fapshi provides a ready-to-use payment page, reducing development time.
- Simplified Integration: Minimal coding required—just generate a payment link and redirect users.
- Fapshi Handles Flow: The platform manages validations, user prompts, and transaction processing.
- Less Control: You rely on Fapshi's checkout design, which may limit customization.
How It Works
- Your application sends a payment request to Fapshi's API with details like the amount and user's phone number.
- Fapshi generates a unique payment link and returns it in the API response.
- You redirect the user to the Fapshi-hosted checkout page.
- The user completes the payment on their mobile wallet via the hosted page.
- Fapshi notifies you of the transaction status (SUCCESSFUL or FAILED) via a webhook (if configured) or through a status check using the
transId
.
Note: Like Direct Pay, Initiate Pay transactions are processed securely, and you must protect your API credentials to avoid misuse.
Comparing Direct Pay and Initiate Pay
Both methods leverage Fapshi's robust backend for secure payment processing, but they differ in control, complexity, and integration effort. Here's a detailed comparison:
Feature | Initiate Pay | Direct Pay |
---|---|---|
Checkout Experience | Fapshi-hosted checkout page | Fully customized, in-app/website |
Integration Effort | Low (use prebuilt payment link) | High (build and manage payment form) |
User Flow | Redirect to Fapshi's checkout page | No redirects, seamless in-app |
Customization | Limited to Fapshi's design | Complete control over UI/UX |
Responsibility | Fapshi handles validations and flow | Developer handles validations and flow |
Setup Time | Quick (minimal coding needed) | Longer (requires custom development) |
Transaction Status | SUCCESSFUL, FAILED, PENDING, EXPIRED via webhook/API | SUCCESSFUL or FAILED, checked via API |
Best Use Cases: When to Use Direct Pay vs. Initiate Pay
Choosing between Direct Pay and Initiate Pay depends on your application's needs, development resources, and desired user experience. The table below outlines the best scenarios for each method:
Scenario | Best Method | Why |
---|---|---|
E-commerce with branded checkout | Direct Pay | Seamlessly integrates payments into your website or app, matching your brand. |
In-app purchases | Direct Pay | Keeps users in the app, enhancing UX and reducing drop-off rates. |
Complex payment flows | Direct Pay | Allows custom validations and logic for unique business requirements. |
Quick setup for startups | Initiate Pay | Minimal development needed, ideal for rapid deployment. |
Low-budget projects | Initiate Pay | Reduces development costs by using Fapshi's prebuilt checkout page. |
Temporary payment campaigns | Initiate Pay | Easy to set up payment links for short-term or one-off campaigns. |
High-volume, low-customization | Initiate Pay | Efficient for businesses prioritizing speed over custom design. |
Pros and Cons
Direct Pay
Pros:
- Seamless user experience with no redirects.
- Full control over the payment form and branding.
- Flexible for complex or unique payment flows.
Cons:
- Requires more development effort to build and maintain the payment form.
- Developers are responsible for input validation and error handling.
- Higher risk of errors if not implemented correctly.
Initiate Pay
Pros:
- Quick and easy to integrate with minimal coding.
- Fapshi handles the entire payment flow, reducing developer workload.
- Ideal for rapid prototyping or small-scale projects.
Cons:
- Limited customization, as the checkout page follows Fapshi's design.
- Redirects may disrupt the user experience or increase drop-off rates.
- Less suitable for apps requiring a fully integrated payment process.
Getting Started
To implement either method, start by reviewing the Preliminary Knowledge section in the Fapshi API documentation. Ensure you have your apiuser
and apikey
ready for authentication, and test in the sandbox environment before going live. For Direct Pay, focus on building a secure, user-friendly payment form, and for Initiate Pay, generate and test payment links. If you encounter issues, contact support@fapshi.com or join the Fapshi Slack developer community for assistance.
Conclusion
Direct Pay and Initiate Pay cater to different needs in the payment integration spectrum. Direct Pay is best for developers who prioritise a tailored, in-app payment experience and have the resources to build and manage a custom checkout flow. Initiate Pay is perfect for those seeking a fast, low-effort solution with a prebuilt checkout page. By understanding your business requirements—such as customisation, development time, and user experience—you can choose the method that best aligns with your goals. Explore the Fapshi API documentation to dive deeper and start integrating today.