Initiate Session
curl --request POST \
--url https://dashu.sa/api/external/initSession \
--header 'Content-Type: application/json' \
--data '
{
"apiKey": "<string>",
"data": {
"Suppliers": [
{}
]
},
"test": true
}
'import requests
url = "https://dashu.sa/api/external/initSession"
payload = {
"apiKey": "<string>",
"data": { "Suppliers": [{}] },
"test": True
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({apiKey: '<string>', data: {Suppliers: [{}]}, test: true})
};
fetch('https://dashu.sa/api/external/initSession', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://dashu.sa/api/external/initSession",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'apiKey' => '<string>',
'data' => [
'Suppliers' => [
[
]
]
],
'test' => true
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://dashu.sa/api/external/initSession"
payload := strings.NewReader("{\n \"apiKey\": \"<string>\",\n \"data\": {\n \"Suppliers\": [\n {}\n ]\n },\n \"test\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://dashu.sa/api/external/initSession")
.header("Content-Type", "application/json")
.body("{\n \"apiKey\": \"<string>\",\n \"data\": {\n \"Suppliers\": [\n {}\n ]\n },\n \"test\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://dashu.sa/api/external/initSession")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"apiKey\": \"<string>\",\n \"data\": {\n \"Suppliers\": [\n {}\n ]\n },\n \"test\": true\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"test": false,
"paymentURL": "https://dashu.sa/api/external/pay?hash=h3qds2paiy-fko9bgd0et-mj94pv32tn"
}
{
"success": false,
"code": 2,
"message": "`CallBackUrl` is a required parameter."
}
Redirect Integration
Initiate Session
Initiate new session for a payment. This endpoint will help you get the paymentURL that you can use to redirect the customer to in order to complete the payment.
POST
/
initSession
Initiate Session
curl --request POST \
--url https://dashu.sa/api/external/initSession \
--header 'Content-Type: application/json' \
--data '
{
"apiKey": "<string>",
"data": {
"Suppliers": [
{}
]
},
"test": true
}
'import requests
url = "https://dashu.sa/api/external/initSession"
payload = {
"apiKey": "<string>",
"data": { "Suppliers": [{}] },
"test": True
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({apiKey: '<string>', data: {Suppliers: [{}]}, test: true})
};
fetch('https://dashu.sa/api/external/initSession', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://dashu.sa/api/external/initSession",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'apiKey' => '<string>',
'data' => [
'Suppliers' => [
[
]
]
],
'test' => true
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://dashu.sa/api/external/initSession"
payload := strings.NewReader("{\n \"apiKey\": \"<string>\",\n \"data\": {\n \"Suppliers\": [\n {}\n ]\n },\n \"test\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://dashu.sa/api/external/initSession")
.header("Content-Type", "application/json")
.body("{\n \"apiKey\": \"<string>\",\n \"data\": {\n \"Suppliers\": [\n {}\n ]\n },\n \"test\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://dashu.sa/api/external/initSession")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"apiKey\": \"<string>\",\n \"data\": {\n \"Suppliers\": [\n {}\n ]\n },\n \"test\": true\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"test": false,
"paymentURL": "https://dashu.sa/api/external/pay?hash=h3qds2paiy-fko9bgd0et-mj94pv32tn"
}
{
"success": false,
"code": 2,
"message": "`CallBackUrl` is a required parameter."
}
Query Parameters
string
required
The API Key of your account.
object
required
Hide properties
Hide properties
string
required
The URL that will be used to redirect the customer after the payment process is done.
string
required
The URL that will be used to redirect the customer after the payment process is failed.
array
required
Any value you want to store with the invoice (you can get it later using the Payment Inquiry method). This can be a user identifier or a transaction Id in your system.
string
required
The total amount you want the customer to pay.
boolean
Set this property to
true to send the request to the development
environment.{
"success": true,
"test": false,
"paymentURL": "https://dashu.sa/api/external/pay?hash=h3qds2paiy-fko9bgd0et-mj94pv32tn"
}
{
"success": false,
"code": 2,
"message": "`CallBackUrl` is a required parameter."
}
Response properties
boolean
required
A boolean value indicates the response status.
boolean
required
A boolean value indicates the development environment status.
string
required
The payment URL that you’ll use to redirect the cusotmer to complete the
payment. It’s a link for a hosted page that will provide multiple payment
methods that can be choosed by the customer to pay the invoice.
Error Codes
Here’s a list of possible error codes of this endpoint.| Code | Description |
|---|---|
| 1 | Missing or invalid api key |
| 2 | CallBackUrl is a required parameter. |
| 3 | UserDefinedField is a required parameter. |
| 4 | InvoiceValue is a required parameter. |
| 5 | Suppliers is a required parameter. |
| 6 | ErrorUrl is a required parameter. |
| 7 | CallBackUrl should be a valid URL. |
| 8 | UserDefinedField should be an array. |
| 9 | InvoiceValue should be greater than zero. |
| 10 | Suppliers should be an array. |
| 11 | ErrorUrl should be a valid URL. |
⌘I