Create deposits

A deposit is a trasnfer you make to a customer account from your balance. The creation of a deposit is done in several processes.

1 - Request to create a deposit

You must first send a request to create a deposit via the API. This request must contain the parameters such as the deposit amount, the currency to be used, the transfer method (MTN Benin, MTN Ivory Coast, Moov Benin, , Moov Togo and Togocel are currently supported), the information of the customer concerned by this operation.
So you have :

  • amount : define the deposit amount. This amount must always be an integer
  • currency : specify the currency to use for deposit
  • For this attribute, either the ISO number or the ISO must be indicated. Refer to the table of available currencies.

  • customer : specify the customer with whom the deposit must be made

At this step, you have the possibility to create along with the transaction, a new customer to whom it will be automatically assigned this transaction if you have not registered him previously.
In this case you must provide last name, first name, e-mail and telephone number.
Use the code below to address your request via the API.

curl -X POST \
https://sandbox-api.fedapay.com/v1/payouts \
-H 'Authorization: Bearer YOUR_API_SECRET_KEY' \
-H 'Content-Type: application/json' \
-d '{
      "amount" : 2000,
      "currency" : {"iso" : "XOF"},
      "mode": "mtn"
      "customer" : {
          "firstname" : "John",
          "lastname" : "Doe",
          "email" : "[email protected]",
          "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 a deposit */
\FedaPay\Payout::create(array(
  "amount" : 2000,
  "currency" : {"iso" : "XOF"},
  "mode": "mtn"
  "customer" => [
      "firstname" => "John",
      "lastname" => "Doe",
      "email" => "[email protected]",
      "phone_number" => [
          "number" => "+22997808080",
          "country" => "bj"
      ]
  ]
));
const { FedaPay, Payout } = 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 a deposit */
const payout = await Payout.create({
  "amount" : 2000,
  "currency" : {"iso" : "XOF"},
  "mode": "mtn"
  "customer" : {
      "firstname" : "John",
      "lastname" : "Doe",
      "email" : "[email protected]",
      "phone_number" : {
          "number" : "+22997808080",
          "country" : "bj"
      }
  }
});

If your customer is already listed, just give in parameter his identifier (ID) or his email.
Your customer ID and email can be found on your dashboard in customer details.

curl -X POST \
https://sandbox-api.fedapay.com/v1/payouts \
-H 'Authorization: Bearer YOUR_API_SECRET_KEY' \
-H 'Content-Type: application/json' \
-d '{
      "amount" : 2000,
      "currency" : {"iso" : "XOF"},
      "mode": "mtn",
      "customer" : {
          "email" : "[email protected]",
        }
    }'
/* 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'); //ou setEnvironment('live');

/* Create a deposit */
\FedaPay\Payout::create(array(
  "amount" => 2000,
  "mode" => "mtn",
  "currency" => ["iso" => "XOF"],
  "customer" => [
    "email" => "[email protected]" /* ou "id" => 105 */
  ]
));
const { FedaPay, Payout } = 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'); //ou setEnvironment('live');

/* Create a deposit */
const payout = await Payout.create({
  description: 'Description',
  amount: 2000,
  mode: "mtn",
  currency: {
      iso: 'XOF'
  },
  customer: {
      email: '[email protected]' /* or id: 105 */
  }
});

2- Sending a deposit

At this point, the deposit you have created is waiting to be sent. You will have to proceed to the transfer. To send a deposit, you can send it at a later time or send it immediately.

Use the code below to address your request via the API

curl -X PUT \
https://sandbox-api.fedapay.com/v1/payouts/start \
-H 'Authorization: Bearer YOUR_API_SECRET_KEY' \
-H 'Content-Type: application/json'
-d '{
      "payouts" : [
        { "id": 23 },
        { "id": 24 , "scheduled_at": "{now}"}
      ]
    }'
$payout = \FedaPay\Payout::create(array(...));
// Proceed to the deposit now
$payout->sendNow();
 // Proceed to the deposit later
$payout->schedule("{now}");
// Schelude many deposits
Payout::scheduleAll([
    [
        "id" => 23 // Proceed to the deposit instantly
    ],
    [
        "id" => 24,
        "scheduled_at" => "{now}" // Proceed to the deposit later
    ]
]);
// Proceed to all deposits instantly
Payout::sendAllNow([
    [ "id" => 23 ],
    [ "id" => 24 ]
]);
const payout = await Payout.create({...});
// Proceed to the deposit now
await payout.sendNow();
// Proceed to the deposit later
await payout.schedule("{now}");
// Schelude many deposits
await Payout.scheduleAll([
    {
        id: 23,
        scheduled_at: "{now}"
    },
    {
        id: 24,
        scheduled_at: "{now}"
    }
]);
// Proceed to all deposits instantly
await Payout.sendAllNow([
    { id: 23 },
    { id: 24 }
]);
3- Retrieve the details of a deposit

To retrieve information about a given deposit, and do some treatment with it, proceed as follows

curl -X GET \
https://sandbox-api.fedapay.com/v1/payouts/ID \
-H 'Authorization: Bearer YOUR_API_SECRET_KEY' \
-H 'Content-Type: application/json'
$payout = \FedaPay\Payout::retrieve(ID);
if ($payout->status == "sent") {
    echo "Deposit well done";
}
const payout = await Payout.retrieve(ID);
if (payout.status == "sent") {
    console.log("Deposit well done");
}

Deposits lifecycle

When you create a deposit, it goes through different states or statuses just like transactions.

    These statuses are :
  • pending: Pending.
  • started: Started. This is the status of a deposit when the transfer has started.
  • processing: Processing. In the process of sending. This is the status when the system is sending to the customer.
  • sent:Sent. This is the status when the deposit is sent successfully.
  • failed: Failed. This is the status when the transfer has failed.

Initially, when you create a deposit, it is in Pending. This is the default status.
The deposit will pass to Started when the transfer will have started.

It will pass to Processing when the system will be sending to the customer.

It will be Sent when the deposit will be sent successfully.

Failed when the transfer will have failed for several reasons.

You can always check the status of each of your deposits on your FedaPay dashboard in the Payments menu to follow their progress.

On this page