Credit an Account
This endpoint allows you to credit a specified amount to a customer's account.
Method
- POST
URL
- /operations/credit
Input
The input data for this operation should be provided in the request body as a JSON object:
{
"amount": "Amount of the operation",
"reason": "Reason for doing this operation",
"idType": "Type of the identity document presented during the operation",
"idNumber": "Number of the identity document presented during the operation",
"cardExpiration": "Expiration date of the identity document presented during the operation",
"partnerReference": "Unique reference generated by API user",
"customer": {
"phone": "Customer's phone number preceded by the area code",
"firstname": "First name",
"lastname": "Last name"
}
}
Notes:
-
The fields reason, idType, idNumber, cardExpiration, customer.firstname, and customer.lastname are optional.
-
The partnerReference is optional but, if provided, must be unique per operation.
Output
The API will return a JSON object with the details of the credit transaction, including:
-
Transaction Reference
-
Customer Details
-
Amount Credited
-
Transaction Status
-
Other relevant details.
HTTP Status Codes
- 200 OK: The request was successful, and the credit transaction details are returned.
Example Request
Here's an example of how to credit an account with minimal required data:
{
"amount": 15000,
"reason": "",
"idType": "",
"idNumber": "",
"cardExpiration": "",
"partnerReference": "001",
"customer": {
"phone": "+22990687526"
}
}
Example Code
Here is an example of how to make a POST request to credit an account:
import axios from 'axios';
const apiKey = 'your-api-key';
const apiSecret = 'your-api-secret';
const requestData = {
amount: 15000,
reason: "",
idType: "",
idNumber: "",
cardExpiration: "",
partnerReference: "001",
customer: {
phone: "+22990687526"
}
};
axios.post('https://svc.test.bestcash.me/external/operations/credit', requestData, {
headers: {
'X-Auth-ApiKey': apiKey,
'X-Auth-ApiSecret': apiSecret,
'Content-Type': 'application/json'
}
})
.then(response => {
console.log('Credit Transaction Details:', response.data);
})
.catch(error => {
console.error('An error occurred:', error.message);
});
Summary
Use this endpoint to credit a specified amount to a customer's account. Optional fields can be included to provide additional details, and a unique partnerReference can be used to track the operation.