Skip to content

Commit 603fa54

Browse files
committed
add code snippets for vt update endpoint
1 parent b87266b commit 603fa54

File tree

5 files changed

+97
-0
lines changed

5 files changed

+97
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
languages:
2+
- sh
3+
- js
4+
- php
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
const https = require('https')
2+
3+
const params = JSON.stringify({
4+
"name": "New terminal name"
5+
})
6+
7+
const options = {
8+
hostname: 'api.paystack.co',
9+
port: 443,
10+
path: '/virtual_terminal/:code',
11+
method: 'PUT',
12+
headers: {
13+
Authorization: 'Bearer SECRET_KEY',
14+
'Content-Type': 'application/json',
15+
'Content-Length': Buffer.byteLength(params)
16+
}
17+
}
18+
19+
const req = https.request(options, res => {
20+
let data = ''
21+
22+
res.on('data', (chunk) => {
23+
data += chunk
24+
})
25+
26+
res.on('end', () => {
27+
console.log(JSON.parse(data))
28+
})
29+
})
30+
31+
req.on('error', error => {
32+
console.error(error)
33+
})
34+
35+
req.write(params)
36+
req.end()
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
$curl = curl_init();
3+
4+
$data = array({
5+
"name": "New terminal name"
6+
});
7+
8+
curl_setopt_array($curl, array(
9+
CURLOPT_URL => "https://api.paystack.co/virtual_terminal/:code",
10+
CURLOPT_RETURNTRANSFER => true,
11+
CURLOPT_CUSTOMREQUEST => "PUT",
12+
CURLOPT_POSTFIELDS => json_encode($data),
13+
CURLOPT_HTTPHEADER => array(
14+
"Authorization: Bearer SECRET_KEY",
15+
"Content-Type: application/json",
16+
"Cache-Control: no-cache"
17+
),
18+
));
19+
20+
$response = curl_exec($curl);
21+
$err = curl_error($curl);
22+
curl_close($curl);
23+
24+
if ($err) {
25+
echo "cURL Error #:" . $err;
26+
} else {
27+
echo $response;
28+
}
29+
?>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/sh
2+
url="https://api.paystack.co/virtual_terminal/:code"
3+
authorization="Authorization: Bearer SECRET_KEY"
4+
content_type="Content-Type: application/json"
5+
data='{
6+
"name": "New terminal name"
7+
}'
8+
9+
curl "$url" -H "$authorization" -H "$content_type" -X PUT -d "$data"
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"400": {
3+
"status": false,
4+
"message": "\"name\" is required",
5+
"meta": { "nextStep": "Provide all required params " },
6+
"type": "validation_error",
7+
"code": "missing_params"
8+
},
9+
"404": {
10+
"description": "404 Not Found",
11+
"data": {
12+
"status": false,
13+
"message": "Virtual Terminal not assigned",
14+
"meta": { "nextStep": "Try again later" },
15+
"type": "api_error",
16+
"code": "unknown"
17+
}
18+
}
19+
}

0 commit comments

Comments
 (0)