Introduction
Defexa is a simple, fast and reliable payment engine with open architecture. Currently it is constantly developing by the community of software engineers with bold background in payment and e-wallet systems.
Defexa Business API - a solution specifically designed for internet businesses in need of cryptocurrency payment processing. We support all major cryptocurrencies.
Environments
There are two environments available for integration:
- Production environment: https://business.payments.defexa.io/
Sandbox Environment
Sandbox provides full functionality but it only emulates processing, no actual bank transactions are made. You can use the following PAN for tests:
- 4617611794313933: CONFIRMED as 3-D Secure transaction
- 4626233193837898: DECLINED as 3-D Secure transaction
- 4392963203551251: CONFIRMED as non 3-D Secure transaction
- 4730198364688516: DECLINED as non 3-D Secure transaction
- 4627342642639018: APPROVED PAYOUT
- 4968357931420422: DECLINED PAYOUT
You can use any cardholder name, expiry date and CVV2/CVC2 with these PANs. 3-D Secure is also emulated with a page that doesn’t require any password but only shows you 2 buttons. One button is for successful authentication, another is for failed authentication. Note, that when you chose to fail authentication, order is always declined, no matter what PAN was used.
Production Environment
Once you complete integration with Sandbox environment you will be provided with Production credentials. These are completely different credentials, not related with the ones on Sandbox. Production always makes real bank transactions, cards from Sandbox are not supported on this environment.
Authentication
Code: Copy
curl "https://business.payments.defexa.io/api/v1/da/login" \
-X POST \
-H "Authorization: Bearer merchant_private_key" \
-H "Content-Type: application/json"
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://business.payments.defexa.io/api/v1/da/login",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "",
CURLOPT_HTTPHEADER => array(
"authorization: Bearer merchant_private_key",
"content-type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
from django.http import HttpResponseRedirect, HttpResponse
import requests
import json
def pay(request) :
MERCHANT_PRIVATE_KEY = 'merchant_private_key'
LIVE_URL = 'https://business.payments.defexa.io/';
SANDBOX_URL = 'https://business.payments.defexa.io/'
payload = {}
headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer %s' % (MERCHANT_PRIVATE_KEY)
}
resp = requests.post('%s/api/v1/da/login' % (SANDBOX_URL), json=payload, headers=headers)
MediaType JSON = MediaType.parse("application/json; charset=utf-8");
HashMap<String, Object> params = new HashMap<String, Object>();
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://business.payments.defexa.io/api/v1/da/login")
.post(RequestBody.create(JSON, new Gson().toJson(params)))
.addHeader("content-type", "application/json")
.addHeader("authorization", "Bearer merchant_private_key")
.build();
Call call = client.newCall(request);
call.enqueue(new Callback() {
@Override
public void onFailure(Call call, IOException e) {
Log.e("response ", "onFailure(): " + e.getMessage() );
}
@Override
public void onResponse(Call call, Response response) throws IOException {
String resp = response.body().string();
Log.e("response ", "onResponse(): " + resp );
}
});
Return status 200 and JSON: Copy
{
"success": true,
"status": 200,
"expiration": "2023-03-28 22:52:59 UTC",
"session_token": "7e7b4119f4d8322daf616733515d9b99",
"user_id": 173
}
Authentication - to start using invoice API, you must first call using the following script. This will allow you to receive a session token, which will be required later.
Header Parameters
| Parameter | Mandatory | Description |
|---|---|---|
| Authorization | yes | "Bearer merchant_private_key" - The api key as a string. |
| Content-Type | yes | All request bodies should have content type application/json and be valid JSON. |
Response Parameters
| Parameter | Description |
|---|---|
| success | true/false |
| status | request status |
| expiration | represents server timestamp of session expiration moment |
| session_token | use this parameter in the invioce API request body |
| user_id | merchant user_id |
Payments
Defexa payment processing REST API.
Create
Code: Copy
curl "https://business.payments.defexa.io/api/v1/payments" \
-X POST \
-H "Authorization: Bearer merchant_private_key" \
-H "Content-Type: application/json" -d '{
"currency" : "BTC",
"callbackUrl" : "https://your-site.com/success",
"customer" : {
"uid": "fksdfu8orhbwfuawe"
}
}'
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://business.payments.defexa.io/api/v1/payments",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "{\"currency\":\"ALGO\",\"callbackUrl\":\"https://your-site.com/success\",\"customer\":{\"uid\":\"12345h45555jf5670w3erknjsdef\"}}",
CURLOPT_HTTPHEADER => array(
"authorization: Bearer merchant_private_key",
"content-type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
from django.http import HttpResponseRedirect, HttpResponse
import requests
import json
def pay(request) :
MERCHANT_PRIVATE_KEY = 'merchant_private_key'
LIVE_URL = 'https://business.payments.defexa.io/';
SANDBOX_URL = 'https://business.payments.defexa.io/'
payload = {
"currency" : "BTC",
"callbackUrl": request.POST['notify_url'],
"customer" : {
"uid": "12345h45555jf5670w3erknjsdef"
}
}
headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer %s' % (MERCHANT_PRIVATE_KEY)
}
resp = requests.post('%s/api/v1/payments' % (SANDBOX_URL), json=payload, headers=headers)
if resp.status_code == 200:
resp_payload = json.loads(resp.text)
return HttpResponseRedirect(resp_payload['processingUrl'])
else:
return HttpResponse('<html><body><span>Something gone wrong: %s</span></body></html>' % (resp.status_code))
MediaType JSON = MediaType.parse("application/json; charset=utf-8");
HashMap<String, Object> params = new HashMap<String, Object>();
params.put("currency", "BTC");
params.put("callbackUrl", "[sucess redirect url]");
params.put("customer", "[customer uid]");
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://business.payments.defexa.io/api/v1/payments")
.post(RequestBody.create(JSON, new Gson().toJson(params)))
.addHeader("content-type", "application/json")
.addHeader("authorization", "Bearer merchant_private_key")
.build();
Call call = client.newCall(request);
call.enqueue(new Callback() {
@Override
public void onFailure(Call call, IOException e) {
Log.e("response ", "onFailure(): " + e.getMessage() );
}
@Override
public void onResponse(Call call, Response response) throws IOException {
String resp = response.body().string();
Log.e("response ", "onResponse(): " + resp );
}
});
Return status 200 and JSON: Copy
{
"success": true | false,
"error": "",
"currency": "ALGO",
"customer": {
"uid": "12345h45555jf5670w3erknjsdef",
"address": "UM54Q23FAFZ4TL2SWHXW72AOGCPKTUKKM2IQN55N7YSQIVPJZAS2ZCFOQU"
}
}
}
Initialize payments - to begin receiving payments, you must first call using the following script.
HTTP Request via SSL
POST '/api/v1/payments'
Query Parameters
| Parameter | Mandatory | Description |
|---|---|---|
| currency | yes | Currency code (BTC, ALGO). |
| callbackUrl | No | The server URL a merchant will be notified about a payment finalisation |
| customer | yes | Customer object for Host2Host payments. |
| customer.uid | yes | Create a customer with a static customer address |
New Widget Invoice
Code: Copy
curl "https://business.payments.defexa.io/api/v1/charge" \
-X POST \
-H "Authorization: Bearer merchant_private_key" \
-H "Content-Type: application/json" -d '{
"amount": 10,
"currency": "ALGO",
"callback_url": "https://test.test",
"redirect_fail_url": "https://your-site.com/fail",
"redirect_success_url": "https://your-site.com/success",
"logo_url": "https://test.com/img.png"
}'
from django.http import HttpResponseRedirect, HttpResponse
import requests
import json
def pay(request) :
MERCHANT_PRIVATE_KEY = 'merchant_private_key'
LIVE_URL = 'https://business.payments.defexa.io/';
SANDBOX_URL = 'https://business.payments.defexa.io/'
payload = {
"amount": 10,
"currency": "ALGO",
"callback_url": "https://test.test",
"redirect_fail_url": "https://your-site.com/fail",
"redirect_success_url": "https://your-site.com/success",
"logo_url": "https://test.com/img.png"
}
headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer %s' % (MERCHANT_PRIVATE_KEY)
}
resp = requests.post('%s/api/v1/charge' % (SANDBOX_URL), json=payload, headers=headers)
if resp.status_code == 200:
resp_payload = json.loads(resp.text)
else:
return HttpResponse('<html><body><span>Something gone wrong: %s</span></body></html>' % (resp.status_code))
MediaType JSON = MediaType.parse("application/json; charset=utf-8");
HashMap<String, Object> params = new HashMap<String, Object>();
params.put("amount", 10);
params.put("currency", "ALGO");
params.put("callback_url", "ttps://test.test");
params.put("redirect_fail_url", "https://your-site.com/fail");
params.put("redirect_success_url", "https://your-site.com/success");
params.put("logo_url", "https://test.com/img.png");
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://business.payments.defexa.io/api/v1/charge")
.post(RequestBody.create(JSON, new Gson().toJson(params)))
.addHeader("content-type", "application/json")
.addHeader("authorization", "Bearer merchant_private_key")
.build();
Call call = client.newCall(request);
call.enqueue(new Callback() {
@Override
public void onFailure(Call call, IOException e) {
Log.e("response ", "onFailure(): " + e.getMessage() );
}
@Override
public void onResponse(Call call, Response response) throws IOException {
String resp = response.body().string();
Log.e("response ", "onResponse(): " + resp );
}
});
Return status 200 and JSON: Copy
{
"status": "success",
"redirect_url": "https://crypto.payments.defexa.io/charge_requests?..."
}
Create a widget operation.
HTTP Request via SSL
POST '/api/v1/charge'
Header Parameters
| Parameter | Mandatory | Description |
|---|---|---|
| Authorization | yes | "Bearer merchant_private_key" - The api key as a string. |
| Content-Type | yes | All request bodies should have content type application/json and be valid JSON. |
Body Parameters
| Parameter | Mandatory | Description |
|---|---|---|
| amount | yes | Payment amount. |
| currency | yes | Currency ISO. |
| callback_url | yes | Callback URL. |
| redirect_fail_url | yes | Redirection URL for declined transactions. |
| redirect_success_url | yes | Redirection URL for approved transactions. |
| logo_url | no | URL of logo. |
| pay_fee_for_client | no | defines whether network transaction fee for transfer |
| shop_order_id | no | define shop order id |
| autoexchange | no | autoexchange true/false |
| exchange_currency | no | required if autoexchange, BTC/ETH e.t.c. |
Response Parameters
| Parameter | Description |
|---|---|
| success | success/fail |
| redirect_url | redirection url |
Payouts
Transferring money from a business account to a client account.
Create Session
Code: Copy
curl "https://business.payments.defexa.io/api/v1/da/login" \
-X POST \
-H "Authorization: Bearer merchant_private_key" \
-H "Content-Type: application/json"
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://business.payments.defexa.io/api/v1/da/login",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "",
CURLOPT_HTTPHEADER => array(
"authorization: Bearer merchant_private_key",
"content-type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
from django.http import HttpResponseRedirect, HttpResponse
import requests
import json
def pay(request) :
MERCHANT_PRIVATE_KEY = 'merchant_private_key'
LIVE_URL = 'https://business.payments.defexa.io/';
SANDBOX_URL = 'https://business.payments.defexa.io/'
payload = {}
headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer %s' % (MERCHANT_PRIVATE_KEY)
}
resp = requests.post('%s/api/v1/da/login' % (SANDBOX_URL), json=payload, headers=headers)
MediaType JSON = MediaType.parse("application/json; charset=utf-8");
HashMap<String, Object> params = new HashMap<String, Object>();
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://business.payments.defexa.io/api/v1/da/login")
.post(RequestBody.create(JSON, new Gson().toJson(params)))
.addHeader("content-type", "application/json")
.addHeader("authorization", "Bearer merchant_private_key")
.build();
Call call = client.newCall(request);
call.enqueue(new Callback() {
@Override
public void onFailure(Call call, IOException e) {
Log.e("response ", "onFailure(): " + e.getMessage() );
}
@Override
public void onResponse(Call call, Response response) throws IOException {
String resp = response.body().string();
Log.e("response ", "onResponse(): " + resp );
}
});
Return status 200 and JSON: Copy
{
"success": true,
"status": 200,
"expiration": "2023-03-28 22:52:59 UTC",
"session_token": "7e7b4119f4d8322daf616733515d9b99",
"user_id": 173
}
Authentication - to start using invoice API, you must first call using the following script. This will allow you to receive a session token, which will be required later.
Header Parameters
| Parameter | Mandatory | Description |
|---|---|---|
| Authorization | yes | "Bearer merchant_private_key" - The api key as a string. |
| Content-Type | yes | All request bodies should have content type application/json and be valid JSON. |
Response Parameters
| Parameter | Description |
|---|---|
| success | true/false |
| status | request status |
| expiration | represents server timestamp of session expiration moment |
| session_token | use this parameter in the invioce API request body |
| user_id | merchant user_id |
Get Assets And Wallet Addresses
Code: Copy
curl "https://business.payments.defexa.io/api/v1/da/wallets?session_token=f3a728b408fadd87fb076b46c0893f22" \
-H "Authorization: Bearer merchant_private_key"
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://business.payments.defexa.io/api/v1/da/wallets?session_token=f3a728b408fadd87fb076b46c0893f22",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"authorization: Bearer merchant_private_key"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://business.payments.defexa.io/api/v1/da/wallets?session_token=f3a728b408fadd87fb076b46c0893f22")
.get()
.addHeader("authorization", "Bearer merchant_private_key")
.build();
Response response = client.newCall(request).execute();
Return status 200 and JSON: Copy
{
"success": true,
"result": 0,
"status": 200,
"wallets": [
{
"wallet": {
"id": 418,
"amount": "10.00",
"unformatted_amount": 10.0,
"available_for_payout": 10.0,
"currency": "ALGO",
"held": 0.0,
"limit": 0,
"revenue": 20.0,
"name": "unlim",
"main": null,
"address": "TD2I7GP6CJAF5E622CHL6RUMWM22X6KEIUJIZ6KFQP4FSIOOMMVJST3EQY",
"bank_account_id": 340
}
}
]
}
HTTP Request via SSL
GET '/api/v1/da/wallets'
This endpoint retrieves all assets and wallet addresses.
Header Parameters
| Parameter | Mandatory | Description |
|---|---|---|
| Authorization | yes | "Bearer merchant_private_key" - The api key as a string. |
| Content-Type | yes | All request bodies should have content type application/json and be valid JSON. |
Query Parameters
| Parameter | Mandatory | Description |
|---|---|---|
| session_token | yes | Authorization token. |
Response Parameters
| Parameter | Description |
|---|---|
| success | true/false |
| status | status code |
| wallets | wallet list |
Get All Payouts (single/mass)
Code: Copy
curl "https://business.payments.defexa.io/api/v1/da/payouts?session_token=56fd74e7c837133c61a266b1b2f89a8b&type=single" \
-H "Authorization: Bearer merchant_private_key"
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://business.payments.defexa.io/api/v1/da/payouts?session_token=56fd74e7c837133c61a266b1b2f89a8b&type=single",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"authorization: Bearer merchant_private_key"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://business.payments.defexa.io/api/v1/da/payouts?session_token=56fd74e7c837133c61a266b1b2f89a8b&type=single")
.get()
.addHeader("authorization", "Bearer merchant_private_key")
.build();
Response response = client.newCall(request).execute();
Return status 200 and JSON: Copy
{
"success": true,
"result": 0,
"status": 200,
"payouts": [
{
"id": 736,
"message": null,
"from": "vdfbdzfbhn zcdfbhxdfsth",
"from_id": 173,
"from_phone": null,
"from_email": "aaaaaaaaaannn@nfghngfnxf.ru",
"from_profile_wallet_type": "personal",
"from_wallet_token": "d24fb5f4b8b1872c0b6d28e76d2375f203a6",
"to": " ",
"to_id": 4,
"to_phone": null,
"to_email": "wallet@defexa.com",
"to_profile_wallet_type": "biz",
"to_wallet_token": "fb4ba7f9bbea0250552e79ba1853d5c2646b",
"global": 2,
"date": "2023-04-04 16:16:56 UTC",
"likes": null,
"paymentId": 736,
"order_number": "e1cfdfa3-974c-47ac-b8c8-9b68c02bc7c1",
"for": null,
"type": "cashout",
"amount": 1.0,
"currency": "ALGO",
"viewed": 0,
"pic": "",
"pics": [],
"company_name": null,
"btc_address": null,
"target_amount": null,
"target_currency": null,
"source": null,
"status": 1,
"description": null,
"extra_data": {
"tx_hash": "L2AE3ETAA6...E36UN6P2A",
"target_address": "U5JW3GOE5C2...CWI3VPUHA",
"explorer_url": "https://testnet.algo....G4E36UN6P2A"
},
"api_payment_token": "82e4146af709b56ace64c10f6b2bd90c",
"to_account": null,
"from_account": "TWAL6PN73...X4YVCCJKAY65XLU",
"from_wallet_name": "kj.ih",
"bank_account": null,
"commission_amount": 1.0,
"commission_currency": "ALGO",
"target_currency_rate": null,
"network_commission": null
}
]
}
This endpoint retrieves all payouts.
Header Parameters
| Parameter | Mandatory | Description |
|---|---|---|
| Authorization | yes | "Bearer merchant_private_key" - The api key as a string. |
| Content-Type | yes | All request bodies should have content type application/json and be valid JSON. |
Query Parameters
| Parameter | Mandatory | Description |
|---|---|---|
| session_token | yes | Authorization token. |
| type | yes | single/mass |
| order_number | No | Retrieves a specific invoice by order_number |
Response Parameters
| Parameter | Description |
|---|---|
| success | true/false |
| status | status code |
| payouts | payout list |
Get a Specific Payout (mass/single)
Code: Copy
curl "https://business.payments.defexa.io/api/v1/da/payouts/{PAYOUT_ID}?session_token=f3a728b408fadd87fb076b46c0893f22" \
-H "Authorization: Bearer merchant_private_key"
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://business.payments.defexa.io/api/v1/da/payouts/{PAYOUT_ID}?session_token=f3a728b408fadd87fb076b46c0893f22",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"authorization: Bearer merchant_private_key"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://business.payments.defexa.io/api/v1/da/payouts/{PAYOUT_ID}?session_token=f3a728b408fadd87fb076b46c0893f22")
.get()
.addHeader("authorization", "Bearer merchant_private_key")
.build();
Response response = client.newCall(request).execute();
Return status 200 and JSON: Copy
{
"success": true,
"result": 0,
"status": 200,
"feed": [
{
"id": 659,
"message": null,
"created_at": "2023-03-13T12:32:22.614Z",
"updated_at": "2023-03-13T12:32:52.772Z",
"privacy": 2,
"likes": null,
"description": null,
"from_profile_id": 205,
"to_profile_id": 4,
"fType": 6,
"feed_date": "2023-03-13T12:32:22.607Z",
"amount": 6.0,
"currency": "XRP",
"status": 1,
"viewed": 0,
"rate_id": null,
"commission_value": 0.0,
"commission_amount": 1.0,
"commission_currency": "XRP",
"trusted": false,
"charge_request_id": null,
"api_payment_token": "c5b9e121df252b05ebe147e218faa6e4",
"order_number": "3000444a-e19f-4a76-b77a-16df4f4ad50b",
"extra_param": "defexa|205",
"refund_id": null,
"file_data": [],
"source": null,
"bank_account_id": null,
"extra_data": {
"tx_hash": "17CC45D3......E99F54CD8A04BC7C",
"url": "https://....7C"
},
"target_currency": null,
"target_amount": null,
"target_currency_rate": null,
"feed_reference_id": null,
"refunded_target_amount": 0.0,
"country_bank": null,
"country_ip": null,
"country_phone": null,
"commission_fee": 1.0,
"commission_provider_value": 0.0,
"commission_provider_fee": 0.0,
"commission_provider_amount": 0.0,
"attachments": [],
"source_currency_rate": null,
"to_bank_account_id": null,
"from_bank_account_id": 385,
"network_fee": null
}
]
}
This endpoint retrieves a specific payout. PAYOUT_ID - payout id
HTTP Request via SSL
GET '/api/v1/da/payouts/{PAYOUT_ID}'
Header Parameters
| Parameter | Mandatory | Description |
|---|---|---|
| Authorization | yes | "Bearer merchant_private_key" - The api key as a string. |
| Content-Type | yes | All request bodies should have content type application/json and be valid JSON. |
Query Parameters
| Parameter | Description | Required |
|---|---|---|
| session_token | String | Yes |
Response Parameters
| Parameter | Description |
|---|---|
| success | true/false |
| status | status code |
| feed | payout object |
New Payout
Code: Copy
curl "https://business.payments.defexa.io//api/v1/da/payouts" \
-X POST \
-H "Authorization: Bearer merchant_private_key" \
-H "Content-Type: application/json" -d '{
"session_token": "bab7f2dc5f9e2bc85e6031d88140d7b5",
"from_address": "TWAL6PN73E6NAOERO5746HZQY5OGXOU",
"target_address": "U5JW3GOE5C2SKIFADXNS7WYXK4634",
"amount" : 10,
"currency" : "ALGO",
"order_number": "10001"
}'
from django.http import HttpResponseRedirect, HttpResponse
import requests
import json
def pay(request) :
MERCHANT_PRIVATE_KEY = 'merchant_private_key'
LIVE_URL = 'https://business.payments.defexa.io/';
SANDBOX_URL = 'https://business.payments.defexa.io/'
payload = {
"amount": request['amount'],
"currency": request['currency'],
"order_number": request['order_number'],
"session_token": request['session_token'],
"from_address": request['from_address'],
"target_address": request['target_address']
}
headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer %s' % (MERCHANT_PRIVATE_KEY)
}
resp = requests.post('%s/api/v1/da/payouts' % (SANDBOX_URL), json=payload, headers=headers)
if resp.status_code == 200:
resp_payload = json.loads(resp.text)
else:
return HttpResponse('<html><body><span>Something gone wrong: %s</span></body></html>' % (resp.status_code))
MediaType JSON = MediaType.parse("application/json; charset=utf-8");
HashMap<String, Object> params = new HashMap<String, Object>();
params.put("amount", 10);
params.put("currency", "ALGO");
params.put("order_number", "10001");
params.put("session_token", "bab7f2dc5f9e2bc85e6031d88140d7b5");
params.put("from_address", "TWAL6PN73E6NAOERO5746HZQY5OGXOUKJWH");
params.put("target_address", "U5JW3GOE5C2SKIFADXNS7WYXK46344WANRWY33TAW");
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://business.payments.defexa.io//api/v1/da/payouts")
.post(RequestBody.create(JSON, new Gson().toJson(params)))
.addHeader("content-type", "application/json")
.addHeader("authorization", "Bearer merchant_private_key")
.build();
Call call = client.newCall(request);
call.enqueue(new Callback() {
@Override
public void onFailure(Call call, IOException e) {
Log.e("response ", "onFailure(): " + e.getMessage() );
}
@Override
public void onResponse(Call call, Response response) throws IOException {
String resp = response.body().string();
Log.e("response ", "onResponse(): " + resp );
}
});
Return status 200 and JSON: Copy
{
"success": true,
"result": 0,
"status": 200,
"payout": {
"token": "82e4146af709b56ace64c10f6b2bd90c",
"timestamp": "2023-04-04T16:16:56.619Z",
"status": "pending",
"scoring_action": "success"
},
"token": "82e4146af709b56ace64c10f6b2bd90c",
"timestamp": "2023-04-04T16:16:56.619Z"
}
Create a payout operation.
HTTP Request via SSL
POST '/api/v1/da/payouts'
Header Parameters
| Parameter | Mandatory | Description |
|---|---|---|
| Authorization | yes | "Bearer merchant_private_key" - The api key as a string. |
| Content-Type | yes | All request bodies should have content type application/json and be valid JSON. |
Body Parameters
| Parameter | Mandatory | Description |
|---|---|---|
| session_token | yes | Authorization token. |
| amount | yes | Amount of funds to withdraw. |
| currency | yes | Currency ISO. |
| from_address | yes | Sender's crypto address. |
| target_address | yes | Cryptocurrency address where you want to send funds. |
| order_number | No | Defexa's client inner order number. |
| callback_url | No | callback URL. |
Response Parameters
| Parameter | Description |
|---|---|
| success | true/false |
| status | request status |
| payout | Payout object |
| payout.status | Payout status |
| payout.core_id | Id for get request |
| token | Payout token |
| timestamp | A sequence of characters or encoded information identifying when a payout occurred |
New Mass Payout
Code: Copy
curl "https://business.payments.defexa.io/api/v1/da/mass_payouts" \
-X POST \
-H "Authorization: Bearer merchant_private_key" \
-H "Content-Type: application/json" -d '{
"session_token": "bab7f2dc5f9e2bc85e6031d88140d7b5",
"name": "test api",
"from_address": "TWAL6PN73E6NAOERO5746HZQY5OGXOUK",
"currency": "ALGO",
"payout_list": [
{
"Summ": 0.0008,
"Address": "U5JW3GOE5C2SKIFADXNS7UHA",
"Comment": "ffffff"
}
]
}'
from django.http import HttpResponseRedirect, HttpResponse
import requests
import json
def pay(request) :
MERCHANT_PRIVATE_KEY = 'merchant_private_key'
LIVE_URL = 'https://business.payments.defexa.io/';
SANDBOX_URL = 'https://business.payments.defexa.io/'
payload = {
"amount": request['amount'],
"currency": request['currency'],
"name": request['name'],
"session_token": request['session_token'],
"from_address": request['from_address'],
"payout_list": [{
"Summ": 0.0008,
"Address": "U5JW3GOE5C2SKIFADXNS7UHA",
"Comment": "ffffff"
}]
}
headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer %s' % (MERCHANT_PRIVATE_KEY)
}
resp = requests.post('%s/api/v1/da/mass_payouts' % (SANDBOX_URL), json=payload, headers=headers)
if resp.status_code == 200:
resp_payload = json.loads(resp.text)
else:
return HttpResponse('<html><body><span>Something gone wrong: %s</span></body></html>' % (resp.status_code))
MediaType JSON = MediaType.parse("application/json; charset=utf-8");
HashMap<String, Object> params = new HashMap<String, Object>();
params.put("currency", "ALGO");
params.put("name", "name");
params.put("session_token", "bab7f2dc5f9e2bc85e6031d88140d7b5");
params.put("from_address", "TWAL6PN73E6NAOERO5746HZQY5OGXOUKJWH");
params.put("payout_list", []);
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://business.payments.defexa.io/api/v1/da/mass_payouts")
.post(RequestBody.create(JSON, new Gson().toJson(params)))
.addHeader("content-type", "application/json")
.addHeader("authorization", "Bearer merchant_private_key")
.build();
Call call = client.newCall(request);
call.enqueue(new Callback() {
@Override
public void onFailure(Call call, IOException e) {
Log.e("response ", "onFailure(): " + e.getMessage() );
}
@Override
public void onResponse(Call call, Response response) throws IOException {
String resp = response.body().string();
Log.e("response ", "onResponse(): " + resp );
}
});
Return status 200 and JSON: Copy
{
"success": true,
"result": 0,
"status": 200
}
Create a payout operation.
HTTP Request via SSL
POST '/api/v1/da/mass_payouts'
Header Parameters
| Parameter | Mandatory | Description |
|---|---|---|
| Authorization | yes | "Bearer merchant_private_key" - The api key as a string. |
| Content-Type | yes | All request bodies should have content type application/json and be valid JSON. |
Body Parameters
| Parameter | Mandatory | Description |
|---|---|---|
| session_token | yes | Authorization token. |
| name | yes | Mass payout name. |
| currency | yes | Currency ISO. |
| from_address | yes | Sender's crypto address. |
| callback_url | No | callback URL. |
| payout_list | yes | Payout list. |
| payout_list.Summ | yes | Amount of funds to withdraw. |
| payout_list.Address | yes | Cryptocurrency address. |
| payout_list.Comment | No | Comment for the withdrawal transaction. |
Response Parameters
| Parameter | Description |
|---|---|
| success | true/false |
| status | status code |
| order_number | order number |
Get Transactions From a Specific Mass Payout
Code: Copy
curl "https://business.payments.defexa.io/api/v1/da/mass_payouts?session_token=dc828f946afb78b8af99c816c0dfea0e&order_number=mass_payout_99e8efa03fd7bdc10b87c03f21bc49f4" \
-H "Authorization: Bearer merchant_private_key"
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://business.payments.defexa.io/api/v1/da/mass_payouts?session_token=dc828f946afb78b8af99c816c0dfea0e&order_number=mass_payout_99e8efa03fd7bdc10b87c03f21bc49f4",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"authorization: Bearer merchant_private_key"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://business.payments.defexa.io/api/v1/da/mass_payouts?session_token=dc828f946afb78b8af99c816c0dfea0e&order_number=mass_payout_99e8efa03fd7bdc10b87c03f21bc49f4")
.get()
.addHeader("authorization", "Bearer merchant_private_key")
.build();
Response response = client.newCall(request).execute();
Return status 200 and JSON: Copy
{
"success": true,
"result": 0,
"status": 200,
"payouts": [
{
"id": 736,
"message": null,
"from": "vdfbdzfbhn zcdfbhxdfsth",
"from_id": 173,
"from_phone": null,
"from_email": "aaaaaaaaaannn@nfghngfnxf.ru",
"from_profile_wallet_type": "personal",
"from_wallet_token": "d24fb5f4b8b1872c0b6d28e76d2375f203a6",
"to": " ",
"to_id": 4,
"to_phone": null,
"to_email": "wallet@defexa.com",
"to_profile_wallet_type": "biz",
"to_wallet_token": "fb4ba7f9bbea0250552e79ba1853d5c2646b",
"global": 2,
"date": "2023-04-04 16:16:56 UTC",
"likes": null,
"paymentId": 736,
"order_number": "e1cfdfa3-974c-47ac-b8c8-9b68c02bc7c1",
"for": null,
"type": "cashout",
"amount": 1.0,
"currency": "ALGO",
"viewed": 0,
"pic": "",
"pics": [],
"company_name": null,
"btc_address": null,
"target_amount": null,
"target_currency": null,
"source": null,
"status": 1,
"description": null,
"extra_data": {
"tx_hash": "L2AE3ETAA6...E36UN6P2A",
"target_address": "U5JW3GOE5C2...CWI3VPUHA",
"explorer_url": "https://testnet.algo....G4E36UN6P2A"
},
"api_payment_token": "82e4146af709b56ace64c10f6b2bd90c",
"to_account": null,
"from_account": "TWAL6PN73...X4YVCCJKAY65XLU",
"from_wallet_name": "kj.ih",
"bank_account": null,
"commission_amount": 1.0,
"commission_currency": "ALGO",
"target_currency_rate": null,
"network_commission": null
}
]
}
This endpoint retrieves all transactions from a specific mass payout.
Header Parameters
| Parameter | Mandatory | Description |
|---|---|---|
| Authorization | yes | "Bearer merchant_private_key" - The api key as a string. |
| Content-Type | yes | All request bodies should have content type application/json and be valid JSON. |
Query Parameters
| Parameter | Mandatory | Description |
|---|---|---|
| session_token | yes | Authorization token. |
| order_number | yes | Mass payout order_number |
Response Parameters
| Parameter | Description |
|---|---|
| success | true/false |
| status | status code |
| payouts | payout list |
Get Expected Transaction Fee
Code: Copy
curl "https://business.payments.defexa.io/api/v1/da/payouts/fee" \
-X POST \
-H "Authorization: Bearer merchant_private_key" \
-H "Content-Type: application/json" -d '{
"session_token": "bab7f2dc5f9e2bc85e6031d88140d7b5",
"from_address": "TWAL6PN73E6NAOERO5746HZQY5OGX",
"target_address": "U5JW3GOE5C2SKIFADXNS",
"amount" : 10,
"currency" : "ALGO"
}'
from django.http import HttpResponseRedirect, HttpResponse
import requests
import json
def pay(request) :
MERCHANT_PRIVATE_KEY = 'merchant_private_key'
LIVE_URL = 'https://business.payments.defexa.io/';
SANDBOX_URL = 'https://business.payments.defexa.io/'
payload = {
"amount": request['amount'],
"currency": request['currency'],
"session_token": request['session_token'],
"from_address": request['from_address'],
"target_address": request['target_address']
}
headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer %s' % (MERCHANT_PRIVATE_KEY)
}
resp = requests.post('%s/api/v1/da/payouts/fee' % (SANDBOX_URL), json=payload, headers=headers)
if resp.status_code == 200:
resp_payload = json.loads(resp.text)
else:
return HttpResponse('<html><body><span>Something gone wrong: %s</span></body></html>' % (resp.status_code))
MediaType JSON = MediaType.parse("application/json; charset=utf-8");
HashMap<String, Object> params = new HashMap<String, Object>();
params.put("amount", 10);
params.put("currency", "ALGO");
params.put("session_token", "bab7f2dc5f9e2bc85e6031d88140d7b5");
params.put("from_address", "TWAL6PN73E6NAOERO5746HZQY5OGXOUKJWH");
params.put("target_address", "U5JW3GOE5C2SKIFADXNS7WYXK46344WANRWY33TAW");
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://business.payments.defexa.io/api/v1/da/payouts/fee")
.post(RequestBody.create(JSON, new Gson().toJson(params)))
.addHeader("content-type", "application/json")
.addHeader("authorization", "Bearer merchant_private_key")
.build();
Call call = client.newCall(request);
call.enqueue(new Callback() {
@Override
public void onFailure(Call call, IOException e) {
Log.e("response ", "onFailure(): " + e.getMessage() );
}
@Override
public void onResponse(Call call, Response response) throws IOException {
String resp = response.body().string();
Log.e("response ", "onResponse(): " + resp );
}
});
Return status 200 and JSON: Copy
{
"success": true,
"result": 0,
"status": 200,
"commission": {
"low": {
"networkFee": "0.001"
},
"medium": {
"networkFee": "0.001"
},
"high": {
"networkFee": "0.001"
}
}
}
This endpoint retrieves the expected transaction fee.
HTTP Request via SSL
POST '/api/v1/da/payouts/fee'
Header Parameters
| Parameter | Mandatory | Description |
|---|---|---|
| Authorization | yes | "Bearer merchant_private_key" - The api key as a string. |
| Content-Type | yes | All request bodies should have content type application/json and be valid JSON. |
Body Parameters
| Parameter | Mandatory | Description |
|---|---|---|
| session_token | yes | Authorization token. |
| amount | yes | Amount of funds to withdraw. |
| currency | yes | Currency ISO. |
| from_address | yes | Sender's crypto address. |
| target_address | yes | Cryptocurrency address where you want to send funds. |
Response Parameters
| Parameter | Description |
|---|---|
| success | true/false |
| status | request status |
| commission | Commission object |
| commission.medium.networkFee | The expected transaction fee |
Invoice
Provides a wide range of methods for invoices
Get All Invoices
Code: Copy
curl "https://business.payments.defexa.io/api/v1/da/invoices?session_token=f3a728b408fadd87" \
-H "Authorization: Bearer merchant_private_key"
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://business.payments.defexa.io/api/v1/da/invoices?session_token=f3a728b408fad",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"authorization: Bearer merchant_private_key"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://business.payments.defexa.io/api/v1/da/invoices?session_token=f3a728b408fadd87fb0")
.get()
.addHeader("authorization", "Bearer merchant_private_key")
.build();
Response response = client.newCall(request).execute();
Return status 200 and JSON: Copy
{
"success": true,
"invoices": [
{
"id": 661,
"message": null,
"from": "bvdndtfg gbfghngfnj",
"from_id": 205,
"from_phone": null,
"from_email": "test@user.com",
"from_profile_wallet_type": "personal",
"from_wallet_token": "5050314a4fe5a5d8b9a940f2521f2f68d45c",
"to": "anonymous",
"to_id": 295,
"to_phone": null,
"to_email": "1678798205@anonymous.charge_request.com",
"to_profile_wallet_type": "pale",
"to_wallet_token": "fe04d4617709cbe4f179316460bcf76f9c98",
"global": 2,
"date": "2023-03-14 12:50:05 UTC",
"likes": null,
"paymentId": 661,
"order_number": "limited_invoice_7e5fb42d19d3fd0c00",
"for": "test 12",
"type": "charge new",
"amount": 13.0,
"currency": "ALGO",
"viewed": 0,
"pic": "",
"pics": [],
"company_name": null,
"btc_address": null,
"target_amount": 13.0,
"target_currency": "ALGO",
"source": null,
"status": 0,
"description": "test 12",
"extra_data": {},
"api_payment_token": null,
"to_account": null,
"from_account": "KE6QKDJRAIGXSREZ3HBLJE57XNJZJQQUJ",
"from_wallet_name": "lim test",
"bank_account": null,
"commission_amount": null,
"commission_currency": null,
"target_currency_rate": null,
"network_commission": null
}
]
}
This endpoint retrieves all invoices.
HTTP Request via SSL
GET '/api/v1/da/invoices'
Header Parameters
| Parameter | Mandatory | Description |
|---|---|---|
| Authorization | yes | "Bearer merchant_private_key" - The api key as a string. |
| Content-Type | yes | All request bodies should have content type application/json and be valid JSON. |
Query Parameters
| Parameter | Mandatory | Description |
|---|---|---|
| session_token | yes | Authorization token. |
| type_name | No | SINGLE/UNLIMITED |
| order_number | No | retrieves a specific invoice by order_number |
Response Parameters
| Parameter | Description |
|---|---|
| success | true/false |
| invoices | invoices list |
Get a Specific Invoice
Code: Copy
curl "https://business.payments.defexa.io/api/v1/da/invoices/{INVOICE_ID}?session_token=f3a728b408fadd8" \
-H "Authorization: Bearer merchant_private_key"
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://business.payments.defexa.io/api/v1/da/invoices/{INVOICE_ID}?session_token=f3a728b408fadd87f",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"authorization: Bearer merchant_private_key"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://business.payments.defexa.io/api/v1/da/invoices/{INVOICE_ID}?session_token=f3a728b408fadd87fb")
.get()
.addHeader("authorization", "Bearer merchant_private_key")
.build();
Response response = client.newCall(request).execute();
Return status 200 and JSON: Copy
{
"success": true,
"status": 200,
"feed": [
{
"id": 661,
"message": null,
"created_at": "2023-03-14T12:50:05.966Z",
"updated_at": "2023-03-14T12:50:05.977Z",
"privacy": 2,
"likes": null,
"description": "test 12",
"from_profile_id": 205,
"to_profile_id": 295,
"fType": 3,
"feed_date": "2023-03-14T12:50:05.953Z",
"amount": 13.0,
"currency": "ALGO",
"status": 0,
"viewed": 0,
"rate_id": null,
"commission_value": null,
"commission_amount": null,
"commission_currency": null,
"trusted": false,
"charge_request_id": null,
"api_payment_token": null,
"order_number": "limited_invoice_7e5fb49-5319d3fd0c00",
"extra_param": "recurring_payment",
"refund_id": null,
"file_data": [],
"source": null,
"bank_account_id": null,
"extra_data": {},
"target_currency": "ALGO",
"target_amount": 13.0,
"target_currency_rate": null,
"feed_reference_id": null,
"refunded_target_amount": 0.0,
"country_bank": null,
"country_ip": null,
"country_phone": null,
"commission_fee": null,
"commission_provider_value": null,
"commission_provider_fee": null,
"commission_provider_amount": null,
"payment_object": null,
"attachments": [],
"source_currency_rate": null,
"to_bank_account_id": null,
"from_bank_account_id": 351,
"network_fee": null
}
]
}
This endpoint retrieves all invoices. INVOICE_ID - invoice id
HTTP Request via SSL
GET '/api/v1/da/invoices/{INVOICE_ID}'
Header Parameters
| Parameter | Mandatory | Description |
|---|---|---|
| Authorization | yes | "Bearer merchant_private_key" - The api key as a string. |
| Content-Type | yes | All request bodies should have content type application/json and be valid JSON. |
Query Parameters
| Parameter | Mandatory | Description |
|---|---|---|
| session_token | yes | Authorization token. |
Response Parameters
| Parameter | Description |
|---|---|
| success | true/false |
| feed | invoice object |
New Invoice
Code: Copy
curl "https://business.payments.defexa.io/api/v1/da/invoices" \
-X POST \
-H "Authorization: Bearer merchant_private_key" \
-H "Content-Type: application/json" -d '{
"session_token": "92c52a255578b86af2ad46705e10ef9b",
"type": "UNLIMITED",
"currency": "ALGO",
"description": "UNLIMITED",
"from_wallet": 345
}'
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://business.payments.defexa.io/api/v1/da/invoices",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "{ \"session_token\" : \"92c52a255578b86af2ad46705e10ef9b\", \"type\" : \"UNLIMITED\", \"currency\" : \"ALGO\", \"description\" : \"UNLIMITED\", \"from_wallet\" : \"345\"\n}",
CURLOPT_HTTPHEADER => array(
"authorization: Bearer merchant_private_key",
"content-type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
from django.http import HttpResponseRedirect, HttpResponse
import requests
import json
def pay(request) :
MERCHANT_PRIVATE_KEY = 'merchant_private_key'
LIVE_URL = 'https://business.payments.defexa.io/';
SANDBOX_URL = 'https://business.payments.defexa.io/'
payload = {
"session_token" : "92c52a255578b86af2ad46705e10ef9b",
"currency" : "ALGO",
"type": "UNLIMITED",
"description" : "UNLIMITED",
"from_wallet" : 345
}
headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer %s' % (MERCHANT_PRIVATE_KEY)
}
resp = requests.post('%s/api/v1/da/invoices' % (SANDBOX_URL), json=payload, headers=headers)
MediaType JSON = MediaType.parse("application/json; charset=utf-8");
HashMap<String, Object> params = new HashMap<String, Object>();
params.put("session_token", "92c52a255578b86af2ad46705e10ef9b");
params.put("currency", "ALGO");
params.put("type", "UNLIMITED");
params.put("description", "UNLIMITED");
params.put("from_wallet", 342);
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://business.payments.defexa.io/api/v1/da/invoices")
.post(RequestBody.create(JSON, new Gson().toJson(params)))
.addHeader("content-type", "application/json")
.addHeader("authorization", "Bearer merchant_private_key")
.build();
Call call = client.newCall(request);
call.enqueue(new Callback() {
@Override
public void onFailure(Call call, IOException e) {
Log.e("response ", "onFailure(): " + e.getMessage() );
}
@Override
public void onResponse(Call call, Response response) throws IOException {
String resp = response.body().string();
Log.e("response ", "onResponse(): " + resp );
}
});
Return status 200 and JSON: Copy
{
"success": true,
"status": "success",
"url": "http://wallet:8800/charge_requests?....."
}
This endpoint creates a new invoice.
HTTP Request via SSL
POST '/api/v1/da/invoices'
Header Parameters
| Parameter | Mandatory | Description |
|---|---|---|
| Authorization | yes | "Bearer merchant_private_key" - The api key as a string. |
| Content-Type | yes | All request bodies should have content type application/json and be valid JSON. |
Request Body
| Parameter | Mandatory | Description |
|---|---|---|
| session_token | yes | Authorization token. |
| type | yes | SINGLE/UNLIMITED |
| currency | Yes | received blockchain currency. [BTC ETH XRP BNB MATIC TRX BSC AVAX SOL EOS ALGO NEAR LUNA] |
| description | Yes | short invoice description |
| from_wallet | Yes | wallet ID for replenishment |
| amount | Yes | total invoice amount(only for SINGLE) |
| pay_fee_for_client | No | defines whether network transaction fee for transfer from invoice wallet to your wallet will be substracted from transfer amount or not (only for SINGLE) |
| expiration_time | No | represents server timestamp of invoice expiration moment (only for SINGLE) |
| set_expiration_time | No | true, required if expiration_time is present |
| customer.uid | No | create an invoice with a static customer address if uid sent |
| callback_url | No | callback URL. |
| autoexchange | No | autoexchange true/false (only for SINGLE) |
| exchange_currency | No | required if autoexchange, BTC/ETH e.t.c. (only for SINGLE) |
Response Parameters
| Parameter | Description |
|---|---|
| success | true/false |
| status | status code |
| url | invoice url |
AML refund
Methods for AML refunds (if auto-refunds disabled)
Get All pending AML payments
Code: Copy
curl "https://business.payments.defexa.io/api/v1/da/aml_refunds?session_token=f3a728b408fadd87" \
-H "Authorization: Bearer merchant_private_key"
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://business.payments.defexa.io/api/v1/da/aml_refunds?session_token=f3a728b408fad",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"authorization: Bearer merchant_private_key"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://business.payments.defexa.io/api/v1/da/aml_refunds?session_token=f3a728b408fadd87fb0")
.get()
.addHeader("authorization", "Bearer merchant_private_key")
.build();
Response response = client.newCall(request).execute();
Return status 200 and JSON: Copy
{
"success": true,
"result": 0,
"status": 200,
"payments": [
{
"id": 2,
"status": "pending",
"token": "103ffca027f46708eacad35",
"currency": "ALGO",
"amount": 10.0,
"created_at": "2024-03-14T14:48:33.725Z",
"operation_type": "pay",
"order_number": "7be82c21-164b-4855-98b4-5355ae7bbb55",
"details": {
"address": "XFZJ64GXWYXY62MOHE",
"core_id": 6,
"tx_hash": "PLPYDH4JEMFZA",
"risk_score": 70,
"address_from": "GD64YIY3TWGDMCNPP553DZPPR6LDUSFQOIJVFDPPXWEG3FVOJCCDBBHU5A",
"explorer_url": "https://testnet.algoexplorer.io/tx/MFZA",
"aml_refund_disabled": true,
"merchant_private_key": "88617d07b9acfda9501c"
}
}
]
}
This endpoint retrieves all AML scoring failed pending payments.
HTTP Request via SSL
GET '/api/v1/da/aml_refunds'
Header Parameters
| Parameter | Mandatory | Description |
|---|---|---|
| Authorization | yes | "Bearer merchant_private_key" - The api key as a string. |
| Content-Type | yes | All request bodies should have content type application/json and be valid JSON. |
Query Parameters
| Parameter | Mandatory | Description |
|---|---|---|
| session_token | yes | Authorization token. |
Response Parameters
| Parameter | Description |
|---|---|
| success | true/false |
| payments | payments list |
New AML refund
Code: Copy
curl "https://business.payments.defexa.io/api/v1/da/aml_refunds" \
-X POST \
-H "Authorization: Bearer merchant_private_key" \
-H "Content-Type: application/json" -d '{
"session_token": "92c52a255578b86af2ad46705e10ef9b",
"token": "79853ee89f9c0876e66efc",
"to_address": "1234"
}'
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://business.payments.defexa.io/api/v1/da/aml_refunds",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "{ \"session_token\" : \"92c52a255578b86af2ad46705e10ef9b\", \"token\" : \"79853ee89f9c0876e66efc\", \"to_address\" : \"1234\"\n}",
CURLOPT_HTTPHEADER => array(
"authorization: Bearer merchant_private_key",
"content-type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
from django.http import HttpResponseRedirect, HttpResponse
import requests
import json
def pay(request) :
MERCHANT_PRIVATE_KEY = 'merchant_private_key'
LIVE_URL = 'https://business.payments.defexa.io/';
SANDBOX_URL = 'https://business.payments.defexa.io/'
payload = {
"session_token" : "92c52a255578b86af2ad46705e10ef9b",
"token": "79853ee89f9c0876e66efc",
"to_address": "1234"
}
headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer %s' % (MERCHANT_PRIVATE_KEY)
}
resp = requests.post('%s/api/v1/da/aml_refunds' % (SANDBOX_URL), json=payload, headers=headers)
MediaType JSON = MediaType.parse("application/json; charset=utf-8");
HashMap<String, Object> params = new HashMap<String, Object>();
params.put("session_token", "92c52a255578b86af2ad46705e10ef9b");
params.put("token", "79853ee89f9c0876e66efc");
params.put("to_address", "1234");
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://business.payments.defexa.io/api/v1/da/aml_refunds")
.post(RequestBody.create(JSON, new Gson().toJson(params)))
.addHeader("content-type", "application/json")
.addHeader("authorization", "Bearer merchant_private_key")
.build();
Call call = client.newCall(request);
call.enqueue(new Callback() {
@Override
public void onFailure(Call call, IOException e) {
Log.e("response ", "onFailure(): " + e.getMessage() );
}
@Override
public void onResponse(Call call, Response response) throws IOException {
String resp = response.body().string();
Log.e("response ", "onResponse(): " + resp );
}
});
Return status 200 and JSON: Copy
{
"success": true,
"result": 0,
"status": 200
}
This endpoint creates a new AML refund.
HTTP Request via SSL
POST '/api/v1/da/aml_refunds'
Header Parameters
| Parameter | Mandatory | Description |
|---|---|---|
| Authorization | yes | "Bearer merchant_private_key" - The api key as a string. |
| Content-Type | yes | All request bodies should have content type application/json and be valid JSON. |
Request Body
| Parameter | Mandatory | Description |
|---|---|---|
| session_token | yes | Authorization token. |
| token | yes | payment token |
| to_address | yes | address for refund |
Response Parameters
| Parameter | Description |
|---|---|
| success | true/false |
| status | status code |
Notifications
Notifications with the payment or payout status are sent to your callback URL using POST methods. In case payment or payout status changed (pending/approved/declined) -- notification type is sent accordingly.
Code: Copy
from django.views.decorators.csrf import csrf_exempt
from django.http import HttpResponseRedirect, HttpResponse, HttpResponseNotFound
@csrf_exempt
def notifyme(request) :
req_o = json.loads(request.read());
return HttpResponse('Status is:%s' % (req_o['status']))
Params: Copy
{
"address": "crypto address",
"callback_type": "payment type: pay | payout",
"net_amount" : "amount received",
"created" : "payment date",
"description" : "payment description",
"payment_id": "payment id",
"feed_id": "api feed id",
"payway": "transaction direction",
"processed": "payment update date",
"ps_currency": "payment currency",
"ps_data": {
"ps_payer_account": "payer crypto address",
"transaction_hash": "payment hash",
"client_hash": "client payment hash"
},
"amount": "original payment amount",
"shop_currency": "original payment currency",
"shop_id": "original shop id",
"shop_order_id": "original payment id",
"status": "payment status",
"client": "optional payers email",
"client_uid": "optional payers uid",
"order_number": "payment order number",
"token": "payment order token",
"signature": "callback verification signature"
}
Dictionaries
Errors
If any method failed, the JSON response with status code 403 returned that specified the problem.
Return status 403 and JSON: Copy
{'success': false, 'result': 1, 'status': 403, 'errors': {'list': [{'code': 'merchant_not_found', 'kind': 'api_error'}]}}
{'success': false, 'result': 1, 'status': 403, 'errors': [{'code': 'amount_less_than_minimum', 'kind': 'invalid_request_error'}]}
{'success': false, 'result': 1, 'status': 403, 'errors': [{'code': 'amount_less_than_balance', 'kind': 'processing_error'}]}
Payment states
| State | Final | Description |
|---|---|---|
| init | no | Request to API will initiate payments. |
| pending | no | User redirected to the Defexa Checkout facility during payment processing period. |
| approved | yes | Successfully completed payment. |
| declined | yes | Unsuccessful payment. |
Kinds of errors
| Kind | Description |
|---|---|
| api_error | Indicate rare occasions such as an Defexa API server technicality. |
| authentication_error | Authentication request failure. |
| invalid_request_error | Invalid parameters which produce invalid requests. |
| processing_error | Processing the payment generated an error. |
Codes of errors
| Code | Description |
|---|---|
| incorrect_private_key | The current private key cannot identify the user. |
| incorrect_address_info | Absent or incorrect address information. |
| incorrect_bank_card_info | Absent or incorrect bank card information. |
| order_number_already_exists | Repeating an order of already identified order number. |
| amount_less_than_balance | Payout cannot be completed due to insufficient funds. |
| incorrect_amount | Absent or incorrect amount value. |
| incorrect_currency | Absent or incorrect currency value. |
| incorrect_order_number | Absent or incorrect order value. |
| amount_less_than_minimum | Minimum payout amount has not been requested. |