File tree Expand file tree Collapse file tree 5 files changed +97
-0
lines changed
src/api/virtual-terminal/update Expand file tree Collapse file tree 5 files changed +97
-0
lines changed Original file line number Diff line number Diff line change 1+ languages :
2+ - sh
3+ - js
4+ - php
Original file line number Diff line number Diff line change 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 ( )
Original file line number Diff line number Diff line change 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+ ?>
Original file line number Diff line number Diff line change 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 "
Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments