Payfonte Direct Charge API

The Payfonte direct charge API allows you to call some providers API directly from your backend application without using a checkout session. Here is how it works:

  • Optional From your infrastructure/application, call our Fetch Provider Payment Properties to get the additional the for the API call.
  • Make a call to our direct charge API with the payment details
  • Once the transaction is complete, We will send a webhook response to your webhook URL.

1. Get Payment Provider Properties [Optional for Some providers]

if you are using a provider that expects some addition properties for a direct call, this API will return what you need to make that decision. Example is Orange Senegal, Pawapay. You can find a list of providers that you need to fetch properties for in the Supported Providers Section. Find a Sample CURL Below to fetch provider properties:

curl --location 'https://sandbox-api.payfonte.com/payments/v1/payments/direct-charge/{{provider-slug}}/properties' \
--header 'client-id: <client-id>' \
--header 'client-secret: <client-secret>'

Here is a sample response for pawapay

{
  "data": {
    "networks": [
      {
        "name": "Airtel",
        "image": "https://pbs.twimg.com/profile_images/1422229945317744642/1f6bLEh__400x400.jpg",
        "value": "airtel"
      },
      {
        "name": "MTN MoMo",
        "image": "https://seeklogo.com/images/M/mtn-logo-40644FC8B0-seeklogo.com.png",
        "value": "mtn-momo"
      }
    ]
  }
}

2. Get all the payment details

First, you need to assemble the payment details. Here are the details you’ll need:

FieldTypeDescriptionRequired
providerString [Provider Slug]This is the Provider we are routing the request to. e.g mtn-momo-ivory-coastfalse
amountNumberThis is the amount to charge the customer. This should be in the lowest currency denominationfalse
referenceStringA reference code you’ll generate to identify this transaction. This must be unique for every transaction. If you don’t pass one, we will generate one for you.False
redirectURLStringThe URL to which the customer should be redirected after the payment is completed.False
webhookStringThis is a URL, if this is passed we will send the event webhook payload to this endpoint
customerInputObjectThis is an object of inputs to be passed to the provider. This varies per provider. You can find more in the Examples Section.True
narrationStringThis is the transaction descriptionFalse

3. Call the endpoint to initialize the Direct Charge

Next, in order to initiate the payment process, you will need to call our Direct Charge API API and provide the collected payment details. Please ensure that you authorize the API call using your client-id and client-secret. Below is an example in CURL:

curl --location 'https://sandbox-api.payfonte.com/payments/v1/payments/direct-charge' \
--header 'client-id: <client-id>' \
--header 'client-secret: <client-secret>' \
--header 'Content-Type: application/json' \
--data '{
    "reference": "9617a32a-e936-48b4-99bd-f0fcd882561c",
    "amount": 10000,
    "provider": "mtn-momo-ivory-coast",
    "webhook": "https://webhook.site/9e5c6a7c-3345-4e7a-8e05-f6c4cc61f4a0",
    "narration": "Test payment from payfonte",
    "customerInput": {
        "phoneNumber": "8023456789"
    }
}'

After making the API call, you will receive a response similar to this:

{
  "data": {
    "sessionId": "e0b04887-ee15-40ba-a3c0-5efc8b207292",
    "provider": "mtn-momo-ivory-coast",
    "reference": "D20240612202245CGOCK",
    "amount": 10000,
    "status": "initialized",
    "statusDescription": "Awaiting Customer Input",
    "amountLabel": "NGN 100.00",
    "chargeLabel": "NGN 0.00"
  },
  "statusCode": 201
}

4. After the payment

This following event will occur after a payment is completed

  1. If you have webhooks enabled, we will send you a notification via webhook once the payment is completed. To learn more about webhooks and see examples, please visit the following link Webhooks.