Managing customers is an essential step when conducting transactions via the FedaPay platform. Each transaction is linked to a customer, so you must register and manage your customers in the system before initiating any transactions.
Creating a customer in FedaPay is done via an API request, allowing you to add the necessary information about your customer. This data is used during transactions to clearly identify the user.
When creating a customer, you need to provide the following information:
First Name (firstname): The customer’s first name.
Last Name (lastname): The customer’s last name.
Email (email): The customer’s email address, which will be used for all communications and confirmations.
Phone Number (phone_number): Optional, but helpful for certain transactions (must include the country code, e.g., +229 for Benin).
These details, except for the phone number, are mandatory. However, it is recommended to provide all information to enhance the tracking of customer interactions and payments.Example API Request for Creating a CustomerTo add a new customer, send a request to the FedaPay API. Below are examples in various programming languages:
Copy
const { FedaPay, Customer } = require('fedapay');/* Replace YOUR_SECRETE_API_KEY with your real API key */FedaPay.setApiKey("YOUR_SECRETE_API_KEY");/* Specify whether you want to run your query in test or live mode */FedaPay.setEnvironment('sandbox'); //or setEnvironment('live');/* Create customer */const customer = await Customer.create({ firstname: 'John', lastname: 'Doe', email: 'john@doe.com', phone_number: { number: '90090909', country: 'BJ' }});
To get a complete list of customers registered on your FedaPay account, send a simple request to the API. This allows you to view all available customers, review their details, and track their transactions.Example request to retrieve customers
Copy
const { FedaPay, Customer } = require('fedapay');/* Replace YOUR_SECRETE_API_KEY with your real API key */FedaPay.setApiKey("YOUR_SECRETE_API_KEY");/* Specify whether you want to run your query in test or live mode */FedaPay.setEnvironment('sandbox'); //or setEnvironment('live');/* Show customers */const customer = await Customer.all( params = {}, headers = {} );
Sometimes, you may need to update a customer’s information (e.g., an incorrect email address or phone number). To do this, provide the customer ID and the updated information.Example of Updating a Customer
Copy
const { FedaPay, Customer } = require('fedapay');/* Replace YOUR_SECRETE_API_KEY with your real API key */FedaPay.setApiKey("YOUR_SECRETE_API_KEY");/* Specify whether you want to run your query in test or live mode */FedaPay.setEnvironment('sandbox'); //or setEnvironment('live');/* Modify customer */const customer = await Customer.update(ID, params = {}, headers = {});
If a customer is no longer active or you wish to remove their data from your FedaPay account, you can use an API request to delete their information.Example of Deleting a Customer
Copy
const { FedaPay, Customer } = require('fedapay');/* Replace YOUR_SECRETE_API_KEY with your real API key */FedaPay.setApiKey("YOUR_SECRETE_API_KEY");/* Specify whether you want to run your query in test or live mode */FedaPay.setEnvironment('sandbox'); //or setEnvironment('live');/* Delete customer */const customer = await Customer.delete(ID, params = {}, headers = {});