Payment
Get Payments
GET
https://api.stretch.com/api/v1/payments
Code sample
cURL Python PHP Java Ruby Node.js .NET Go Dart
curl -X GET \
--url "https://api.stretch.com/api/v1/payments" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
import requests
headers = {
"Content-Type" : "application/json" ,
"Authorization" : "Bearer YOUR_ACCESS_TOKEN"
}
try :
response = requests . get ( "https://api.stretch.com/api/v1/payments, headers=headers" )
print ( response . json ())
except requests . exceptions . HTTPError as errh :
print ( "HTTP Error:" , errh )
except requests . exceptions . RequestException as errex :
print ( "Exception request:" , errex )
<?php
$url = "https://api.stretch.com/api/v1/payments" ;
$headers = array (
"Content-Type: application/json" ,
"Authorization: Bearer YOUR_ACCESS_TOKEN" ,
);
$ch = curl_init ();
curl_setopt ( $ch , CURLOPT_URL , $url );
curl_setopt ( $ch , CURLOPT_HTTPHEADER , $headers );
curl_setopt ( $ch , CURLOPT_RETURNTRANSFER , true );
curl_setopt ( $ch , CURLOPT_FAILONERROR , true );
$response = curl_exec ( $ch );
if ( curl_errno ( $ch )) {
$error_msg = curl_error ( $ch );
echo "Exception request: " . $error_msg ;
} else {
if ( curl_getinfo ( $ch , CURLINFO_HTTP_CODE ) != 200 ) {
echo "HTTP Error: " . curl_getinfo ( $ch , CURLINFO_HTTP_CODE );
} else {
echo $response ;
}
}
curl_close ( $ch );
?>
import java.io.BufferedReader ;
import java.io.IOException ;
import java.io.InputStreamReader ;
import java.net.HttpURLConnection ;
import java.net.MalformedURLException ;
import java.net.URL ;
public class Main {
public static void main ( String [] args ) {
String url = "https://api.stretch.com/api/v1/payments" ;
String accessToken = "YOUR_ACCESS_TOKEN" ;
try {
URL apiUrl = new URL ( url );
HttpURLConnection connection = ( HttpURLConnection ) apiUrl . openConnection ();
connection . setRequestMethod ( "GET" );
connection . setRequestProperty ( "Content-Type" , "application/json" );
connection . setRequestProperty ( "Authorization" , "Bearer " + accessToken );
int responseCode = connection . getResponseCode ();
if ( responseCode == HttpURLConnection . HTTP_OK ) {
BufferedReader in = new BufferedReader ( new InputStreamReader ( connection . getInputStream ()));
String inputLine ;
StringBuilder content = new StringBuilder ();
while (( inputLine = in . readLine ()) != null ) {
content . append ( inputLine );
}
in . close ();
System . out . println ( content . toString ());
} else {
System . out . println ( "HTTP Error: " + responseCode );
}
connection . disconnect ();
} catch ( MalformedURLException e ) {
System . out . println ( "Exception request: " + e . getMessage ());
} catch ( IOException e ) {
System . out . println ( "Exception request: " + e . getMessage ());
}
}
}
require 'net/http'
require 'uri'
require 'json'
url = 'https://api.stretch.com/api/v1/payments'
access_token = 'YOUR_ACCESS_TOKEN'
uri = URI . parse ( url )
http = Net :: HTTP . new ( uri . host , uri . port )
http . use_ssl = true
headers = {
'Content-Type' => 'application/json' ,
'Authorization' => "Bearer #{ access_token } "
}
begin
request = Net :: HTTP :: Get . new ( uri . request_uri , headers )
response = http . request ( request )
if response . code . to_i == 200
puts JSON . parse ( response . body )
else
puts "HTTP Error: #{ response . code } "
end
rescue => e
puts "Exception request: #{ e . message } "
end
const axios = require ( 'axios' );
const url = 'https://api.stretch.com/api/v1/payments' ;
const headers = {
'Content-Type' : 'application/json' ,
'Authorization' : 'Bearer YOUR_ACCESS_TOKEN' ,
};
axios
. get ( url ,{ headers })
. then (( response ) => {
console . log ( response . data );
})
. catch (( error ) => {
if ( error . response ) {
console . log ( 'HTTP Error:' , error . response . status );
} else {
console . log ( 'Exception request:' , error . message );
}
});
using System ;
using System.Net.Http ;
async Task Main () {
using ( var client = new HttpClient ()) {
client . DefaultRequestHeaders . Add ( "Content-Type" , "application/json" ); var response = await client . GetAsync ( new Uri ( "https://api.stretch.com/api/v1/payments" )
if ( response . IsSuccessStatusCode ) {
var content = await response . Content . ReadAsStringAsync ();
Console . WriteLine ( content );
} else {
Console . WriteLine ( $"Request failed with status code: {(int)response.StatusCode}" );
}
}
}
package main
import (
"fmt"
"io/ioutil"
"net/http"
)
func main () {
url := "https://api.stretch.com/api/v1/payments"
accessToken := "YOUR_ACCESS_TOKEN"
client := & http . Client {}
req , err := http . NewRequest ( "GET" , url , nil )
if err != nil {
fmt . Println ( "Exception request:" , err )
return
}
req . Header . Add ( "Content-Type" , "application/json" )
req . Header . Add ( "Authorization" , "Bearer " + accessToken )
resp , err := client . Do ( req )
if err != nil {
fmt . Println ( "Exception request:" , err )
return
}
defer resp . Body . Close ()
if resp . StatusCode == http . StatusOK {
body , err := ioutil . ReadAll ( resp . Body )
if err != nil {
fmt . Println ( "Exception request:" , err )
return
}
fmt . Println ( string ( body ))
} else {
fmt . Println ( "HTTP Error:" , resp . StatusCode )
}
}
import 'dart:convert' ;
import 'package:http/http.dart' as http ;
void main () async {
final url = 'https://api.stretch.com/api/v1/payments' ;
final accessToken = 'YOUR_ACCESS_TOKEN' ;
final headers = {
'Content-Type' : 'application/json' ,
'Authorization' : 'Bearer $ accessToken ' ,
};
try { final response = await http . get ( Uri . parse ( url ), headers: headers );
if ( response . statusCode == 200 ) {
print ( jsonDecode ( response . body ));
} else {
print ( 'HTTP Error: ${ response . statusCode } ' );
}
} catch ( e ) {
print ( 'Exception request: $ e ' );
}
}
Response
[{
"status": "awaiting",
"price": 55.12,
"currency": "string",
"id": "9ae95f34-a8aa-4092-8d31-b4dd00f957bb",
"methodId": 1234,
"coachId": "96ea2218-8423-4c0c-9d77-04ca608d090c",
"clientId": "4b4790f2-472d-4c79-8621-e51a1bdbfe3a",
"serviceId": "5d661d18-64b3-4920-a730-33bb23def855",
"clientSecret": "string",
"checkout": "object",
"expirationAt": "string",
"createdAt": "string"
},{
"status": "awaiting",
"price": 55.12,
"currency": "string",
"id": "d110c03e-3a48-4ed9-bbf6-cf56e6034b17",
"methodId": 1234,
"coachId": "4b638507-b98f-4530-85ec-47ee139adc4a",
"clientId": "1300c28b-6bd8-4050-b54b-e260568a7bba",
"serviceId": "e0251629-288b-4603-90d7-1f6afdd2678d",
"clientSecret": "string",
"checkout": "object",
"expirationAt": "string",
"createdAt": "string"
}]
```
Get Payment
GET
https://api.stretch.com/api/v1/payment/hash/{hash_id}
Code sample
cURL Python PHP Java Ruby Node.js .NET Go Dart
curl -X GET \
--url "https://api.stretch.com/api/v1/payment/hash/{hash_id}" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
import requests
headers = {
"Content-Type" : "application/json" ,
"Authorization" : "Bearer YOUR_ACCESS_TOKEN"
}
try :
response = requests . get ( "https://api.stretch.com/api/v1/payment/hash/ {hash_id} , headers=headers" )
print ( response . json ())
except requests . exceptions . HTTPError as errh :
print ( "HTTP Error:" , errh )
except requests . exceptions . RequestException as errex :
print ( "Exception request:" , errex )
<?php
$url = "https://api.stretch.com/api/v1/payment/hash/{hash_id}" ;
$headers = array (
"Content-Type: application/json" ,
"Authorization: Bearer YOUR_ACCESS_TOKEN" ,
);
$ch = curl_init ();
curl_setopt ( $ch , CURLOPT_URL , $url );
curl_setopt ( $ch , CURLOPT_HTTPHEADER , $headers );
curl_setopt ( $ch , CURLOPT_RETURNTRANSFER , true );
curl_setopt ( $ch , CURLOPT_FAILONERROR , true );
$response = curl_exec ( $ch );
if ( curl_errno ( $ch )) {
$error_msg = curl_error ( $ch );
echo "Exception request: " . $error_msg ;
} else {
if ( curl_getinfo ( $ch , CURLINFO_HTTP_CODE ) != 200 ) {
echo "HTTP Error: " . curl_getinfo ( $ch , CURLINFO_HTTP_CODE );
} else {
echo $response ;
}
}
curl_close ( $ch );
?>
import java.io.BufferedReader ;
import java.io.IOException ;
import java.io.InputStreamReader ;
import java.net.HttpURLConnection ;
import java.net.MalformedURLException ;
import java.net.URL ;
public class Main {
public static void main ( String [] args ) {
String url = "https://api.stretch.com/api/v1/payment/hash/{hash_id}" ;
String accessToken = "YOUR_ACCESS_TOKEN" ;
try {
URL apiUrl = new URL ( url );
HttpURLConnection connection = ( HttpURLConnection ) apiUrl . openConnection ();
connection . setRequestMethod ( "GET" );
connection . setRequestProperty ( "Content-Type" , "application/json" );
connection . setRequestProperty ( "Authorization" , "Bearer " + accessToken );
int responseCode = connection . getResponseCode ();
if ( responseCode == HttpURLConnection . HTTP_OK ) {
BufferedReader in = new BufferedReader ( new InputStreamReader ( connection . getInputStream ()));
String inputLine ;
StringBuilder content = new StringBuilder ();
while (( inputLine = in . readLine ()) != null ) {
content . append ( inputLine );
}
in . close ();
System . out . println ( content . toString ());
} else {
System . out . println ( "HTTP Error: " + responseCode );
}
connection . disconnect ();
} catch ( MalformedURLException e ) {
System . out . println ( "Exception request: " + e . getMessage ());
} catch ( IOException e ) {
System . out . println ( "Exception request: " + e . getMessage ());
}
}
}
require 'net/http'
require 'uri'
require 'json'
url = 'https://api.stretch.com/api/v1/payment/hash/{hash_id}'
access_token = 'YOUR_ACCESS_TOKEN'
uri = URI . parse ( url )
http = Net :: HTTP . new ( uri . host , uri . port )
http . use_ssl = true
headers = {
'Content-Type' => 'application/json' ,
'Authorization' => "Bearer #{ access_token } "
}
begin
request = Net :: HTTP :: Get . new ( uri . request_uri , headers )
response = http . request ( request )
if response . code . to_i == 200
puts JSON . parse ( response . body )
else
puts "HTTP Error: #{ response . code } "
end
rescue => e
puts "Exception request: #{ e . message } "
end
const axios = require ( 'axios' );
const url = 'https://api.stretch.com/api/v1/payment/hash/{hash_id}' ;
const headers = {
'Content-Type' : 'application/json' ,
'Authorization' : 'Bearer YOUR_ACCESS_TOKEN' ,
};
axios
. get ( url ,{ headers })
. then (( response ) => {
console . log ( response . data );
})
. catch (( error ) => {
if ( error . response ) {
console . log ( 'HTTP Error:' , error . response . status );
} else {
console . log ( 'Exception request:' , error . message );
}
});
using System ;
using System.Net.Http ;
async Task Main () {
using ( var client = new HttpClient ()) {
client . DefaultRequestHeaders . Add ( "Content-Type" , "application/json" ); var response = await client . GetAsync ( new Uri ( "https://api.stretch.com/api/v1/payment/hash/{hash_id}" )
if ( response . IsSuccessStatusCode ) {
var content = await response . Content . ReadAsStringAsync ();
Console . WriteLine ( content );
} else {
Console . WriteLine ( $"Request failed with status code: {(int)response.StatusCode}" );
}
}
}
package main
import (
"fmt"
"io/ioutil"
"net/http"
)
func main () {
url := "https://api.stretch.com/api/v1/payment/hash/{hash_id}"
accessToken := "YOUR_ACCESS_TOKEN"
client := & http . Client {}
req , err := http . NewRequest ( "GET" , url , nil )
if err != nil {
fmt . Println ( "Exception request:" , err )
return
}
req . Header . Add ( "Content-Type" , "application/json" )
req . Header . Add ( "Authorization" , "Bearer " + accessToken )
resp , err := client . Do ( req )
if err != nil {
fmt . Println ( "Exception request:" , err )
return
}
defer resp . Body . Close ()
if resp . StatusCode == http . StatusOK {
body , err := ioutil . ReadAll ( resp . Body )
if err != nil {
fmt . Println ( "Exception request:" , err )
return
}
fmt . Println ( string ( body ))
} else {
fmt . Println ( "HTTP Error:" , resp . StatusCode )
}
}
import 'dart:convert' ;
import 'package:http/http.dart' as http ;
void main () async {
final url = 'https://api.stretch.com/api/v1/payment/hash/{hash_id}' ;
final accessToken = 'YOUR_ACCESS_TOKEN' ;
final headers = {
'Content-Type' : 'application/json' ,
'Authorization' : 'Bearer $ accessToken ' ,
};
try { final response = await http . get ( Uri . parse ( url ), headers: headers );
if ( response . statusCode == 200 ) {
print ( jsonDecode ( response . body ));
} else {
print ( 'HTTP Error: ${ response . statusCode } ' );
}
} catch ( e ) {
print ( 'Exception request: $ e ' );
}
}
Response
Successful Response (200) Validation Error (422)
Payment
{
"status" : "awaiting" ,
"price" : 55.12 ,
"currency" : "string" ,
"id" : "e1a5d70e-1f7a-4c02-82c4-3c860b60cf83" ,
"methodId" : 1234 ,
"coachId" : "8b0db87d-5166-40c0-9dd4-fad72c52bfda" ,
"clientId" : "a3fb0ae0-552c-4c66-8142-9de18d3b17af" ,
"serviceId" : "d3198b60-4c05-49ee-9db3-95ebc2351c10" ,
"clientSecret" : "string" ,
"checkout" : "object" ,
"expirationAt" : "string" ,
"createdAt" : "string"
}
List Methods
GET
https://api.stretch.com/api/v1/payment/methods
Code sample
cURL Python PHP Java Ruby Node.js .NET Go Dart
curl -X GET \
--url "https://api.stretch.com/api/v1/payment/methods" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
import requests
headers = {
"Content-Type" : "application/json" ,
"Authorization" : "Bearer YOUR_ACCESS_TOKEN"
}
try :
response = requests . get ( "https://api.stretch.com/api/v1/payment/methods, headers=headers" )
print ( response . json ())
except requests . exceptions . HTTPError as errh :
print ( "HTTP Error:" , errh )
except requests . exceptions . RequestException as errex :
print ( "Exception request:" , errex )
<?php
$url = "https://api.stretch.com/api/v1/payment/methods" ;
$headers = array (
"Content-Type: application/json" ,
"Authorization: Bearer YOUR_ACCESS_TOKEN" ,
);
$ch = curl_init ();
curl_setopt ( $ch , CURLOPT_URL , $url );
curl_setopt ( $ch , CURLOPT_HTTPHEADER , $headers );
curl_setopt ( $ch , CURLOPT_RETURNTRANSFER , true );
curl_setopt ( $ch , CURLOPT_FAILONERROR , true );
$response = curl_exec ( $ch );
if ( curl_errno ( $ch )) {
$error_msg = curl_error ( $ch );
echo "Exception request: " . $error_msg ;
} else {
if ( curl_getinfo ( $ch , CURLINFO_HTTP_CODE ) != 200 ) {
echo "HTTP Error: " . curl_getinfo ( $ch , CURLINFO_HTTP_CODE );
} else {
echo $response ;
}
}
curl_close ( $ch );
?>
import java.io.BufferedReader ;
import java.io.IOException ;
import java.io.InputStreamReader ;
import java.net.HttpURLConnection ;
import java.net.MalformedURLException ;
import java.net.URL ;
public class Main {
public static void main ( String [] args ) {
String url = "https://api.stretch.com/api/v1/payment/methods" ;
String accessToken = "YOUR_ACCESS_TOKEN" ;
try {
URL apiUrl = new URL ( url );
HttpURLConnection connection = ( HttpURLConnection ) apiUrl . openConnection ();
connection . setRequestMethod ( "GET" );
connection . setRequestProperty ( "Content-Type" , "application/json" );
connection . setRequestProperty ( "Authorization" , "Bearer " + accessToken );
int responseCode = connection . getResponseCode ();
if ( responseCode == HttpURLConnection . HTTP_OK ) {
BufferedReader in = new BufferedReader ( new InputStreamReader ( connection . getInputStream ()));
String inputLine ;
StringBuilder content = new StringBuilder ();
while (( inputLine = in . readLine ()) != null ) {
content . append ( inputLine );
}
in . close ();
System . out . println ( content . toString ());
} else {
System . out . println ( "HTTP Error: " + responseCode );
}
connection . disconnect ();
} catch ( MalformedURLException e ) {
System . out . println ( "Exception request: " + e . getMessage ());
} catch ( IOException e ) {
System . out . println ( "Exception request: " + e . getMessage ());
}
}
}
require 'net/http'
require 'uri'
require 'json'
url = 'https://api.stretch.com/api/v1/payment/methods'
access_token = 'YOUR_ACCESS_TOKEN'
uri = URI . parse ( url )
http = Net :: HTTP . new ( uri . host , uri . port )
http . use_ssl = true
headers = {
'Content-Type' => 'application/json' ,
'Authorization' => "Bearer #{ access_token } "
}
begin
request = Net :: HTTP :: Get . new ( uri . request_uri , headers )
response = http . request ( request )
if response . code . to_i == 200
puts JSON . parse ( response . body )
else
puts "HTTP Error: #{ response . code } "
end
rescue => e
puts "Exception request: #{ e . message } "
end
const axios = require ( 'axios' );
const url = 'https://api.stretch.com/api/v1/payment/methods' ;
const headers = {
'Content-Type' : 'application/json' ,
'Authorization' : 'Bearer YOUR_ACCESS_TOKEN' ,
};
axios
. get ( url ,{ headers })
. then (( response ) => {
console . log ( response . data );
})
. catch (( error ) => {
if ( error . response ) {
console . log ( 'HTTP Error:' , error . response . status );
} else {
console . log ( 'Exception request:' , error . message );
}
});
using System ;
using System.Net.Http ;
async Task Main () {
using ( var client = new HttpClient ()) {
client . DefaultRequestHeaders . Add ( "Content-Type" , "application/json" ); var response = await client . GetAsync ( new Uri ( "https://api.stretch.com/api/v1/payment/methods" )
if ( response . IsSuccessStatusCode ) {
var content = await response . Content . ReadAsStringAsync ();
Console . WriteLine ( content );
} else {
Console . WriteLine ( $"Request failed with status code: {(int)response.StatusCode}" );
}
}
}
package main
import (
"fmt"
"io/ioutil"
"net/http"
)
func main () {
url := "https://api.stretch.com/api/v1/payment/methods"
accessToken := "YOUR_ACCESS_TOKEN"
client := & http . Client {}
req , err := http . NewRequest ( "GET" , url , nil )
if err != nil {
fmt . Println ( "Exception request:" , err )
return
}
req . Header . Add ( "Content-Type" , "application/json" )
req . Header . Add ( "Authorization" , "Bearer " + accessToken )
resp , err := client . Do ( req )
if err != nil {
fmt . Println ( "Exception request:" , err )
return
}
defer resp . Body . Close ()
if resp . StatusCode == http . StatusOK {
body , err := ioutil . ReadAll ( resp . Body )
if err != nil {
fmt . Println ( "Exception request:" , err )
return
}
fmt . Println ( string ( body ))
} else {
fmt . Println ( "HTTP Error:" , resp . StatusCode )
}
}
import 'dart:convert' ;
import 'package:http/http.dart' as http ;
void main () async {
final url = 'https://api.stretch.com/api/v1/payment/methods' ;
final accessToken = 'YOUR_ACCESS_TOKEN' ;
final headers = {
'Content-Type' : 'application/json' ,
'Authorization' : 'Bearer $ accessToken ' ,
};
try { final response = await http . get ( Uri . parse ( url ), headers: headers );
if ( response . statusCode == 200 ) {
print ( jsonDecode ( response . body ));
} else {
print ( 'HTTP Error: ${ response . statusCode } ' );
}
} catch ( e ) {
print ( 'Exception request: $ e ' );
}
}
Response
Get Payment
GET
https://api.stretch.com/api/v1/payment/checkout/{payment_id}
Code sample
cURL Python PHP Java Ruby Node.js .NET Go Dart
curl -X GET \
--url "https://api.stretch.com/api/v1/payment/checkout/{payment_id}" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
import requests
headers = {
"Content-Type" : "application/json" ,
"Authorization" : "Bearer YOUR_ACCESS_TOKEN"
}
try :
response = requests . get ( "https://api.stretch.com/api/v1/payment/checkout/ {payment_id} , headers=headers" )
print ( response . json ())
except requests . exceptions . HTTPError as errh :
print ( "HTTP Error:" , errh )
except requests . exceptions . RequestException as errex :
print ( "Exception request:" , errex )
<?php
$url = "https://api.stretch.com/api/v1/payment/checkout/{payment_id}" ;
$headers = array (
"Content-Type: application/json" ,
"Authorization: Bearer YOUR_ACCESS_TOKEN" ,
);
$ch = curl_init ();
curl_setopt ( $ch , CURLOPT_URL , $url );
curl_setopt ( $ch , CURLOPT_HTTPHEADER , $headers );
curl_setopt ( $ch , CURLOPT_RETURNTRANSFER , true );
curl_setopt ( $ch , CURLOPT_FAILONERROR , true );
$response = curl_exec ( $ch );
if ( curl_errno ( $ch )) {
$error_msg = curl_error ( $ch );
echo "Exception request: " . $error_msg ;
} else {
if ( curl_getinfo ( $ch , CURLINFO_HTTP_CODE ) != 200 ) {
echo "HTTP Error: " . curl_getinfo ( $ch , CURLINFO_HTTP_CODE );
} else {
echo $response ;
}
}
curl_close ( $ch );
?>
import java.io.BufferedReader ;
import java.io.IOException ;
import java.io.InputStreamReader ;
import java.net.HttpURLConnection ;
import java.net.MalformedURLException ;
import java.net.URL ;
public class Main {
public static void main ( String [] args ) {
String url = "https://api.stretch.com/api/v1/payment/checkout/{payment_id}" ;
String accessToken = "YOUR_ACCESS_TOKEN" ;
try {
URL apiUrl = new URL ( url );
HttpURLConnection connection = ( HttpURLConnection ) apiUrl . openConnection ();
connection . setRequestMethod ( "GET" );
connection . setRequestProperty ( "Content-Type" , "application/json" );
connection . setRequestProperty ( "Authorization" , "Bearer " + accessToken );
int responseCode = connection . getResponseCode ();
if ( responseCode == HttpURLConnection . HTTP_OK ) {
BufferedReader in = new BufferedReader ( new InputStreamReader ( connection . getInputStream ()));
String inputLine ;
StringBuilder content = new StringBuilder ();
while (( inputLine = in . readLine ()) != null ) {
content . append ( inputLine );
}
in . close ();
System . out . println ( content . toString ());
} else {
System . out . println ( "HTTP Error: " + responseCode );
}
connection . disconnect ();
} catch ( MalformedURLException e ) {
System . out . println ( "Exception request: " + e . getMessage ());
} catch ( IOException e ) {
System . out . println ( "Exception request: " + e . getMessage ());
}
}
}
require 'net/http'
require 'uri'
require 'json'
url = 'https://api.stretch.com/api/v1/payment/checkout/{payment_id}'
access_token = 'YOUR_ACCESS_TOKEN'
uri = URI . parse ( url )
http = Net :: HTTP . new ( uri . host , uri . port )
http . use_ssl = true
headers = {
'Content-Type' => 'application/json' ,
'Authorization' => "Bearer #{ access_token } "
}
begin
request = Net :: HTTP :: Get . new ( uri . request_uri , headers )
response = http . request ( request )
if response . code . to_i == 200
puts JSON . parse ( response . body )
else
puts "HTTP Error: #{ response . code } "
end
rescue => e
puts "Exception request: #{ e . message } "
end
const axios = require ( 'axios' );
const url = 'https://api.stretch.com/api/v1/payment/checkout/{payment_id}' ;
const headers = {
'Content-Type' : 'application/json' ,
'Authorization' : 'Bearer YOUR_ACCESS_TOKEN' ,
};
axios
. get ( url ,{ headers })
. then (( response ) => {
console . log ( response . data );
})
. catch (( error ) => {
if ( error . response ) {
console . log ( 'HTTP Error:' , error . response . status );
} else {
console . log ( 'Exception request:' , error . message );
}
});
using System ;
using System.Net.Http ;
async Task Main () {
using ( var client = new HttpClient ()) {
client . DefaultRequestHeaders . Add ( "Content-Type" , "application/json" ); var response = await client . GetAsync ( new Uri ( "https://api.stretch.com/api/v1/payment/checkout/{payment_id}" )
if ( response . IsSuccessStatusCode ) {
var content = await response . Content . ReadAsStringAsync ();
Console . WriteLine ( content );
} else {
Console . WriteLine ( $"Request failed with status code: {(int)response.StatusCode}" );
}
}
}
package main
import (
"fmt"
"io/ioutil"
"net/http"
)
func main () {
url := "https://api.stretch.com/api/v1/payment/checkout/{payment_id}"
accessToken := "YOUR_ACCESS_TOKEN"
client := & http . Client {}
req , err := http . NewRequest ( "GET" , url , nil )
if err != nil {
fmt . Println ( "Exception request:" , err )
return
}
req . Header . Add ( "Content-Type" , "application/json" )
req . Header . Add ( "Authorization" , "Bearer " + accessToken )
resp , err := client . Do ( req )
if err != nil {
fmt . Println ( "Exception request:" , err )
return
}
defer resp . Body . Close ()
if resp . StatusCode == http . StatusOK {
body , err := ioutil . ReadAll ( resp . Body )
if err != nil {
fmt . Println ( "Exception request:" , err )
return
}
fmt . Println ( string ( body ))
} else {
fmt . Println ( "HTTP Error:" , resp . StatusCode )
}
}
import 'dart:convert' ;
import 'package:http/http.dart' as http ;
void main () async {
final url = 'https://api.stretch.com/api/v1/payment/checkout/{payment_id}' ;
final accessToken = 'YOUR_ACCESS_TOKEN' ;
final headers = {
'Content-Type' : 'application/json' ,
'Authorization' : 'Bearer $ accessToken ' ,
};
try { final response = await http . get ( Uri . parse ( url ), headers: headers );
if ( response . statusCode == 200 ) {
print ( jsonDecode ( response . body ));
} else {
print ( 'HTTP Error: ${ response . statusCode } ' );
}
} catch ( e ) {
print ( 'Exception request: $ e ' );
}
}
Response
Successful Response (200) Validation Error (422)
Payment
{
"status" : "awaiting" ,
"price" : 55.12 ,
"currency" : "string" ,
"id" : "b67bd683-17fe-468a-9e63-13226275608f" ,
"methodId" : 1234 ,
"coachId" : "78aafed2-88b0-41e6-b221-0d50d53921a9" ,
"clientId" : "36b1ed0f-98ca-4114-a348-09560225d059" ,
"serviceId" : "38b39e19-1fce-422b-bf85-7d25c1ed002f" ,
"clientSecret" : "string" ,
"checkout" : "object" ,
"expirationAt" : "string" ,
"createdAt" : "string"
}
Checkout Payment
POST
https://api.stretch.com/api/v1/payment/checkout/{payment_id}
Code sample
cURL Python PHP Java Ruby Node.js .NET Go Dart
curl -X POST \
--url "https://api.stretch.com/api/v1/payment/checkout/{payment_id}" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
import requests
headers = {
"Content-Type" : "application/json" ,
"Authorization" : "Bearer YOUR_ACCESS_TOKEN"
}
try :
response = requests . post ( "https://api.stretch.com/api/v1/payment/checkout/ {payment_id} , headers=headers" )
print ( response . json ())
except requests . exceptions . HTTPError as errh :
print ( "HTTP Error:" , errh )
except requests . exceptions . RequestException as errex :
print ( "Exception request:" , errex )
<?php
$url = "https://api.stretch.com/api/v1/payment/checkout/{payment_id}" ;
$headers = array (
"Content-Type: application/json" ,
"Authorization: Bearer YOUR_ACCESS_TOKEN" ,
);
$ch = curl_init ();
curl_setopt ( $ch , CURLOPT_URL , $url );
curl_setopt ( $ch , CURLOPT_HTTPHEADER , $headers );
curl_setopt ( $ch , CURLOPT_RETURNTRANSFER , true );
curl_setopt ( $ch , CURLOPT_FAILONERROR , true );
$response = curl_exec ( $ch );
if ( curl_errno ( $ch )) {
$error_msg = curl_error ( $ch );
echo "Exception request: " . $error_msg ;
} else {
if ( curl_getinfo ( $ch , CURLINFO_HTTP_CODE ) != 200 ) {
echo "HTTP Error: " . curl_getinfo ( $ch , CURLINFO_HTTP_CODE );
} else {
echo $response ;
}
}
curl_close ( $ch );
?>
import java.io.BufferedReader ;
import java.io.IOException ;
import java.io.InputStreamReader ;
import java.net.HttpURLConnection ;
import java.net.MalformedURLException ;
import java.net.URL ;
public class Main {
public static void main ( String [] args ) {
String url = "https://api.stretch.com/api/v1/payment/checkout/{payment_id}" ;
String accessToken = "YOUR_ACCESS_TOKEN" ;
try {
URL apiUrl = new URL ( url );
HttpURLConnection connection = ( HttpURLConnection ) apiUrl . openConnection ();
connection . setRequestMethod ( "POST" );
connection . setRequestProperty ( "Content-Type" , "application/json" );
connection . setRequestProperty ( "Authorization" , "Bearer " + accessToken );
int responseCode = connection . getResponseCode ();
if ( responseCode == HttpURLConnection . HTTP_OK ) {
BufferedReader in = new BufferedReader ( new InputStreamReader ( connection . getInputStream ()));
String inputLine ;
StringBuilder content = new StringBuilder ();
while (( inputLine = in . readLine ()) != null ) {
content . append ( inputLine );
}
in . close ();
System . out . println ( content . toString ());
} else {
System . out . println ( "HTTP Error: " + responseCode );
}
connection . disconnect ();
} catch ( MalformedURLException e ) {
System . out . println ( "Exception request: " + e . getMessage ());
} catch ( IOException e ) {
System . out . println ( "Exception request: " + e . getMessage ());
}
}
}
require 'net/http'
require 'uri'
require 'json'
url = 'https://api.stretch.com/api/v1/payment/checkout/{payment_id}'
access_token = 'YOUR_ACCESS_TOKEN'
uri = URI . parse ( url )
http = Net :: HTTP . new ( uri . host , uri . port )
http . use_ssl = true
headers = {
'Content-Type' => 'application/json' ,
'Authorization' => "Bearer #{ access_token } "
}
begin
request = Net :: HTTP :: Post . new ( uri . request_uri , headers )
response = http . request ( request )
if response . code . to_i == 200
puts JSON . parse ( response . body )
else
puts "HTTP Error: #{ response . code } "
end
rescue => e
puts "Exception request: #{ e . message } "
end
const axios = require ( 'axios' );
const url = 'https://api.stretch.com/api/v1/payment/checkout/{payment_id}' ;
const headers = {
'Content-Type' : 'application/json' ,
'Authorization' : 'Bearer YOUR_ACCESS_TOKEN' ,
};
axios
. post ( url ,{ headers })
. then (( response ) => {
console . log ( response . data );
})
. catch (( error ) => {
if ( error . response ) {
console . log ( 'HTTP Error:' , error . response . status );
} else {
console . log ( 'Exception request:' , error . message );
}
});
using System ;
using System.Net.Http ;
async Task Main () {
using ( var client = new HttpClient ()) {
client . DefaultRequestHeaders . Add ( "Content-Type" , "application/json" ); var response = await client . PostAsync ( new Uri ( "https://api.stretch.com/api/v1/payment/checkout/{payment_id}" )
if ( response . IsSuccessStatusCode ) {
var content = await response . Content . ReadAsStringAsync ();
Console . WriteLine ( content );
} else {
Console . WriteLine ( $"Request failed with status code: {(int)response.StatusCode}" );
}
}
}
package main
import (
"fmt"
"io/ioutil"
"net/http"
)
func main () {
url := "https://api.stretch.com/api/v1/payment/checkout/{payment_id}"
accessToken := "YOUR_ACCESS_TOKEN"
client := & http . Client {}
req , err := http . NewRequest ( "POST" , url , nil )
if err != nil {
fmt . Println ( "Exception request:" , err )
return
}
req . Header . Add ( "Content-Type" , "application/json" )
req . Header . Add ( "Authorization" , "Bearer " + accessToken )
resp , err := client . Do ( req )
if err != nil {
fmt . Println ( "Exception request:" , err )
return
}
defer resp . Body . Close ()
if resp . StatusCode == http . StatusOK {
body , err := ioutil . ReadAll ( resp . Body )
if err != nil {
fmt . Println ( "Exception request:" , err )
return
}
fmt . Println ( string ( body ))
} else {
fmt . Println ( "HTTP Error:" , resp . StatusCode )
}
}
import 'dart:convert' ;
import 'package:http/http.dart' as http ;
void main () async {
final url = 'https://api.stretch.com/api/v1/payment/checkout/{payment_id}' ;
final accessToken = 'YOUR_ACCESS_TOKEN' ;
final headers = {
'Content-Type' : 'application/json' ,
'Authorization' : 'Bearer $ accessToken ' ,
};
try { final response = await http . post ( Uri . parse ( url ), headers: headers );
if ( response . statusCode == 200 ) {
print ( jsonDecode ( response . body ));
} else {
print ( 'HTTP Error: ${ response . statusCode } ' );
}
} catch ( e ) {
print ( 'Exception request: $ e ' );
}
}
Response
Successful Response (201) Validation Error (422)
Payment
{
"status" : "awaiting" ,
"price" : 55.12 ,
"currency" : "string" ,
"id" : "33b9d490-974b-43c1-8ba8-2a0500b9ad1b" ,
"methodId" : 1234 ,
"coachId" : "bd0e48af-0c66-4e77-ace7-bd61e376cd42" ,
"clientId" : "44e63c77-0ce3-41f6-a653-e7f1f26b3c53" ,
"serviceId" : "e3e91726-335c-4dd5-8bdf-3cc9c587462f" ,
"clientSecret" : "string" ,
"checkout" : "object" ,
"expirationAt" : "string" ,
"createdAt" : "string"
}
List Wallets
GET
https://api.stretch.com/api/v1/payment/wallets
Code sample
cURL Python PHP Java Ruby Node.js .NET Go Dart
curl -X GET \
--url "https://api.stretch.com/api/v1/payment/wallets" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
import requests
headers = {
"Content-Type" : "application/json" ,
"Authorization" : "Bearer YOUR_ACCESS_TOKEN"
}
try :
response = requests . get ( "https://api.stretch.com/api/v1/payment/wallets, headers=headers" )
print ( response . json ())
except requests . exceptions . HTTPError as errh :
print ( "HTTP Error:" , errh )
except requests . exceptions . RequestException as errex :
print ( "Exception request:" , errex )
<?php
$url = "https://api.stretch.com/api/v1/payment/wallets" ;
$headers = array (
"Content-Type: application/json" ,
"Authorization: Bearer YOUR_ACCESS_TOKEN" ,
);
$ch = curl_init ();
curl_setopt ( $ch , CURLOPT_URL , $url );
curl_setopt ( $ch , CURLOPT_HTTPHEADER , $headers );
curl_setopt ( $ch , CURLOPT_RETURNTRANSFER , true );
curl_setopt ( $ch , CURLOPT_FAILONERROR , true );
$response = curl_exec ( $ch );
if ( curl_errno ( $ch )) {
$error_msg = curl_error ( $ch );
echo "Exception request: " . $error_msg ;
} else {
if ( curl_getinfo ( $ch , CURLINFO_HTTP_CODE ) != 200 ) {
echo "HTTP Error: " . curl_getinfo ( $ch , CURLINFO_HTTP_CODE );
} else {
echo $response ;
}
}
curl_close ( $ch );
?>
import java.io.BufferedReader ;
import java.io.IOException ;
import java.io.InputStreamReader ;
import java.net.HttpURLConnection ;
import java.net.MalformedURLException ;
import java.net.URL ;
public class Main {
public static void main ( String [] args ) {
String url = "https://api.stretch.com/api/v1/payment/wallets" ;
String accessToken = "YOUR_ACCESS_TOKEN" ;
try {
URL apiUrl = new URL ( url );
HttpURLConnection connection = ( HttpURLConnection ) apiUrl . openConnection ();
connection . setRequestMethod ( "GET" );
connection . setRequestProperty ( "Content-Type" , "application/json" );
connection . setRequestProperty ( "Authorization" , "Bearer " + accessToken );
int responseCode = connection . getResponseCode ();
if ( responseCode == HttpURLConnection . HTTP_OK ) {
BufferedReader in = new BufferedReader ( new InputStreamReader ( connection . getInputStream ()));
String inputLine ;
StringBuilder content = new StringBuilder ();
while (( inputLine = in . readLine ()) != null ) {
content . append ( inputLine );
}
in . close ();
System . out . println ( content . toString ());
} else {
System . out . println ( "HTTP Error: " + responseCode );
}
connection . disconnect ();
} catch ( MalformedURLException e ) {
System . out . println ( "Exception request: " + e . getMessage ());
} catch ( IOException e ) {
System . out . println ( "Exception request: " + e . getMessage ());
}
}
}
require 'net/http'
require 'uri'
require 'json'
url = 'https://api.stretch.com/api/v1/payment/wallets'
access_token = 'YOUR_ACCESS_TOKEN'
uri = URI . parse ( url )
http = Net :: HTTP . new ( uri . host , uri . port )
http . use_ssl = true
headers = {
'Content-Type' => 'application/json' ,
'Authorization' => "Bearer #{ access_token } "
}
begin
request = Net :: HTTP :: Get . new ( uri . request_uri , headers )
response = http . request ( request )
if response . code . to_i == 200
puts JSON . parse ( response . body )
else
puts "HTTP Error: #{ response . code } "
end
rescue => e
puts "Exception request: #{ e . message } "
end
const axios = require ( 'axios' );
const url = 'https://api.stretch.com/api/v1/payment/wallets' ;
const headers = {
'Content-Type' : 'application/json' ,
'Authorization' : 'Bearer YOUR_ACCESS_TOKEN' ,
};
axios
. get ( url ,{ headers })
. then (( response ) => {
console . log ( response . data );
})
. catch (( error ) => {
if ( error . response ) {
console . log ( 'HTTP Error:' , error . response . status );
} else {
console . log ( 'Exception request:' , error . message );
}
});
using System ;
using System.Net.Http ;
async Task Main () {
using ( var client = new HttpClient ()) {
client . DefaultRequestHeaders . Add ( "Content-Type" , "application/json" ); var response = await client . GetAsync ( new Uri ( "https://api.stretch.com/api/v1/payment/wallets" )
if ( response . IsSuccessStatusCode ) {
var content = await response . Content . ReadAsStringAsync ();
Console . WriteLine ( content );
} else {
Console . WriteLine ( $"Request failed with status code: {(int)response.StatusCode}" );
}
}
}
package main
import (
"fmt"
"io/ioutil"
"net/http"
)
func main () {
url := "https://api.stretch.com/api/v1/payment/wallets"
accessToken := "YOUR_ACCESS_TOKEN"
client := & http . Client {}
req , err := http . NewRequest ( "GET" , url , nil )
if err != nil {
fmt . Println ( "Exception request:" , err )
return
}
req . Header . Add ( "Content-Type" , "application/json" )
req . Header . Add ( "Authorization" , "Bearer " + accessToken )
resp , err := client . Do ( req )
if err != nil {
fmt . Println ( "Exception request:" , err )
return
}
defer resp . Body . Close ()
if resp . StatusCode == http . StatusOK {
body , err := ioutil . ReadAll ( resp . Body )
if err != nil {
fmt . Println ( "Exception request:" , err )
return
}
fmt . Println ( string ( body ))
} else {
fmt . Println ( "HTTP Error:" , resp . StatusCode )
}
}
import 'dart:convert' ;
import 'package:http/http.dart' as http ;
void main () async {
final url = 'https://api.stretch.com/api/v1/payment/wallets' ;
final accessToken = 'YOUR_ACCESS_TOKEN' ;
final headers = {
'Content-Type' : 'application/json' ,
'Authorization' : 'Bearer $ accessToken ' ,
};
try { final response = await http . get ( Uri . parse ( url ), headers: headers );
if ( response . statusCode == 200 ) {
print ( jsonDecode ( response . body ));
} else {
print ( 'HTTP Error: ${ response . statusCode } ' );
}
} catch ( e ) {
print ( 'Exception request: $ e ' );
}
}
Response
Wallet Info
GET
https://api.stretch.com/api/v1/payment/wallet/info
Code sample
cURL Python PHP Java Ruby Node.js .NET Go Dart
curl -X GET \
--url "https://api.stretch.com/api/v1/payment/wallet/info" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
import requests
headers = {
"Content-Type" : "application/json" ,
"Authorization" : "Bearer YOUR_ACCESS_TOKEN"
}
try :
response = requests . get ( "https://api.stretch.com/api/v1/payment/wallet/info, headers=headers" )
print ( response . json ())
except requests . exceptions . HTTPError as errh :
print ( "HTTP Error:" , errh )
except requests . exceptions . RequestException as errex :
print ( "Exception request:" , errex )
<?php
$url = "https://api.stretch.com/api/v1/payment/wallet/info" ;
$headers = array (
"Content-Type: application/json" ,
"Authorization: Bearer YOUR_ACCESS_TOKEN" ,
);
$ch = curl_init ();
curl_setopt ( $ch , CURLOPT_URL , $url );
curl_setopt ( $ch , CURLOPT_HTTPHEADER , $headers );
curl_setopt ( $ch , CURLOPT_RETURNTRANSFER , true );
curl_setopt ( $ch , CURLOPT_FAILONERROR , true );
$response = curl_exec ( $ch );
if ( curl_errno ( $ch )) {
$error_msg = curl_error ( $ch );
echo "Exception request: " . $error_msg ;
} else {
if ( curl_getinfo ( $ch , CURLINFO_HTTP_CODE ) != 200 ) {
echo "HTTP Error: " . curl_getinfo ( $ch , CURLINFO_HTTP_CODE );
} else {
echo $response ;
}
}
curl_close ( $ch );
?>
import java.io.BufferedReader ;
import java.io.IOException ;
import java.io.InputStreamReader ;
import java.net.HttpURLConnection ;
import java.net.MalformedURLException ;
import java.net.URL ;
public class Main {
public static void main ( String [] args ) {
String url = "https://api.stretch.com/api/v1/payment/wallet/info" ;
String accessToken = "YOUR_ACCESS_TOKEN" ;
try {
URL apiUrl = new URL ( url );
HttpURLConnection connection = ( HttpURLConnection ) apiUrl . openConnection ();
connection . setRequestMethod ( "GET" );
connection . setRequestProperty ( "Content-Type" , "application/json" );
connection . setRequestProperty ( "Authorization" , "Bearer " + accessToken );
int responseCode = connection . getResponseCode ();
if ( responseCode == HttpURLConnection . HTTP_OK ) {
BufferedReader in = new BufferedReader ( new InputStreamReader ( connection . getInputStream ()));
String inputLine ;
StringBuilder content = new StringBuilder ();
while (( inputLine = in . readLine ()) != null ) {
content . append ( inputLine );
}
in . close ();
System . out . println ( content . toString ());
} else {
System . out . println ( "HTTP Error: " + responseCode );
}
connection . disconnect ();
} catch ( MalformedURLException e ) {
System . out . println ( "Exception request: " + e . getMessage ());
} catch ( IOException e ) {
System . out . println ( "Exception request: " + e . getMessage ());
}
}
}
require 'net/http'
require 'uri'
require 'json'
url = 'https://api.stretch.com/api/v1/payment/wallet/info'
access_token = 'YOUR_ACCESS_TOKEN'
uri = URI . parse ( url )
http = Net :: HTTP . new ( uri . host , uri . port )
http . use_ssl = true
headers = {
'Content-Type' => 'application/json' ,
'Authorization' => "Bearer #{ access_token } "
}
begin
request = Net :: HTTP :: Get . new ( uri . request_uri , headers )
response = http . request ( request )
if response . code . to_i == 200
puts JSON . parse ( response . body )
else
puts "HTTP Error: #{ response . code } "
end
rescue => e
puts "Exception request: #{ e . message } "
end
const axios = require ( 'axios' );
const url = 'https://api.stretch.com/api/v1/payment/wallet/info' ;
const headers = {
'Content-Type' : 'application/json' ,
'Authorization' : 'Bearer YOUR_ACCESS_TOKEN' ,
};
axios
. get ( url ,{ headers })
. then (( response ) => {
console . log ( response . data );
})
. catch (( error ) => {
if ( error . response ) {
console . log ( 'HTTP Error:' , error . response . status );
} else {
console . log ( 'Exception request:' , error . message );
}
});
using System ;
using System.Net.Http ;
async Task Main () {
using ( var client = new HttpClient ()) {
client . DefaultRequestHeaders . Add ( "Content-Type" , "application/json" ); var response = await client . GetAsync ( new Uri ( "https://api.stretch.com/api/v1/payment/wallet/info" )
if ( response . IsSuccessStatusCode ) {
var content = await response . Content . ReadAsStringAsync ();
Console . WriteLine ( content );
} else {
Console . WriteLine ( $"Request failed with status code: {(int)response.StatusCode}" );
}
}
}
package main
import (
"fmt"
"io/ioutil"
"net/http"
)
func main () {
url := "https://api.stretch.com/api/v1/payment/wallet/info"
accessToken := "YOUR_ACCESS_TOKEN"
client := & http . Client {}
req , err := http . NewRequest ( "GET" , url , nil )
if err != nil {
fmt . Println ( "Exception request:" , err )
return
}
req . Header . Add ( "Content-Type" , "application/json" )
req . Header . Add ( "Authorization" , "Bearer " + accessToken )
resp , err := client . Do ( req )
if err != nil {
fmt . Println ( "Exception request:" , err )
return
}
defer resp . Body . Close ()
if resp . StatusCode == http . StatusOK {
body , err := ioutil . ReadAll ( resp . Body )
if err != nil {
fmt . Println ( "Exception request:" , err )
return
}
fmt . Println ( string ( body ))
} else {
fmt . Println ( "HTTP Error:" , resp . StatusCode )
}
}
import 'dart:convert' ;
import 'package:http/http.dart' as http ;
void main () async {
final url = 'https://api.stretch.com/api/v1/payment/wallet/info' ;
final accessToken = 'YOUR_ACCESS_TOKEN' ;
final headers = {
'Content-Type' : 'application/json' ,
'Authorization' : 'Bearer $ accessToken ' ,
};
try { final response = await http . get ( Uri . parse ( url ), headers: headers );
if ( response . statusCode == 200 ) {
print ( jsonDecode ( response . body ));
} else {
print ( 'HTTP Error: ${ response . statusCode } ' );
}
} catch ( e ) {
print ( 'Exception request: $ e ' );
}
}
Response
Stripe Webhook
POST
https://api.stretch.com/api/v1/payment/webhook
event = None
payload = request.data
sig_header = request.headers['STRIPE_SIGNATURE']
try:
event = stripe.Webhook.construct_event(
payload, sig_header, endpoint_secret
)
except ValueError as e:
# Invalid payload
raise e
except stripe.error.SignatureVerificationError as e:
# Invalid signature
Code sample
cURL Python PHP Java Ruby Node.js .NET Go Dart
curl -X POST \
--url "https://api.stretch.com/api/v1/payment/webhook" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
import requests
headers = {
"Content-Type" : "application/json" ,
"Authorization" : "Bearer YOUR_ACCESS_TOKEN"
}
try :
response = requests . post ( "https://api.stretch.com/api/v1/payment/webhook, headers=headers" )
print ( response . json ())
except requests . exceptions . HTTPError as errh :
print ( "HTTP Error:" , errh )
except requests . exceptions . RequestException as errex :
print ( "Exception request:" , errex )
<?php
$url = "https://api.stretch.com/api/v1/payment/webhook" ;
$headers = array (
"Content-Type: application/json" ,
"Authorization: Bearer YOUR_ACCESS_TOKEN" ,
);
$ch = curl_init ();
curl_setopt ( $ch , CURLOPT_URL , $url );
curl_setopt ( $ch , CURLOPT_HTTPHEADER , $headers );
curl_setopt ( $ch , CURLOPT_RETURNTRANSFER , true );
curl_setopt ( $ch , CURLOPT_FAILONERROR , true );
$response = curl_exec ( $ch );
if ( curl_errno ( $ch )) {
$error_msg = curl_error ( $ch );
echo "Exception request: " . $error_msg ;
} else {
if ( curl_getinfo ( $ch , CURLINFO_HTTP_CODE ) != 200 ) {
echo "HTTP Error: " . curl_getinfo ( $ch , CURLINFO_HTTP_CODE );
} else {
echo $response ;
}
}
curl_close ( $ch );
?>
import java.io.BufferedReader ;
import java.io.IOException ;
import java.io.InputStreamReader ;
import java.net.HttpURLConnection ;
import java.net.MalformedURLException ;
import java.net.URL ;
public class Main {
public static void main ( String [] args ) {
String url = "https://api.stretch.com/api/v1/payment/webhook" ;
String accessToken = "YOUR_ACCESS_TOKEN" ;
try {
URL apiUrl = new URL ( url );
HttpURLConnection connection = ( HttpURLConnection ) apiUrl . openConnection ();
connection . setRequestMethod ( "POST" );
connection . setRequestProperty ( "Content-Type" , "application/json" );
connection . setRequestProperty ( "Authorization" , "Bearer " + accessToken );
int responseCode = connection . getResponseCode ();
if ( responseCode == HttpURLConnection . HTTP_OK ) {
BufferedReader in = new BufferedReader ( new InputStreamReader ( connection . getInputStream ()));
String inputLine ;
StringBuilder content = new StringBuilder ();
while (( inputLine = in . readLine ()) != null ) {
content . append ( inputLine );
}
in . close ();
System . out . println ( content . toString ());
} else {
System . out . println ( "HTTP Error: " + responseCode );
}
connection . disconnect ();
} catch ( MalformedURLException e ) {
System . out . println ( "Exception request: " + e . getMessage ());
} catch ( IOException e ) {
System . out . println ( "Exception request: " + e . getMessage ());
}
}
}
require 'net/http'
require 'uri'
require 'json'
url = 'https://api.stretch.com/api/v1/payment/webhook'
access_token = 'YOUR_ACCESS_TOKEN'
uri = URI . parse ( url )
http = Net :: HTTP . new ( uri . host , uri . port )
http . use_ssl = true
headers = {
'Content-Type' => 'application/json' ,
'Authorization' => "Bearer #{ access_token } "
}
begin
request = Net :: HTTP :: Post . new ( uri . request_uri , headers )
response = http . request ( request )
if response . code . to_i == 200
puts JSON . parse ( response . body )
else
puts "HTTP Error: #{ response . code } "
end
rescue => e
puts "Exception request: #{ e . message } "
end
const axios = require ( 'axios' );
const url = 'https://api.stretch.com/api/v1/payment/webhook' ;
const headers = {
'Content-Type' : 'application/json' ,
'Authorization' : 'Bearer YOUR_ACCESS_TOKEN' ,
};
axios
. post ( url ,{ headers })
. then (( response ) => {
console . log ( response . data );
})
. catch (( error ) => {
if ( error . response ) {
console . log ( 'HTTP Error:' , error . response . status );
} else {
console . log ( 'Exception request:' , error . message );
}
});
using System ;
using System.Net.Http ;
async Task Main () {
using ( var client = new HttpClient ()) {
client . DefaultRequestHeaders . Add ( "Content-Type" , "application/json" ); var response = await client . PostAsync ( new Uri ( "https://api.stretch.com/api/v1/payment/webhook" )
if ( response . IsSuccessStatusCode ) {
var content = await response . Content . ReadAsStringAsync ();
Console . WriteLine ( content );
} else {
Console . WriteLine ( $"Request failed with status code: {(int)response.StatusCode}" );
}
}
}
package main
import (
"fmt"
"io/ioutil"
"net/http"
)
func main () {
url := "https://api.stretch.com/api/v1/payment/webhook"
accessToken := "YOUR_ACCESS_TOKEN"
client := & http . Client {}
req , err := http . NewRequest ( "POST" , url , nil )
if err != nil {
fmt . Println ( "Exception request:" , err )
return
}
req . Header . Add ( "Content-Type" , "application/json" )
req . Header . Add ( "Authorization" , "Bearer " + accessToken )
resp , err := client . Do ( req )
if err != nil {
fmt . Println ( "Exception request:" , err )
return
}
defer resp . Body . Close ()
if resp . StatusCode == http . StatusOK {
body , err := ioutil . ReadAll ( resp . Body )
if err != nil {
fmt . Println ( "Exception request:" , err )
return
}
fmt . Println ( string ( body ))
} else {
fmt . Println ( "HTTP Error:" , resp . StatusCode )
}
}
import 'dart:convert' ;
import 'package:http/http.dart' as http ;
void main () async {
final url = 'https://api.stretch.com/api/v1/payment/webhook' ;
final accessToken = 'YOUR_ACCESS_TOKEN' ;
final headers = {
'Content-Type' : 'application/json' ,
'Authorization' : 'Bearer $ accessToken ' ,
};
try { final response = await http . post ( Uri . parse ( url ), headers: headers );
if ( response . statusCode == 200 ) {
print ( jsonDecode ( response . body ));
} else {
print ( 'HTTP Error: ${ response . statusCode } ' );
}
} catch ( e ) {
print ( 'Exception request: $ e ' );
}
}