Create your first app
Build a working app on the test store: an account, an app, installation with the merchant's consent, a token, a first request, and notifications.
- Create a developer account
- Register your app
- Install it on the test store
- Send the merchant to the consent screen
- Exchange the code for tokens
- Make your first request
- Receive notifications
- Send it for review
Create a developer account
Create your account as a person or a company, then confirm your email from the link we send. You can build and test right away; Naqllah verifies your identity before any app is sent for review.
Register your app
In «My apps», create an app: name and description, return addresses, notification address, and the permissions with a reason for each. The app secret and the webhook secret show once only, so store them safely.
- Return addresses must start with
https://and match exactly. While testing on the test store,http://localhostis also accepted. - The notification address must be https on a public host. Leave it empty until your server is ready.
- Choose only the scopes the app needs, with a reason for each: the merchant reads your reasons on the consent screen.
Install it on the test store
Any app that is not suspended installs on the test store sandbox with no review and no payment. Testing with the test store
Send the merchant to the consent screen
Create a random verifier and state, keep them in the session, and send the merchant to the authorize address with the verifier's challenge.
VERIFIER=$(openssl rand -base64 48 | tr -d '=+/\n' | cut -c1-64)
CHALLENGE=$(printf '%s' "$VERIFIER" | openssl dgst -sha256 -binary | openssl base64 | tr '+/' '-_' | tr -d '=\n')
STATE=$(openssl rand -hex 16)
<?php
$verifier = rtrim(strtr(base64_encode(random_bytes(48)), '+/', '-_'), '=');
$challenge = rtrim(strtr(base64_encode(hash('sha256', $verifier, true)), '+/', '-_'), '=');
$state = bin2hex(random_bytes(16));
// keep both until the merchant comes back
$_SESSION['pkce_verifier'] = $verifier;
$_SESSION['oauth_state'] = $state;
import crypto from 'node:crypto';
const verifier = crypto.randomBytes(48).toString('base64url');
const challenge = crypto.createHash('sha256').update(verifier).digest('base64url');
const state = crypto.randomBytes(16).toString('hex');
// keep both until the merchant comes back
req.session.pkceVerifier = verifier;
req.session.oauthState = state;
import base64, hashlib, secrets
verifier = secrets.token_urlsafe(48)
challenge = base64.urlsafe_b64encode(
hashlib.sha256(verifier.encode()).digest()
).rstrip(b"=").decode()
state = secrets.token_hex(16)
# keep both until the merchant comes back
session["pkce_verifier"] = verifier
session["oauth_state"] = state
https://naqllah.com/dashboard/apps/authorize?response_type=code&client_id=app_…&redirect_uri=https://your.app/callback&scope=store.read%20orders.read%20webhooks.read&state=STATE&code_challenge=CHALLENGE&code_challenge_method=S256
Exchange the code for tokens
The merchant comes back to your return address with a code and the same state. Check the state, then exchange the code from your server.
curl -X POST "https://naqllah.com/oauth/token" \
-u "$NAQLLAH_CLIENT_ID:$NAQLLAH_CLIENT_SECRET" \
-d grant_type=authorization_code \
-d code="$CODE" \
-d redirect_uri=https://your.app/callback \
-d code_verifier="$CODE_VERIFIER"
<?php
if (! hash_equals($_SESSION['oauth_state'] ?? '', $_GET['state'] ?? '')) {
http_response_code(400);
exit;
}
$ch = curl_init('https://naqllah.com/oauth/token');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_USERPWD => getenv('NAQLLAH_CLIENT_ID') . ':' . getenv('NAQLLAH_CLIENT_SECRET'),
CURLOPT_POSTFIELDS => http_build_query([
'grant_type' => 'authorization_code',
'code' => $_GET['code'],
'redirect_uri' => 'https://your.app/callback',
'code_verifier' => $_SESSION['pkce_verifier'],
]),
]);
$token = json_decode(curl_exec($ch), true);
// $token['access_token'], $token['refresh_token'], $token['expires_in']
if (req.query.state !== req.session.oauthState) return res.sendStatus(400);
const code = req.query.code;
const codeVerifier = req.session.pkceVerifier;
const basic = Buffer.from(
`${process.env.NAQLLAH_CLIENT_ID}:${process.env.NAQLLAH_CLIENT_SECRET}`,
).toString('base64');
const res = await fetch('https://naqllah.com/oauth/token', {
method: 'POST',
headers: { Authorization: `Basic ${basic}` },
body: new URLSearchParams({
grant_type: 'authorization_code',
code: code,
redirect_uri: 'https://your.app/callback',
code_verifier: codeVerifier,
}),
});
const token = await res.json();
import os, secrets
import requests
if not secrets.compare_digest(session.get("oauth_state", ""), request.args.get("state", "")):
abort(400)
code = request.args["code"]
code_verifier = session["pkce_verifier"]
res = requests.post(
"https://naqllah.com/oauth/token",
auth=(os.environ["NAQLLAH_CLIENT_ID"], os.environ["NAQLLAH_CLIENT_SECRET"]),
data={
"grant_type": "authorization_code",
"code": code,
"redirect_uri": "https://your.app/callback",
"code_verifier": code_verifier,
},
timeout=10,
)
token = res.json()
Make your first request
curl "https://naqllah.com/api/apps/v1/store" \
-H "Authorization: Bearer $NAQLLAH_ACCESS_TOKEN"
<?php
$ch = curl_init('https://naqllah.com/api/apps/v1/store');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 10,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('NAQLLAH_ACCESS_TOKEN'),
'Accept: application/json',
],
]);
$body = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
$json = json_decode($body, true);
if ($status >= 400) {
throw new RuntimeException($json['error'] ?? 'http_' . $status);
}
$data = $json['data'];
// Node.js 18+ (fetch is built in)
const res = await fetch('https://naqllah.com/api/apps/v1/store', {
headers: {
Authorization: `Bearer ${process.env.NAQLLAH_ACCESS_TOKEN}`,
Accept: 'application/json',
},
});
const json = await res.json();
if (!res.ok) throw new Error(json.error);
const { data } = json;
import os
import requests
res = requests.get(
"https://naqllah.com/api/apps/v1/store",
headers={
"Authorization": f"Bearer {os.environ['NAQLLAH_ACCESS_TOKEN']}",
"Accept": "application/json",
},
timeout=10,
)
body = res.json()
if res.status_code >= 400:
raise RuntimeError(body["error"])
data = body["data"]
{
"data": {
"id": 1042,
"uuid": "9b2f6c1e-4d3a-4f7b-a1c2-5e8d0f9a7b31",
"name": "متجر الريم",
"currency": "SAR",
"locale": "ar",
"timezone": "Asia/Riyadh"
}
}
Everything about this endpoint
Receive notifications
Choose events in the app form, grant webhooks.read, and verify each notification's signature before you trust it. Webhooks
Send it for review
When the app works on the test store from install to uninstall, send it for review from the app page. Publishing and review
Version v1.0.0 Changelog Service status openapi-v1.json Support