The integration of FedaPay into your application or website which only requires three steps, can start as soon as you create a FedaPay account:

  1. Get your API keys so that FedaPay can authenticate your API requests
  2. Install an API library so your integration can interact with FedaPay
  3. Test API requests to make sure everything is in place and working well


Step 1 : Get your API keys

FedaPay authenticates your requests using the API keys of your account. If you do not include your key when sending a request, or if you use an incorrect or old key, FedaPay will return an error.

Each account is provided with two keys : one for testing and one for live transactions. All requests through the API exist either in test or live mode, and objects (customers, transactions) in one mode cannot be manipulated by objects in the other mode.

Your API keys are available on the dashboard of your account. We include randomly generated API keys in our code examples. Replace them with yours.

Step 2: Install an API library

We provide libraries for different programming languages and mobile platforms.

The PHP library can be installed with Composer

composer require fedapay/fedapay-php

Install with npm

npm install fedapay
Consult the API documentation or the PHP source on GitHub.

Step 3: Test API requests

To verify that your integration is working properly, perform a test request through the API using your test secret key to create a transaction.

curl -X POST \
  https://sandbox.fedapay.com/v1/transactions \
  -H 'Authorization: Bearer YOUR_API_SECRET_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
        "description" : "Transaction for john.doe@example.com",
        "amount" : 2000,
        "currency" : {"iso" : "XOF"},
        "callback_url" : "https://mywebsite.com/callback",
        "customer" : {
            "firstname" : "John",
            "lastname" : "Doe",
            "email" : "john.doe@example.com",
            "phone_number" : {
                "number" : "+22997808080",
                "country" : "bj"
            }
          }
      }'
/* Replace YOUR_API_SECRET_KEY by your API secret key */
  \FedaPay\FedaPay::setApiKey("YOUR_API_SECRET_KEY");

  /* Specify whenever you are willing to execute your request in test or live mode */
  \FedaPay\FedaPay::setEnvironment('sandbox'); //or setEnvironment('live');

  /* Create the transaction */
  \FedaPay\Transaction::create(array(
    "description" => "Transaction for john.doe@example.com",
    "amount" => 2000,
    "currency" => ["iso" => "XOF"],
    "callback_url" => "https://mywebsite.com/callback",
    "customer" => [
        "firstname" => "John",
        "lastname" => "Doe",
        "email" => "john.doe@example.com",
        "phone_number" => [
            "number" => "+22997808080",
            "country" => "bj"
        ]
    ]
  ));
const { FedaPay, Transaction } = require('fedapay')

  /* Replace YOUR_API_SECRET_KEY by your API secret key */
  FedaPay.setApiKey("YOUR_API_SECRET_KEY");

  /* Specify whenever you are willing to execute your request in test or live mode */
  FedaPay.setEnvironment('sandbox'); //or setEnvironment('live');

  /* Create the transaction */
  const transaction = await Transaction.create({
    description: 'Description',
    amount: 2000,
    callback_url: 'https://mywebsite.com/callback',
    currency: {
        iso: 'XOF'
    },
    customer: {
        firstname: 'John',
        lastname: 'Doe',
        email: 'john.doe@example.com',
        phone_number: {
            number: '97808080',
            country: 'BJ'
        }
    }
  });
FedaPay returns a transaction object in response to your request..
{
  "v1/transaction": {
    "klass": "v1/transaction",
    "id": 7450,
    "transaction_key": null,
    "reference": "1530805389377",
    "amount": 2000,
    "description": "Transaction for john.doe@example.com",
    "callback_url": "https://feda-store.com/checkout",
    "status": "pending",
    "customer_id": 105,
    "currency_id": 1,
    "mode": null,
    "metadata": {},
    "created_at": "2018-07-05T15:43:09.377Z",
    "updated_at": "2018-07-05T15:43:09.377Z",
    "approved_at": null,
    "canceled_at": null,
    "declined_at": null,
    "refunded_at": null,
    "transferred_at": null
  }
}

Once you have successfully completed your request via the API, you are ready to integrate FedaPay.