Event Management

Events are important actions that occur within your FedaPay account, such as the creation of a transaction or an update to a customer. Understanding how these events work allows you to better manage your transactions and provide a better experience for your customers.

Whenever an event occurs, FedaPay notifies you in real-time through event notifications. These notifications can be used to track and react to what is happening within your account, such as when a payment is approved or when a customer is updated.

Transaction Lifecycle

Transactions on FedaPay follow a lifecycle, and each stage in this lifecycle generates a specific event. Here’s how it works:

  1. Transaction Creation : Once the customer is created, you can assign a transaction to them. This triggers the transaction.created event.

  2. Tracking Transactions : A transaction can evolve in several ways:

    • transaction.approved : The transaction has been approved, meaning the payment has been validated.

    • transaction.declined : The payment failed or was rejected.

    • transaction.canceled : The transaction was canceled before it was finalized.

    • transaction.transferred : The funds from the transaction have been transferred to the designated account (e.g., bank account or mobile money).

  3. Each time a status changes, a new event is generated to keep you informed. For example, once a transaction is updated, the transaction.updated event is triggered.

Customer Lifecycle

Customers can also have specific events:

  • customer.updated : The customer’s profile has been modified (e.g., their name or email address).

  • customer.deleted : The customer has been deleted from your account.

How to Use Events ?

Each event contains detailed information about what has just happened. You can view all these events in the Events section of your FedaPay dashboard, which gives you a complete history of all important actions in your account.

Why is it Important ?

Event management helps you to:

  • Track Payments : You are informed in real-time of the status of each transaction.

  • Manage Customers : You can track changes made to customer profiles.

  • Automate Processes : With event notifications, you can automate certain tasks on your site, like sending a confirmation email after a successful payment.

Introduction to Webhooks

Webhooks are automatic notifications that FedaPay sends to your application or website when significant events occur on your account. For example, you can receive a webhook when a transaction is successful or contested.

These notifications are particularly useful because they allow you to stay informed in real-time, without manually checking what’s happening on your FedaPay account.

Why Use Webhooks ?

Webhooks are essential for quickly being alerted to important actions on your account, such as:

  • Successful or failed payments

  • Refunds

  • Contested transactions

How Do Webhooks Work ?

Each time an event occurs (e.g., a successful payment), FedaPay creates an event object. This object contains all relevant information about the event, such as the event type (successful payment) and the associated details.

Then, FedaPay sends this object to your chosen URL (called an endpoint) via an HTTP request. It’s like FedaPay sending you a message to inform you of what just happened.

Configuring Webhooks

1

Create a Webhook

To receive webhooks, you need to configure a URL on your site that will receive these notifications. Here’s how to do it:

  1. Log in to your FedaPay account and go to the Webhooks section of your dashboard.

  2. Click Create a Webhook.

  3. Enter the URL of your site where you want to receive the notifications. It’s important that this page is ready to receive FedaPay notifications.

  4. Select the types of events you want to be notified about (e.g: successful payments, refunds).

  5. Click Create.

2

Manage Your Webhooks

Once your webhooks are created, you can:

  • Edit : Change the URL or the events you want to track.

  • Delete : If you no longer need the webhook, you can remove it.

  • View Details : You can see all the information about the webhook (URL, events tracked, etc.).

Webhook Signature Verification

To ensure that the notifications you receive are indeed from FedaPay (and not from a third party), FedaPay signs each event sent to your URL.

How to Verify the Signature ?

  1. When a webhook is sent, FedaPay includes a signature in the request header. This signature is named X-FEDAPAY-SIGNATURE.

  2. To verify that the message is authentic, you need to use your webhook’s secret key. You can retrieve this key from the settings in your dashboard.

  3. Use this secret key to verify the signature and ensure that the webhook was indeed sent by FedaPay.

Tools to Verify Signatures

To ensure that the Webhooks you receive are from FedaPay and have not been tampered with, it is essential to verify their signature. Fortunately, the official FedaPay libraries make this process much easier. Here is a code example showing how to verify the signature using these libraries in your projects: