executePayment
curl --request POST \
--url https://dashu.sa/api/external/executePayment \
--header 'Content-Type: application/json' \
--data '
{
"apiKey": "<string>",
"data": {
"Suppliers": [
{}
]
},
"test": true
}
'import requests
url = "https://dashu.sa/api/external/executePayment"
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/executePayment', 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/executePayment",
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/executePayment"
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/executePayment")
.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/executePayment")
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{
"IsSuccess": true,
"Message": "Invoice Created Successfully!",
"ValidationErrors": null,
"Data": {
"InvoiceId": 927972,
"IsDirectPayment": false,
"PaymentURL": "https://demo.MyFatoorah.com/Ar/KWT/PayInvoice/Checkout?invoiceKey=0106292797237&paymentGatewayId=20",
"CustomerReference": "noshipping-nosupplier"
}
}
{
"success": false,
"code": 5,
"test": true,
"message": "Invalid data",
"errors": [
{
"Name": "SessionId",
"Error": "SessionId is invalid!"
}
]
}
Embedded Integration
executePayment
Executes a payment using the SessionId you have from the initiateSession endpoint. This endpoint will return a payment URL to redirect your customers to the payment page.
POST
/
executePayment
executePayment
curl --request POST \
--url https://dashu.sa/api/external/executePayment \
--header 'Content-Type: application/json' \
--data '
{
"apiKey": "<string>",
"data": {
"Suppliers": [
{}
]
},
"test": true
}
'import requests
url = "https://dashu.sa/api/external/executePayment"
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/executePayment', 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/executePayment",
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/executePayment"
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/executePayment")
.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/executePayment")
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{
"IsSuccess": true,
"Message": "Invoice Created Successfully!",
"ValidationErrors": null,
"Data": {
"InvoiceId": 927972,
"IsDirectPayment": false,
"PaymentURL": "https://demo.MyFatoorah.com/Ar/KWT/PayInvoice/Checkout?invoiceKey=0106292797237&paymentGatewayId=20",
"CustomerReference": "noshipping-nosupplier"
}
}
{
"success": false,
"code": 5,
"test": true,
"message": "Invalid data",
"errors": [
{
"Name": "SessionId",
"Error": "SessionId is invalid!"
}
]
}
Query Parameters
string
required
The API Key of your account.
object
required
Hide properties
Hide properties
string
The SessionId you have from the
initateSession endpoint.Sample: 783851c4-b10f-4e40-bb2c-fcb657975ffb.string
The invoice total amount that should be paid by the customer.Sample:
313.14.boolean
Set this property to
true to send the request to the development
environment.{
"IsSuccess": true,
"Message": "Invoice Created Successfully!",
"ValidationErrors": null,
"Data": {
"InvoiceId": 927972,
"IsDirectPayment": false,
"PaymentURL": "https://demo.MyFatoorah.com/Ar/KWT/PayInvoice/Checkout?invoiceKey=0106292797237&paymentGatewayId=20",
"CustomerReference": "noshipping-nosupplier"
}
}
{
"success": false,
"code": 5,
"test": true,
"message": "Invalid data",
"errors": [
{
"Name": "SessionId",
"Error": "SessionId is invalid!"
}
]
}
Response properties
boolean
required
The response status.
string
required
The description of the response status.
array|null
required
List of validation errors (if any).
object
required
Hide properties
Hide properties
integer
required
A unique integer value of the created invoice.
boolean
required
true or false to indicate if this URL for Direct Payment method.string
required
The URL that you should redirect the customer to OR submit the card
details to process the payment.
string
required
Refers to the order or transaction ID in your system that you have sent in
the request earlier.
Error Codes
Here’s a list of possible error codes of this endpoint.| Code | Description |
|---|---|
| 1 | Missing or invalid api key |
| 2 | InvoiceValue is a required parameter. |
| 3 | Suppliers is not valid. |
| 4 | wrong supplier code. |
| 5 | An error meessage from the bank. |
⌘I