Create session
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.
Environments
There are two environments available for integration:
- Production environment: https://business.payments.defexa.io/
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 |
API Base URL: https://business.payments.defexa.io/
- Shell
- PHP
- Python
- Java
- Response JSON
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);
}
});{
"success": true,
"status": 200,
"expiration": "2023-03-28 22:52:59 UTC",
"session_token": "7e7b4119f4d8322daf616733515d9b99",
"user_id": 173
}