Skip to main content

Overview

This guide will walk you through integrating the FLEX Merchant API into your application. By the end, you’ll be able to create payment requests, generate QR codes, and manage transactions.
Estimated Time: 30-45 minutesPrerequisites:
  • API credentials (client ID, API key, location ID)
  • Development environment set up
  • Basic understanding of REST APIs

Integration Steps

1

Set Up Your Environment

Configure your development environment with the necessary credentials and dependencies.
2

Verify PayTag

Implement PayTag verification to ensure customers exist before creating payment requests.
3

Create Payment Request

Build the core functionality to create payment requests for your customers.
4

Track Payment Status

Implement status tracking to monitor payment request lifecycle.
5

Handle Edge Cases

Add error handling and edge case management.
6

Test & Go Live

Test thoroughly in staging, then deploy to production.

Step 1: Set Up Your Environment

Install Dependencies

Configure Environment Variables

Create a .env file in your project root:
.env
Add .env to your .gitignore file to prevent committing sensitive credentials!

Create API Client


Step 2: Verify PayTag

Before creating a payment request, verify that the customer’s PayTag exists and is valid.
Expected Response:

Step 3: Create Payment Request

Now create a payment request for your verified customer.
Expected Response:
Payment requests expire after the specified duration (default: 30 minutes). Customers must complete payment before expiration.

Step 4: Track Payment Status

Implement functionality to check payment request status and retrieve payment history.

Get Single Payment Request

List All Payment Requests


Step 5: Handle Edge Cases

Cancel Payment Request

Error Handling Best Practices


Step 6: Generate QR Codes (Optional)

Generate QR codes for quick payment collection.

Step 7: Test & Go Live

Testing Checklist

  • All API requests include correct headers
  • Credentials are stored securely in environment variables
  • 401 errors are handled gracefully
  • PayTag verification works correctly
  • Payment requests are created successfully
  • Payment status can be retrieved
  • Payment cancellation works
  • Pagination works for payment lists
  • Invalid PayTags are handled
  • Network errors are caught and logged
  • Invalid amounts are rejected
  • Expired payments are handled
  • Duplicate references are prevented
  • Large amounts are tested
  • Currency switching works (NGN/FP)
  • Metadata is properly stored and retrieved

Go Live Checklist

1

Complete Staging Tests

Ensure all features work correctly in the staging environment
2

Update Environment Variables

Switch FLEXPAY_BASE_URL to production: https://api.yourflexpay.com/v2
3

Request Production Credentials

Contact FLEX to receive your production API credentials
4

Enable Monitoring

Set up logging and monitoring for API requests and errors
5

Deploy to Production

Deploy your integration and monitor closely for the first few transactions

Complete Example Application

Here’s a complete working example:

Next Steps

API Reference

Explore detailed API endpoint documentation

Overview

Merchant API overview

OpenAPI Spec

Complete API specification

Need Help?