1+ const sh = `#!/bin/sh
2+ url="https://api.paystack.co/virtual_terminal"
3+ authorization="Authorization: Bearer SECRET_KEY"
4+ content_type="Content-Type: application/json"
5+ data='{
6+ "name": "Sample Terminal",
7+ "destinations": [
8+ {
9+ "target": "+27639022319",
10+ "name": "Phone Destination"
11+ }
12+ ]
13+ }'
14+
15+ curl "$url" \
16+ -H "$authorization" \
17+ -H "$content_type" \
18+ -X POST \
19+ -d "$data"
20+
21+ `
22+
23+ const js = `const https = require("https");
24+
25+ const params = JSON.stringify({
26+ name: "Sample Terminal",
27+ destinations: [
28+ {
29+ target: "+27639022319",
30+ name: "Phone Destination",
31+ },
32+ ],
33+ });
34+
35+ const options = {
36+ hostname: "api.paystack.co",
37+ port: 443,
38+ path: "/virtual_terminal",
39+ method: "POST",
40+ headers: {
41+ Authorization: "Bearer SECRET_KEY",
42+ "Content-Type": "application/json",
43+ },
44+ };
45+
46+ const req = https.request(options, (res) => {
47+ let data = "";
48+
49+ res.on("data", (chunk) => {
50+ data += chunk;
51+ });
52+
53+ res.on("end", () => {
54+ console.log(JSON.parse(data));
55+ });
56+ });
57+
58+ req.on("error", (error) => {
59+ console.error(error);
60+ });
61+
62+ req.write(params);
63+ req.end();
64+ `
65+
66+ const php = `<?php
67+ $curl = curl_init();
68+
69+ $data = array(
70+ "name" => "Sample Terminal",
71+ "destinations" => array(
72+ array(
73+ "target" => "+27639022319",
74+ "name" => "Phone Destination"
75+ )
76+ )
77+ );
78+
79+ curl_setopt_array($curl, array(
80+ CURLOPT_URL => "https://api.paystack.co/virtual_terminal",
81+ CURLOPT_RETURNTRANSFER => true,
82+ CURLOPT_CUSTOMREQUEST => "POST",
83+ CURLOPT_POSTFIELDS => json_encode($data),
84+ CURLOPT_HTTPHEADER => array(
85+ "Authorization: Bearer SECRET_KEY",
86+ "Content-Type: application/json",
87+ "Cache-Control: no-cache"
88+ ),
89+ ));
90+
91+ $response = curl_exec($curl);
92+ $err = curl_error($curl);
93+ curl_close($curl);
94+
95+ if ($err) {
96+ echo "cURL Error #:" . $err;
97+ } else {
98+ echo $response;
99+ }
100+ ?>
101+ `
102+
103+ export { sh , js , php }
0 commit comments