### Install FedaPay React.js SDK using npm
Source: https://docs.fedapay.com/sdks/fr/reactjs-fr
This snippet shows the command to add the fedapay-reactjs library to your project using npm. Ensure you have Node.js and npm installed.
```bash
npm install fedapay-reactjs --save
```
--------------------------------
### Install FedaPay Libraries using Package Managers
Source: https://docs.fedapay.com/integration-api/fr/librairies-fr
Commands to install FedaPay libraries using standard package managers for Node.js, PHP, Ruby, React.js, and Angular. Ensure you have the respective package managers (npm, composer, gem) installed.
```bash
npm install fedapay --save
```
```bash
composer require fedapay/fedapay-php
```
```bash
$ gem install fedapay-ruby
```
```bash
npm install fedapay-reactjs --save
```
```bash
npm install fedapay-angular --save
```
--------------------------------
### Install FedaPay PHP SDK with Composer
Source: https://docs.fedapay.com/sdks/fr/php-fr
Installs the FedaPay PHP library using Composer, the standard dependency manager for PHP. Ensure Composer is installed and accessible in your environment.
```bash
composer require fedapay/fedapay-php
```
--------------------------------
### Install FedaPay Node.js SDK
Source: https://docs.fedapay.com/sdks/en/nodejs-en
Use npm to install the FedaPay Node.js library. This is the first step to integrate FedaPay payments into your server-side JavaScript applications.
```javascript
npm install fedapay --save
```
--------------------------------
### Create Customer with FedaPay Ruby SDK
Source: https://docs.fedapay.com/sdks/fr/ruby-fr
This example demonstrates how to create a new customer using the FedaPay Ruby SDK. It requires configuring the API key and environment, then providing customer details like name, email, and phone number.
```ruby
require 'fedapay';
# configure FedaPay library
FedaPay.api_key = '' # Your secret api key
FedaPay.environment = '' # sandbox or live
phone = {
country: 'bj',
number: '66000001'
};
customer = FedaPay::Customer.create(
firstname: 'firstname',
lastname: 'lastname',
email: 'email@test.com',
phone_number: phone
);
```
--------------------------------
### Generate Payment Token and Link using Ruby
Source: https://docs.fedapay.com/integration-api/fr/collects-management-fr
This Ruby snippet provides a complete example of configuring FedaPay, creating a transaction, generating a payment token, and obtaining the payment URL. Remember to replace placeholder API keys and environment settings.
```Ruby
require 'fedapay'
# Configure FedaPay API credentials
FedaPay.api_key = 'YOUR_SECRET_API_KEY'
FedaPay.environment = 'sandbox' # or 'live'
# Créer une transaction
transaction = FedaPay::Transaction.create(
amount: 1000,
currency: { iso: 'XOF' },
customer: { id: 1 },
description: 'Payment for order #1234',
callback_url: 'https://example.com/callback'
)
puts "Transaction successfully created: #{transaction.id}"
# Générer un token de paiement
token = transaction.generate_token
#Afficher le lien sécurisé de paiement
puts "Redirect user to: #{token.url}"
```
--------------------------------
### Install Angular SDK with npm
Source: https://docs.fedapay.com/sdks/fr/angular-fr
This command installs the FedaPay Angular SDK library using npm, making it available for use in your Angular project.
```typescript
npm install fedapay-angular --save
```
--------------------------------
### Install FedaPay Ruby Gem
Source: https://docs.fedapay.com/sdks/fr/ruby-fr
Add the FedaPay Ruby gem to your project's Gemfile to include the FedaPay SDK. This is the initial step for integrating FedaPay functionality into your Ruby applications.
```ruby
$ gem install fedapay-ruby
```
--------------------------------
### GET /currencies
Source: https://docs.fedapay.com/api-reference/currencies/get-all
Retrieves a list of all available currencies supported by FedaPay. This endpoint allows you to get detailed information about each currency, including their IDs, names, supported modes, prefixes, suffixes, and associated account details.
```APIDOC
## GET /currencies
### Description
Retrieves a list of all available currencies supported by FedaPay. This endpoint allows you to get detailed information about each currency, including their IDs, names, supported modes, prefixes, suffixes, and associated account details.
### Method
GET
### Endpoint
/currencies
### Parameters
#### Query Parameters
None
#### Request Body
None
### Response
#### Success Response (200)
- **id** (integer) - Balance ID.
- **name** (string) - Currency name.
- **modes** (array of strings) - Available modes for the currency.
- **prefix** (string) - Currency prefix.
- **suffix** (string) - Currency suffix.
- **account_id** (integer) - Account ID associated with the balance.
- **created_at** (string) - Date and time of balance creation.
- **updated_at** (string) - Date and time of last balance update.
- **default** (boolean) - Is this currency the default one?
#### Response Example
```json
[
{
"id": 1,
"name": "XOF",
"modes": ["Momo"],
"prefix": "CFA",
"suffix": "",
"account_id": 12345,
"created_at": "2023-01-01T10:00:00Z",
"updated_at": "2023-01-01T10:00:00Z",
"default": true
}
]
```
#### Error Response (401)
- **description**: Unauthorized. Provide a valid secret key.
```
--------------------------------
### Create a Customer with FedaPay Node.js SDK
Source: https://docs.fedapay.com/sdks/en/nodejs-en
Example of creating a customer using the FedaPay Node.js SDK. Requires setting the API key and environment. Input includes customer's first name, last name, email, and phone number with country code. Outputs a customer object.
```javascript
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'
}
});
```
--------------------------------
### PUT /v1/payouts/start - Start Deposit Transfer
Source: https://docs.fedapay.com/integration-api/fr/payouts-management-fr
Starts the transfer of a deposit that has been previously created and is marked as 'pending'. This endpoint allows for immediate or scheduled sending of the deposit.
```APIDOC
## PUT /v1/payouts/start
### Description
Starts the transfer of a deposit that has been previously created and is marked as 'pending'. This endpoint allows for immediate or scheduled sending of the deposit.
### Method
PUT
### Endpoint
https://sandbox-api.fedapay.com/v1/payouts/start
### Parameters
#### Request Body
- **payouts** (array) - Required - An array of payout objects to start.
- **id** (integer) - Required - The ID of the payout to start.
```
--------------------------------
### Create a Customer with FedaPay PHP SDK
Source: https://docs.fedapay.com/sdks/fr/php-fr
Demonstrates how to create a new customer using the FedaPay PHP SDK. This involves setting the API key, environment (sandbox or live), and providing customer details like name, email, and phone number.
```php
/* Remplacez YOUR_SECRETE_API_KEY par votre clé API secrète */
\FedaPay\FedaPay::setApiKey("YOUR_SECRETE_API_KEY");
/* Indiquez si vous souhaitez exécuter votre requête en mode test ou en live */
\FedaPay\FedaPay::setEnvironment('sandbox'); //or setEnvironment('live');
/* Créer un client */
\FedaPay\Customer::create(array(
"firstname" => "John",
"lastname" => "Doe",
"email" => "John.doe@gmail.com",
"phone_number" => [
"number" => "+22966666600",
"country" => 'bj' // 'bj' Benin code
]
));
```
--------------------------------
### GET /webhooks/{id}
Source: https://docs.fedapay.com/api-reference/webhooks/get-by-id
Retrieves the details of a specific webhook using its unique identifier. This endpoint is useful for inspecting the configuration and status of a particular webhook.
```APIDOC
## GET /webhooks/{id}
### Description
Retrieves the details of a specific webhook using its unique identifier.
### Method
GET
### Endpoint
/webhooks/{id}
### Parameters
#### Path Parameters
- **id** (integer) - Required - Webhook ID
### Request Example
```json
{
"example": "No request body needed for GET request."
}
```
### Response
#### Success Response (200)
- **id** (integer) - Webhook ID.
- **url** (string) - URL of the request.
- **enabled** (boolean) - Indicates whether the webhook is active.
- **ssl_verify** (boolean) - Indicates whether SSL verification is enabled for the webhook.
- **disable_on_error** (boolean) - the webhook will be disabled after encountering an error.
- **account_id** (integer) - ID of the webhook account
- **http_headers** (boolean) - Indicates whether custom HTTP headers are used
- **created_at** (string) - Date and time of webhook creation
- **updated_at** (string) - Date and time of last webhook update
#### Response Example
```json
{
"id": 123,
"url": "https://example.com/webhook",
"enabled": true,
"ssl_verify": true,
"disable_on_error": false,
"account_id": 456,
"http_headers": false,
"created_at": "2023-10-27T10:00:00Z",
"updated_at": "2023-10-27T10:00:00Z"
}
```
#### Error Responses
- **401**: Unauthorized. Provide a valid secret key.
- **404**: Webhook not found.
```
--------------------------------
### Ajouter plusieurs boutons de paiement avec Checkout.js
Source: https://docs.fedapay.com/introduction/fr/checkoutjs-fr
Ce snippet illustre comment intégrer plusieurs boutons de paiement sur une même page en utilisant Checkout.js. Chaque bouton peut être configuré avec des montants et descriptions de transaction différents via des attributs data. Le script initialise tous les boutons correspondant à un sélecteur donné.
```javascript
Intégrer Feda Checkout à mon site
```
--------------------------------
### Créer un Dépôt avec l'API FedaPay
Source: https://docs.fedapay.com/integration-api/fr/payouts-management-fr
Cet extrait de code montre comment initier la création d'un dépôt via l'API FedaPay. Il prend en entrée le montant, la devise, et les informations du client. Les exemples couvrent Curl, Node.js, PHP et Ruby.
```curl
curl -X POST https://sandbox-api.fedapay.com/v1/payouts -H 'Authorization: Bearer TOKEN' -H 'Content-Type: application/json' -d '{ "amount" : 2000, "currency" : {"iso" : "XOF"}, "mode": "mtn_open" "customer" : { // obligatoire. "firstname" : "John", "lastname" : "Doe", "email" : "john.doe@example.com", "phone_number" : { "number" : "+22997808080", "country" : "bj" } } }'
```
```javascript
const { FedaPay, Payout } = require('fedapay');
FedaPay.setApiKey('YOUR_API_KEY');
FedaPay.setEnvironment('sandbox');
const payout = await Payout.create(
{
amount: 2000,
currency: { iso: "XOF" },
mode: "mtn_open", // Non obligatoire. FedaPay détectera l'operateur sinon.
customer: { // obligatoire.
firstname: "John",
lastname: "Doe",
email: "john.doe@example.com",
phone_number: {
number: "+22997808080",
country: "bj",
},
},
});
```
```php
\FedaPay\Fedapay::setApiKey(MY_API_KEY);
\FedaPay\Payout::create([
"amount" => 2000,
"currency" => ["iso" => "XOF"],
"mode" => "mtn_open", // Non obligatoire. FedaPay détectera l'operateur sinon.
"customer" => [ // Non obligatoire.
"firstname" => "John",
"lastname" => "Doe",
"email" => "john.doe@example.com",
"phone_number" => [
"number" => "+22997808080",
"country" => "bj",
],
],
]);
```
```ruby
require 'fedapay';
FedaPay.api_key = '';
FedaPay.environment = 'sandbox';
currency = { iso: 'XOF' };
payout = FedaPay::Payout.create({
amount: 1000,
currency: currency,
mode: "mtn_open", // Non obligatoire. FedaPay détectera l'operateur sinon.
customer: { // Non obligatoire.
firstname: "John",
lastname: "Doe",
email: "john.doe@example.com",
phone_number: {
number: "+22997808080",
country: "bj",
},
},
});
```
--------------------------------
### Manage FedaPay Payouts (Node.js, PHP, Ruby)
Source: https://docs.fedapay.com/integration-api/fr/payouts-management-fr
This snippet demonstrates how to manage FedaPay payouts using the SDK. It covers creating payouts, sending them instantly, scheduling them for a future date, and performing batch operations like scheduling all or sending all now. The examples show how to specify recipient phone numbers for payouts not associated with the customer.
```javascript
const payout = await Payout.create({...});
// Envoi du dépôt maintenant
await payout.sendNow();
// Envoi d'un dépôt sur numéro de téléphone autre que celui du customer
await payout.sendNow({
phone_number: {
number: "64000001",
country: "BJ"
}
});
// Envoi du dépôt plus tard
await payout.schedule("2024-11-18 18:8:43");
// Programmer un dépôt pour plus tard mais sur un autre numéro autre
// que celui du customer
await payout.schedule("2024-11-18 18:8:43", {
phone_number: {
number: "64000001",
country: "BJ"
}
});
// Programmer plusieurs envois
await Payout.scheduleAll([
{
id: 23, // Envoie le dépôt instantanément
scheduled_at: "2024-11-18 18:8:43" // Envoie le dépôt plus tard
},
{
id: 24, // Envoie le dépôt instantanément
scheduled_at: "2024-11-18 18:8:43" // Envoie le dépôt plus tard
},
{
id: 25,
scheduled_at: "2024-11-18 18:8:43",
phone_number: {
number: "64000001",
country: "BJ"
}
}
]);
// Envoyer tous les dépôts instantanément
await Payout.sendAllNow([
{ id: 23 },
{ id: 24 },
{
id: 24,
phone_number: {
number: "64000001",
country: "BJ"
}
}
]);
```
```php
$payout = \FedaPay\Payout::create(array(...));
// Envoi du dépôt maintenant
$payout->sendNow();
// Envoi d'un dépôt sur numéro de téléphone autre que celui du customer
$payout->sendNow([
"phone_number" => [
"number" => "64000001",
"country" => "BJ"
]
]);
// Programmer un dépôt pour plus tard
$payout->schedule("2024-11-18 18:8:43");
// Programmer un dépôt pour plus tard mais sur un autre numéro autre
// que celui du customer
$payout->schedule("2024-11-18 18:8:43", [
"phone_number" => [
"number" => "64000001",
"country" => "BJ"
]
]);
// Programmer plusieurs envoies
Payout::scheduleAll([
[
"id" => 23 // Envoie le dépôt instantanément
],
[
"id" => 24,
"scheduled_at" => "2024-11-18 18:8:43" // Envoie le dépôt plus tard
],
[
"id" => 25,
"scheduled_at" => "2024-11-18 18:8:43",
"phone_number" => [
"number" => "64000001",
"country" => "BJ"
]
]
]);
// Envoyer tous les paiements instantanément
Payout::sendAllNow([
[ "id" => 23 ],
[ "id" => 24 ],
[
"id" => 24,
"phone_number" => [
"number" => "64000001",
"country" => "BJ"
]
]
]);
```
```ruby
payout = FedaPay::Payout.create({...});
# Envoi du dépôt maintenant
payout.sendNow();
# Envoi d'un dépôt sur numéro de téléphone autre que celui du customer
payout.sendNow({
phone_number: {
number: "64000001",
country: "BJ"
}
});
# Envoi du dépôt plus tard
payout.schedule("2024-11-18 18:8:43");
# Programmer un dépôt pour plus tard mais sur un autre numéro autre
# que celui du customer
payout.schedule("2024-11-18 18:8:43", {
phone_number: {
number: "64000001",
country: "BJ"
}
});
# Programmer plusieurs envois
FedaPay::Payout.scheduleAll([
{
id: 23, # Envoie le dépôt instantanément
scheduled_at: "2024-11-18 18:8:43" # Envoie le dépôt plus tard
},
{
id: 24, # Envoie le dépôt instantanément
scheduled_at: "2024-11-18 18:8:43" # Envoie le dépôt plus tard
},
{
id: 25,
scheduled_at: "2024-11-18 18:8:43",
phone_number: {
number: "64000001",
country: "BJ"
}
}
]);
# Envoyer tous les dépôts instantanément
FedaPay::Payout.sendAllNow([
```
--------------------------------
### Get All Currencies OpenAPI Specification
Source: https://docs.fedapay.com/api-reference/currencies/get-all
This OpenAPI 3.0 specification defines the GET /currencies endpoint. It outlines the request method, path, authentication requirements (bearer token), and detailed response schemas for a successful retrieval (200 OK) and unauthorized access (401 Unauthorized). The response includes currency details such as ID, name, modes, prefixes, suffixes, associated account ID, creation/update timestamps, and a default flag.
```yaml
openapi: 3.0.0
info:
title: Customer API
version: v1
servers:
- url: https://sandbox-api.fedapay.com/v1
- url: https://api.fedapay.com/v1
security: []
paths:
/currencies:
get:
summary: Get all currencies
responses:
'200':
description: List of currencies
content:
application/json:
schema:
type: array
items:
type: object
properties:
id:
type: integer
description: Balance ID.
name:
type: string
description: Currency name.
modes:
type: array
items:
type: string
description: Available modes for the currency
prefix:
type: string
description: Currency prefix.
suffix:
type: string
description: Currency suffix.
account_id:
type: integer
description: Account ID associated with the balance
created_at:
type: string
format: date-time
description: Date and time of balance creation.
updated_at:
type: string
format: date-time
description: Date and time of last balance update.
default:
type: boolean
description: Is this currency the default one?
'401':
description: Unauthorized. Provide a valid secret key.
security:
- bearerAuth: []
components:
securitySchemes:
bearerAuth:
type: http
scheme: bearer
bearerFormat: JWT
```
--------------------------------
### Get Webhook by ID (OpenAPI)
Source: https://docs.fedapay.com/api-reference/webhooks/get-by-id
This OpenAPI 3.0 specification defines the endpoint for retrieving a specific webhook by its ID. It details the path parameters, expected response formats for success (200) and error codes (401, 404), and the security scheme using JWT Bearer authentication.
```yaml
openapi: 3.0.0
info:
title: Customer API
version: v1
servers:
- url: https://sandbox-api.fedapay.com/v1
- url: https://api.fedapay.com/v1
security: []
paths:
/webhooks/{id}:
get:
summary: Get a webhook
parameters:
- in: path
name: id
schema:
type: integer
required: true
description: Webhook ID
responses:
'200':
description: List of webhook
content:
application/json:
schema:
type: array
items:
type: object
properties:
id:
type: integer
description: Webhook ID.
url:
type: string
description: URL of the request.
enabled:
type: boolean
description: Indicates whether the webhook is active.
ssl_verify:
type: boolean
description: >-
Indicates whether SSL verification is enabled for the
webhook.
disable_on_error:
type: boolean
description: >-
the webhook will be disabled after encountering an
error.
account_id:
type: integer
description: ID of the webhook account
http_headers:
type: boolean
description: Indicates whether custom HTTP headers are used
created_at:
type: string
format: date-time
description: Date and time of webhook creation
updated_at:
type: string
format: date-time
description: Date and time of last webhook update
'401':
description: Unauthorized. Provide a valid secret key.
'404':
description: Webhook not found.
security:
- bearerAuth: []
components:
securitySchemes:
bearerAuth:
type: http
scheme: bearer
bearerFormat: JWT
```
--------------------------------
### Vérifier les signatures de webhooks avec Node.js et PHP
Source: https://docs.fedapay.com/integration-api/fr/webhooks-fr
Exemples de code pour vérifier les signatures des webhooks FedaPay en utilisant les bibliothèques officielles. Ce processus est crucial pour s'assurer que les requêtes proviennent bien de FedaPay et n'ont pas été altérées. Il utilise la clé secrète du point de terminaison pour valider l'en-tête 'X-FEDAPAY-SIGNATURE'.
```javascript
const { Webhook } = require('fedapay')
// You can find your endpoint's secret key in your webhook settings
const endpointSecret = 'wh_sandbox...';
// This example uses Express to receive webhooks
const app = require('express')();
// Use body-parser to retrieve the raw body as a buffer
const bodyParser = require('body-parser');
// Match the raw body to content type application/json
app.post('/webhook', bodyParser.raw({type: 'application/json'}), (request, response) => {
const sig = request.headers['x-fedapay-signature'];
let event;
try {
event = Webhook.constructEvent(request.body, sig, endpointSecret);
} catch (err) {
response.status(400).send(`Webhook Error: ${err.message}`);
}
// Handle the event
switch (event.name) {
case 'transaction.created':
// Transaction créée
break;
case 'transaction.approved'':
// Transaction approuvée
break;
case 'transaction.canceled'':
// Transaction annulée
break;
default:
console.log(`Unhandled event type ${event.type}`);
}
// Return a response to acknowledge receipt of the event
response.json({received: true});
});
app.listen(4242, () => console.log('Running on port 4242'));
```
```php
// You can find your endpoint's secret key in your webhook settings
$endpoint_secret = 'wh_dev.......';
$payload = @file_get_contents('php://input');
$sig_header = $_SERVER['HTTP_X_FEDAPAY_SIGNATURE'];
$event = null;
try {
$event = FedaPayWebhook::constructEvent(
$payload, $sig_header, $endpoint_secret
);
} catch(UnexpectedValueException $e) {
// Invalid payload
http_response_code(400);
exit();
} catch(FedaPayErrorSignatureVerification $e) {
// Invalid signature
http_response_code(400);
exit();
}
// Handle the event
switch ($event->name) {
case 'transaction.created':
// Transaction créée
break;
case 'transaction.approved':
// Transaction approuvée
break;
case 'transaction.canceled':
// Transaction annulée
break;
default:
http_response_code(400);
exit();
}
http_response_code(200);
```
--------------------------------
### GET /websites/fedapay/payouts/{payout_id}
Source: https://docs.fedapay.com/api-reference/payouts/update
Retrieves the details of a specific payout, including its status, associated IDs, and timestamps.
```APIDOC
## GET /websites/fedapay/payouts/{payout_id}
### Description
Retrieves the details of a specific payout, including its status, associated IDs, and timestamps.
### Method
GET
### Endpoint
/websites/fedapay/payouts/{payout_id}
### Parameters
#### Path Parameters
- **payout_id** (integer) - Required - The unique identifier of the payout.
### Response
#### Success Response (200)
- **id** (integer) - Unique identifier for the payout.
- **amount** (integer) - The amount of the payout.
- **currency** (string) - The currency of the payout (e.g., 'EUR').
- **status** (string) - The current status of the payout (e.g., 'pending', 'paid', 'failed').
- **created_at** (string) - Date and time the payout was created.
- **sent_at** (string) - Date and time the payout was sent.
- **failed_at** (string) - Date and time the payout failed.
- **deleted_at** (string) - Date and time of payout deletion.
- **metadata** (object) - Additional metadata related to the payout.
- **custom_metadata** (object) - Custom metadata associated with the payout.
- **payment_method_id** (integer) - Payment method ID used for the payout.
- **transaction_key** (string) - Unique key associated with the payout.
- **merchant_reference** (string) - Merchant reference provided for the payout.
- **account_id** (integer) - Account ID associated with the payout.
- **balance_id** (integer) - Balance ID associated with the payout.
#### Response Example
```json
{
"id": 12345,
"amount": 10000,
"currency": "EUR",
"status": "paid",
"created_at": "2023-10-27T10:00:00Z",
"sent_at": "2023-10-27T10:05:00Z",
"failed_at": null,
"deleted_at": null,
"metadata": {},
"custom_metadata": {},
"payment_method_id": 67890,
"transaction_key": "txn_abc123",
"merchant_reference": "MERCHREF456",
"account_id": 11223,
"balance_id": 44556
}
```
#### Error Responses
- **400** - Invalid request body.
- **404** - Payout not found.
```
--------------------------------
### Create Transaction with Custom Metadata (PHP)
Source: https://docs.fedapay.com/integration-api/fr/collects-management-fr
This PHP example shows how to create a transaction and include custom metadata using the FedaPay PHP SDK. It involves configuring the API key and environment, then using the `FedaPayTransaction::create` method with transaction data and a `custom_metadata` array.
```php
// Configurer la clé API et l'environnement
\FedaPay\FedaPay::setApiKey('YOUR_SECRET_API_KEY');
\FedaPay\FedaPay::setEnvironment('sandbox'); // ou 'live'
// Créer une transaction avec custom_metadata
$transaction = \FedaPay\Transaction::create([
"description" => "Abonnement premium",
"amount" => 10000,
"currency" => ["iso" => "XOF"],
"callback_url" => "https://votreapp.com/callback",
"customer" => [
"email" => "utilisateur@votreapp.com"
],
"custom_metadata" => [
"client_id" => "USER-14567",
"forfait" => "premium",
"langue" => "fr"
]
]);
echo "Transaction created: " . $transaction->id;
```
--------------------------------
### GET /transactions/{id}
Source: https://docs.fedapay.com/api-reference/transactions/get-by-id
Retrieves a specific transaction by its ID. This endpoint allows you to fetch detailed information about a single transaction.
```APIDOC
## GET /transactions/{id}
### Description
Retrieves a specific transaction by its ID. This endpoint allows you to fetch detailed information about a single transaction.
### Method
GET
### Endpoint
/transactions/{id}
### Parameters
#### Path Parameters
- **id** (integer) - Required - Transaction ID.
### Response
#### Success Response (200)
- **id** (integer) - Transaction ID.
- **reference** (string) - Transaction reference.
- **amount** (integer) - Transaction amount.
- **description** (string) - Transaction description.
- **callback_url** (string) - Transaction callback URL.
- **status** (string) - Transaction status (e.g., 'pending', 'approved', 'canceled').
- **customer_id** (integer) - Customer ID associated with the transaction.
- **currency_id** (integer) - Currency ID associated with the transaction.
- **mode** (string) - Transaction mode.
- **metadata** (object) - Additional metadata related to the transaction.
- **commission** (integer) - Transaction commission.
- **fees** (integer) - Transaction fees.
- **fixed_commission** (integer) - Fixed commission applied to the transaction.
- **amount_transferred** (integer) - Amount transferred to the beneficiary.
- **created_at** (string) - Date and time of transaction creation.
- **updated_at** (string) - Date and time of last transaction update.
- **approved_at** (string) - Date and time of transaction approval.
- **canceled_at** (string) - Date and time of transaction cancellation.
- **declined_at** (string) - Date and time of transaction decline.
- **refunded_at** (string) - Date and time of transaction refund.
- **transferred_at** (string) - Date and time of transaction transfer.
- **deleted_at** (string) - Date and time of transaction deletion.
- **last_error_code** (string) - Last error code encountered during the transaction.
- **custom_metadata** (object) - Custom metadata associated with the transaction.
- **amount_debited** (integer) - Amount debited from the payer.
- **receipt_url** (string) - URL to the transaction receipt.
- **payment_method_id** (integer) - Payment method ID used for the transaction.
- **sub_accounts_commissions** (array) - Commissions applied to sub-accounts.
- **transaction_key** (string) - Unique key associated with the transaction.
- **merchant_reference** (string) - Merchant reference.
#### Response Example
```json
{
"id": 12345,
"reference": "REF12345",
"amount": 10000,
"description": "Payment for service",
"callback_url": "https://example.com/callback",
"status": "approved",
"customer_id": 6789,
"currency_id": 1,
"mode": "test",
"metadata": {},
"commission": 100,
"fees": 50,
"fixed_commission": 0,
"amount_transferred": 9850,
"created_at": "2023-10-27T10:00:00Z",
"updated_at": "2023-10-27T10:05:00Z",
"approved_at": "2023-10-27T10:02:00Z",
"canceled_at": null,
"declined_at": null,
"refunded_at": null,
"transferred_at": "2023-10-27T10:05:00Z",
"deleted_at": null,
"last_error_code": null,
"custom_metadata": {},
"amount_debited": 10000,
"receipt_url": "https://sandbox-api.fedapay.com/receipt/12345",
"payment_method_id": 10,
"sub_accounts_commissions": [],
"transaction_key": "txn_abc123",
"merchant_reference": "MERCH-REF-XYZ"
}
```
```
--------------------------------
### Déclencher la collecte de paiement avec un événement JavaScript avec Checkout.js
Source: https://docs.fedapay.com/introduction/fr/checkoutjs-fr
Ce code montre comment déclencher le formulaire de paiement Checkout.js via un événement JavaScript, comme un clic sur un bouton. Au lieu d'initialiser le paiement directement sur le bouton, on initialise le widget FedaPay et on ouvre le formulaire à la demande en utilisant la méthode `open()`.
```javascript
Intégrer Feda Checkout à mon site
```