Skip to content

Commit 35d3e68

Browse files
Merge pull request #121 from tolu-paystack/docs/add-storefront-order-api
Add Storefront and Order APIs to API reference
2 parents 8b9b330 + e4ac46e commit 35d3e68

File tree

112 files changed

+2532
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

112 files changed

+2532
-0
lines changed

dist/api/order/create/requests.js

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
const sh = `#!/bin/sh
2+
url="https://api.paystack.co/order"
3+
authorization="Authorization: Bearer YOUR_SECRET_KEY"
4+
content_type="Content-Type: application/json"
5+
data='{
6+
"customer": "CUS_abc123def456",
7+
"line_items": [
8+
{
9+
"product": 2196244,
10+
"quantity": 2
11+
}
12+
]
13+
}'
14+
15+
curl "$url" -H "$authorization" -H "$content_type" -d "$data" -X POST
16+
`
17+
18+
const js = `const https = require('https')
19+
20+
const params = JSON.stringify({
21+
"customer": "CUS_abc123def456",
22+
"line_items": [
23+
{
24+
"product": 2196244,
25+
"quantity": 2
26+
}
27+
]
28+
})
29+
30+
const options = {
31+
hostname: 'api.paystack.co',
32+
port: 443,
33+
path: '/order',
34+
method: 'POST',
35+
headers: {
36+
Authorization: 'Bearer SECRET_KEY',
37+
'Content-Type': 'application/json'
38+
}
39+
}
40+
41+
const req = https.request(options, res => {
42+
let data = ''
43+
44+
res.on('data', (chunk) => {
45+
data += chunk
46+
});
47+
48+
res.on('end', () => {
49+
console.log(JSON.parse(data))
50+
})
51+
}).on('error', error => {
52+
console.error(error)
53+
})
54+
55+
req.write(params)
56+
req.end()
57+
`
58+
59+
const php = `<?php
60+
$url = "https://api.paystack.co/order";
61+
62+
$fields = [
63+
'customer' => "CUS_abc123def456",
64+
'line_items' => [
65+
[
66+
'product' => 2196244,
67+
'quantity' => 2
68+
]
69+
]
70+
];
71+
72+
$fields_string = json_encode($fields);
73+
74+
$ch = curl_init();
75+
76+
curl_setopt($ch,CURLOPT_URL, $url);
77+
curl_setopt($ch,CURLOPT_POST, true);
78+
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
79+
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
80+
"Authorization: Bearer SECRET_KEY",
81+
"Content-Type: application/json",
82+
"Cache-Control: no-cache",
83+
));
84+
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
85+
86+
$result = curl_exec($ch);
87+
echo $result;
88+
?>
89+
`
90+
91+
export {sh, js, php}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"200": {
3+
"description": "200 Ok",
4+
"data": {
5+
"status": true,
6+
"message": "Order created",
7+
"data": {
8+
"id": 12345,
9+
"code": "ORD_abc123def456",
10+
"amount": 20000,
11+
"currency": "NGN",
12+
"status": "pending",
13+
"customer": {
14+
"id": 297346561,
15+
"email": "customer@email.com"
16+
},
17+
"line_items": [
18+
{
19+
"product": {
20+
"id": 2196244,
21+
"name": "Sample Product"
22+
},
23+
"quantity": 2,
24+
"amount": 20000
25+
}
26+
],
27+
"createdAt": "2024-11-01T12:00:00.000Z"
28+
}
29+
}
30+
}
31+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
const sh = `#!/bin/sh
2+
url="https://api.paystack.co/order/product/2196244"
3+
authorization="Authorization: Bearer YOUR_SECRET_KEY"
4+
5+
curl "$url" -H "$authorization" -X GET
6+
`
7+
8+
const js = `const https = require('https')
9+
10+
const options = {
11+
hostname: 'api.paystack.co',
12+
port: 443,
13+
path: '/order/product/2196244',
14+
method: 'GET',
15+
headers: {
16+
Authorization: 'Bearer SECRET_KEY'
17+
}
18+
}
19+
20+
const req = https.request(options, res => {
21+
let data = ''
22+
23+
res.on('data', (chunk) => {
24+
data += chunk
25+
});
26+
27+
res.on('end', () => {
28+
console.log(JSON.parse(data))
29+
})
30+
}).on('error', error => {
31+
console.error(error)
32+
})
33+
34+
req.end()
35+
`
36+
37+
const php = `<?php
38+
$url = "https://api.paystack.co/order/product/2196244";
39+
40+
$ch = curl_init();
41+
42+
curl_setopt($ch,CURLOPT_URL, $url);
43+
curl_setopt($ch,CURLOPT_HTTPHEADER, array(
44+
"Authorization: Bearer SECRET_KEY",
45+
"Cache-Control: no-cache",
46+
));
47+
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
48+
49+
$result = curl_exec($ch);
50+
echo $result;
51+
?>
52+
`
53+
54+
export {sh, js, php}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"200": {
3+
"description": "200 Ok",
4+
"data": {
5+
"status": true,
6+
"message": "Product orders retrieved",
7+
"data": [
8+
{
9+
"id": 12345,
10+
"code": "ORD_abc123def456",
11+
"amount": 20000,
12+
"currency": "NGN",
13+
"status": "success",
14+
"customer": {
15+
"email": "customer@email.com"
16+
},
17+
"createdAt": "2024-11-01T12:00:00.000Z"
18+
}
19+
],
20+
"meta": {
21+
"total": 1,
22+
"skipped": 0,
23+
"perPage": 50,
24+
"page": 1,
25+
"pageCount": 1
26+
}
27+
}
28+
}
29+
}

dist/api/order/fetch/requests.js

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
const sh = `#!/bin/sh
2+
url="https://api.paystack.co/order/12345"
3+
authorization="Authorization: Bearer YOUR_SECRET_KEY"
4+
5+
curl "$url" -H "$authorization" -X GET
6+
`
7+
8+
const js = `const https = require('https')
9+
10+
const options = {
11+
hostname: 'api.paystack.co',
12+
port: 443,
13+
path: '/order/12345',
14+
method: 'GET',
15+
headers: {
16+
Authorization: 'Bearer SECRET_KEY'
17+
}
18+
}
19+
20+
const req = https.request(options, res => {
21+
let data = ''
22+
23+
res.on('data', (chunk) => {
24+
data += chunk
25+
});
26+
27+
res.on('end', () => {
28+
console.log(JSON.parse(data))
29+
})
30+
}).on('error', error => {
31+
console.error(error)
32+
})
33+
34+
req.end()
35+
`
36+
37+
const php = `<?php
38+
$url = "https://api.paystack.co/order/12345";
39+
40+
$ch = curl_init();
41+
42+
curl_setopt($ch,CURLOPT_URL, $url);
43+
curl_setopt($ch,CURLOPT_HTTPHEADER, array(
44+
"Authorization: Bearer SECRET_KEY",
45+
"Cache-Control: no-cache",
46+
));
47+
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
48+
49+
$result = curl_exec($ch);
50+
echo $result;
51+
?>
52+
`
53+
54+
export {sh, js, php}

dist/api/order/fetch/response.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"200": {
3+
"description": "200 Ok",
4+
"data": {
5+
"status": true,
6+
"message": "Order retrieved",
7+
"data": {
8+
"id": 12345,
9+
"code": "ORD_abc123def456",
10+
"amount": 20000,
11+
"currency": "NGN",
12+
"status": "success",
13+
"customer": {
14+
"id": 297346561,
15+
"email": "customer@email.com"
16+
},
17+
"line_items": [
18+
{
19+
"product": {
20+
"id": 2196244,
21+
"name": "Sample Product"
22+
},
23+
"quantity": 2,
24+
"amount": 20000
25+
}
26+
],
27+
"createdAt": "2024-11-01T12:00:00.000Z"
28+
}
29+
}
30+
}
31+
}

dist/api/order/list/requests.js

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
const sh = `#!/bin/sh
2+
url="https://api.paystack.co/order"
3+
authorization="Authorization: Bearer YOUR_SECRET_KEY"
4+
5+
curl "$url" -H "$authorization" -X GET
6+
`
7+
8+
const js = `const https = require('https')
9+
10+
const options = {
11+
hostname: 'api.paystack.co',
12+
port: 443,
13+
path: '/order',
14+
method: 'GET',
15+
headers: {
16+
Authorization: 'Bearer SECRET_KEY'
17+
}
18+
}
19+
20+
const req = https.request(options, res => {
21+
let data = ''
22+
23+
res.on('data', (chunk) => {
24+
data += chunk
25+
});
26+
27+
res.on('end', () => {
28+
console.log(JSON.parse(data))
29+
})
30+
}).on('error', error => {
31+
console.error(error)
32+
})
33+
34+
req.end()
35+
`
36+
37+
const php = `<?php
38+
$url = "https://api.paystack.co/order";
39+
40+
$ch = curl_init();
41+
42+
curl_setopt($ch,CURLOPT_URL, $url);
43+
curl_setopt($ch,CURLOPT_HTTPHEADER, array(
44+
"Authorization: Bearer SECRET_KEY",
45+
"Cache-Control: no-cache",
46+
));
47+
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
48+
49+
$result = curl_exec($ch);
50+
echo $result;
51+
?>
52+
`
53+
54+
export {sh, js, php}

dist/api/order/list/response.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"200": {
3+
"description": "200 Ok",
4+
"data": {
5+
"status": true,
6+
"message": "Orders retrieved",
7+
"data": [
8+
{
9+
"id": 12345,
10+
"code": "ORD_abc123def456",
11+
"amount": 20000,
12+
"currency": "NGN",
13+
"status": "success",
14+
"customer": {
15+
"email": "customer@email.com"
16+
},
17+
"createdAt": "2024-11-01T12:00:00.000Z"
18+
}
19+
],
20+
"meta": {
21+
"total": 1,
22+
"skipped": 0,
23+
"perPage": 50,
24+
"page": 1,
25+
"pageCount": 1
26+
}
27+
}
28+
}
29+
}

0 commit comments

Comments
 (0)