Refund Creation Endpoint
Create refunds requests from a completed deposit
post
https://api-stg.directa24.com
/v3/refunds
Refund Creation

Description

The refunds endpoint allows you to create a partial or a full refund over a deposit in completed state.
In the case of credit cards, since the refund will be processed to the same card, all you need to send are the fields to identify the deposit.
In the case of other payment methods where we don't have the account of the payer, you need to send the beneficiary's ID, bank account details and bank code retrieved with the Endpoint for Bank Codes.
You can create as many refunds as needed over a completed deposit, as long as the summation of those refunds doesn't exceed the deposit amount itself.

Refunds Request

In order to start creating refunds, you need to:
  1. 1.
    Send the request with POST method.
  2. 2.
    Use the headers described here.
  3. 3.
    Specify a valid deposit_id and invoice_id related to the deposit to be refunded.
  4. 4.
    Send the Authorization header calculated like for deposits, as explained here.
  5. 5.
    Send the body of the request as JSON.

Example Request

cURL
JAVA
C#
PHP
1
// CASH Method:
2
3
curl --location --request POST 'https://api-stg.directa24.com/v3/refunds' \
4
--header 'X-Login: {{X-Login}}' \
5
--header 'X-Date: {{X-Date}}' \
6
--header 'Authorization: {{Authorization}}' \
7
--header 'Content-Type: application/json' \
8
--data-raw '{
9
"deposit_id": 300533646,
10
"invoice_id": "newIUnit45328731",
11
"amount": "100",
12
"bank_account": {
13
"beneficiary": "Carlos Ramirez",
14
"bank_code": 1,
15
"branch": "9283",
16
"account_number": "18293435",
17
"account_type": "SAVING"
18
},
19
"comments": "Test refund over v3",
20
"notification_url": "https://webhook.site/url"
21
}'
22
23
24
// CREDIT CARD method:
25
26
curl --location --request POST 'https://api-stg.directa24.com/v3/refunds' \
27
--header 'X-Login: {{X-Login}}' \
28
--header 'X-Date: {{X-Date}}' \
29
--header 'Authorization: {{Authorization}}' \
30
--header 'Content-Type: application/json' \
31
--data-raw '{
32
"deposit_id": 300533647,
33
"invoice_id": "newIUnit45328732",
34
"comments": "Test CREDIT CARD refund over v3",
35
"notification_url": "https://webhook.site/url"
36
}'
Copied!
1
import java.io.*;
2
import okhttp3.*;
3
public class main {
4
public static void main(String []args) throws IOException{
5
OkHttpClient client = new OkHttpClient().newBuilder()
6
.build();
7
MediaType mediaType = MediaType.parse("application/json");
8
RequestBody body = RequestBody.create(mediaType, "{\n \"deposit_id\": 300533646,\n \"invoice_id\": \"newIUnit45328731\",\n \"amount\": \"100\",\n \"bank_account\": {\n \"beneficiary\": \"Carlos Ramirez\",\n \"bank_code\": 1,\n \"branch\": \"9283\",\n \"account_number\": \"18293435\",\n \"account_type\": \"SAVING\"\n },\n \"comments\": \"Test refund over v3\",\n \"notification_url\": \"https://webhook.site/url\"\n}");
9
Request request = new Request.Builder()
10
.url("https://api-stg.directa24.com/v3/refunds")
11
.method("POST", body)
12
.addHeader("X-Login", "{{X-Login}}")
13
.addHeader("X-Date", "{{X-Date}}")
14
.addHeader("Authorization", "{{Authorization}}")
15
.addHeader("Content-Type", "application/json")
16
.build();
17
Response response = client.newCall(request).execute();
18
System.out.println(response.body().string());
19
}
20
}
21
22
Copied!
1
using System;
2
using RestSharp;
3
namespace HelloWorldApplication {
4
class HelloWorld {
5
static void Main(string[] args) {
6
var client = new RestClient("https://api-stg.directa24.com/v3/refunds");
7
client.Timeout = -1;
8
var request = new RestRequest(Method.POST);
9
request.AddHeader("X-Login", "{{X-Login}}");
10
request.AddHeader("X-Date", "{{X-Date}}");
11
request.AddHeader("Authorization", "{{Authorization}}");
12
request.AddHeader("Content-Type", "application/json");
13
request.AddParameter("application/json", "{\n \"deposit_id\": 300533646,\n \"invoice_id\": \"newIUnit45328731\",\n \"amount\": \"100\",\n \"bank_account\": {\n \"beneficiary\": \"Carlos Ramirez\",\n \"bank_code\": 1,\n \"branch\": \"9283\",\n \"account_number\": \"18293435\",\n \"account_type\": \"SAVING\"\n },\n \"comments\": \"Test refund over v3\",\n \"notification_url\": \"https://webhook.site/url\"\n}", ParameterType.RequestBody);
14
IRestResponse response = client.Execute(request);
15
Console.WriteLine(response.Content);
16
}
17
}
18
}
19
20
Copied!
1
<?php
2
3
$curl = curl_init();
4
5
curl_setopt_array($curl, array(
6
CURLOPT_URL => "https://api-stg.directa24.com/v3/refunds",
7
CURLOPT_RETURNTRANSFER => true,
8
CURLOPT_ENCODING => "",
9
CURLOPT_MAXREDIRS => 10,
10
CURLOPT_TIMEOUT => 0,
11
CURLOPT_FOLLOWLOCATION => true,
12
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
13
CURLOPT_CUSTOMREQUEST => "POST",
14
CURLOPT_POSTFIELDS =>"{\n \"deposit_id\": 300533646,\n \"invoice_id\": \"newIUnit45328731\",\n \"amount\": \"100\",\n \"bank_account\": {\n \"beneficiary\": \"Carlos Ramirez\",\n \"bank_code\": 1,\n \"branch\": \"9283\",\n \"account_number\": \"18293435\",\n \"account_type\": \"SAVING\"\n },\n \"comments\": \"Test refund over v3\",\n \"notification_url\": \"https://webhook.site/url\"\n}",
15
CURLOPT_HTTPHEADER => array(
16
"X-Login: {{X-Login}}",
17
"X-Date: {{X-Date}}",
18
"Authorization: {{Authorization}}",
19
"Content-Type: application/json"
20
),
21
));
22
23
$response = curl_exec($curl);
24
25
curl_close($curl);
26
echo $response;
27
28
Copied!

Request fields description

Field
Format
Description
Validations
deposit_id
Integer
Directa24 deposit_id. It is obtained when creating the deposit
Valid deposit_id of a completed deposit
invoice_id
String (max length: 128)
The invoice_id you sent while creating the deposit or the merchant_invoice_id auto-generated by us
Valid invoice_id of a completed deposit
amount
Big decimal (positive, up to 2 decimals)
Amount to refund. Only used in case of partial refunds. If none is sent, a full refund will be assumed
Positive. Equal or smaller than the deposit amount
bank_account[]
Object[]
Object containing the details where the refund should be sent to
bank_account.beneficiary
String (max length: 255)
Beneficiary's name and last name
String of up to 255 characters
bank_account.document
string (max length: 30)
Beneficiary's document ID
Valid document for the country of the deposit.
bank_account.document_type
string (max length: 10)
Beneficiary's document type
Valid document type for the country of the deposit.
bank_account.bank_code
String (max length: 10)
Beneficiary's valid bank_code for the country. Use the Bank Codes Endpoint.
Valid bank code
bank_account.branch
String (max length: 45)
Beneficiary's bank branch
String of up to 45 characters
bank_account.account_number
String (max length: 45)
Beneficiary's bank account number
String of up to 45 characters
bank_account.account_type
Array
Beneficiary's account type
comments
String (max length: 200)
Commentaries about the refund, if any
String of up to 200 characters
notification_url
String (max length: 2048)
Valid HTTPS URL used to send the notifications about refund's change of status
HTTPS URL

Example Response

CASH Success Response Example

1
{
2
"refund_id": 168284
3
}
Copied!

CASH Success Response Fields

Field
Format
Description
refund_id
Integer
ID of the refund on Directa24 end. Store this ID for future checks of its status

CREDIT CARD Responses Example

SUCCESS
IN PROGRESS
REJECTED
1
{
2
"refund_id": "80000001",
3
"deposit_id": 300604089,
4
"merchant_invoice_id": "test766106146",
5
"refund_info": {
6
"type": "CREDIT_CARD",
7
"result": "SUCCESS",
8
"payment_method": "AE",
9
"payment_method_name": "American Express",
10
"amount": 505.95,
11
"currency": "MXN",
12
"created_at": "2021-02-05 22:10:45"
13
}
14
}
Copied!
1
{
2
"refund_id": "80000001",
3
"deposit_id": 300604089,
4
"merchant_invoice_id": "test766106146",
5
"refund_info": {
6
"type": "CREDIT_CARD",
7
"result": "IN_PROGRESS",
8
"reason": "Check refund status or await its notification",
9
"payment_method": "AE",
10
"payment_method_name": "American Express",
11
"amount": 505.95,
12
"currency": "MXN",
13
"created_at": "2021-02-05 22:10:45"
14
}
15
}
Copied!
1
{
2
"refund_id": "80000001",
3
"deposit_id": 300604089,
4
"merchant_invoice_id": "test766106146",
5
"refund_info": {
6
"type": "CREDIT_CARD",
7
"result": "REJECTED",
8
"reason": "Insufficient funds",
9
"reason_code": "INSUFFICIENT_FUNDS",
10
"payment_method": "AE",
11
"payment_method_name": "American Express",
12
"amount": 505.95,
13
"currency": "MXN",
14
"created_at": "2021-02-05 22:10:45"
15
}
16
}
Copied!
When the refund is made over a CREDIT CARD deposit, it might be (depending upon availability) completed instantaneously, and so all the details of the refund are returned.
In case the result SUCCESS, it means the refund was successfully created and the user should receive the money back into their card soon.
In case the result is REJECTED, the response of the API will return two fields called reason and reason_code providing more information about the rejection reason.
In case the result is IN_PROGRESS, it means the refund will be processed asynchronously and so a notification will be sent to the notification_url specified at the time of creating the refund as soon as it gets completed or rejected. Click here for more information about the notifications of the refunds.

Error Responses Example

1
// Invalid amount to refund. The amount is bigger than the deposit or
2
// it has been already refunded
3
{
4
"code": 802,
5
"description": "Amount to refund not valid",
6
"type": "INVALID_AMOUNT_TO_REFUND"
7
}
8
9
// The object_bank account needs to be sent
10
{
11
"code": 804,
12
"description": "Missing bank account information",
13
"type": "MISSING_BANK_ACCOUNT"
14
}
15
16
// The deposit_id and/or the merchant_invoice_id didn't belong to a deposit
17
{
18
"code": 208,
19
"description": "Resource not found",
20
"type": "RESOURCE_NOT_FOUND"
21
}
22
Copied!

Error Responses Fields

Field
Format
Description
description
String
Description of the error

Account types

account_type
Description
SAVING
Savings account
CHECKING
Checkings account
VISTA
Salary account
MASTER
Master account
SAVING_SET
Joint savings account
CHECKING_SET
Joint checkings
DEFAULT
Default