Authentication - Login
This API will take merchant credentials such as SadadId, webssite and secretkey and provide access token if request is correct. For authentication, merchants should be registered in Sadad Payment Solution. Merchant should have SadadID, registered website and valid secret key. You have to generate secret API Keys for the test and live modes. No real money is used in test mode.
- POST
Sandbox
https://api-sandbox.sadad.qa/api/userbusinesses/login
Live
https://api-s.sadad.qa/api/userbusinesses/login
Permission: Merchant
- Curl
- Ruby
- Python
- PHP
- Java
- Node.js
- Go
- .NET
curl -d '{"sadadId": 9288463, "secretKey": "aXXXXXXXXXXXXXX7", "domain": "www.xxxxxxx.com"}' -H "Content-Type: application/json" -X POST https://api-s.sadad.qa/api/userbusinesses/login
require 'net/http'
require 'uri'
require 'json'
uri = URI("https://api-s.sadad.qa/api/userbusinesses/login")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri)
request["Content-Type"] = "application/json"
request.body = {
sadadId: 9288463,
secretKey: "aXXXXXXXXXXXXXX7",
domain: "www.xxxxxxx.com"
}.to_json
response = http.request(request)
puts response.body
import requests
url = "https://api-s.sadad.qa/api/userbusinesses/login"
payload = {
"sadadId": 9288463,
"secretKey": "aXXXXXXXXXXXXXX7",
"domain": "www.xxxxxxx.com"
}
headers = {
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)
<?php
$url = "https://api-s.sadad.qa/api/userbusinesses/login";
$data = json_encode([
"sadadId" => 9288463,
"secretKey" => "aXXXXXXXXXXXXXX7",
"domain" => "www.xxxxxxx.com"
]);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Content-Type: application/json"
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class SadadLogin {
public static void main(String[] args) throws Exception {
String json = """
{
"sadadId": 9288463,
"secretKey": "aXXXXXXXXXXXXXX7",
"domain": "www.xxxxxxx.com"
}
""";
HttpRequest request = HttpRequest.newBuilder()
.uri(new URI("https://api-s.sadad.qa/api/userbusinesses/login"))
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(json))
.build();
HttpClient client = HttpClient.newHttpClient();
HttpResponse<String> response =
client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
fetch("https://api-s.sadad.qa/api/userbusinesses/login", {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({
sadadId: 9288463,
secretKey: "aXXXXXXXXXXXXXX7",
domain: "www.xxxxxxx.com"
})
})
.then(res => res.json())
.then(data => console.log(data))
.catch(err => console.error(err));
package main
import (
"bytes"
"fmt"
"net/http"
)
func main() {
jsonData := []byte(`{
"sadadId": 9288463,
"secretKey": "aXXXXXXXXXXXXXX7",
"domain": "www.xxxxxxx.com"
}`)
req, _ := http.NewRequest("POST", "https://api-s.sadad.qa/api/userbusinesses/login", bytes.NewBuffer(jsonData))
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, _ := client.Do(req)
fmt.Println(resp.Status)
}
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
var client = new HttpClient();
var json = @"{
""sadadId"": 9288463,
""secretKey"": ""aXXXXXXXXXXXXXX7"",
""domain"": ""www.xxxxxxx.com""
}";
var content = new StringContent(json, Encoding.UTF8, "application/json");
var response = await client.PostAsync(
"https://api-s.sadad.qa/api/userbusinesses/login",
content
);
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
}
}
| Field | Type | Description |
|---|---|---|
| sadadId | Number | Unique Sadad user Id |
| secretKey | String | API secret key generated by merchant |
| domain | String | Domain name for which the API key is generated |
- Request-Example
{
"sadadId": 9288463,
"secretKey": "aXXXXXXXXXXXXXX7",
"domain": "www.xxxxxxx.com"
}
Success 200
| Field | Type | Description |
|---|---|---|
| accessToken | String | The accesstoken using which merchant can use other APIs. |
- Success-Response
{
"accessToken": "EUgQYPvPTfCzb7dUW67kT4725jNB31ISxTE0oHQfna4lEyrGNcBlVIn0OyYepVSd"
}
Error 4xx
| Field | Description |
|---|---|
| 401 | Invalid credentials! |
| 400 | User is blocked! |
- Error-Response
{
"error": {
"statusCode": 401,
"name": "Error",
"message": "Invalid credentials !"
}
}