Ejemplos de uso

CURL

curl -X GET\
-H "Authorization: Bearer [[accessToken]]"\
-H "Content-Type: application/json"\
"https://checkout.prod.ua.la/1/order/[[orderId]]"

Python

#!/usr/bin/env/python
# -*- coding: utf-8 -*-
import json
try:
import requests
except ImportError:
print('[!] Please install the requests library')
print('[!] Example: pip install requests')
exit(1)
CHECKOUT_URL = 'https://checkout.prod.ua.la'
ORDER_URL = f'{CHECKOUT_URL}/1/order/'
class Order:
def get_order(self, access_token: str, order_id: str) -> requests.Response:
try:
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': f'Bearer {access_token}'
}
session = requests.Session()
response = session.get(f'{ORDER_URL}{order_id}', headers=headers)
return response
except requests.exceptions.RequestException as e:
raise e('[!] Order error')
exit(1)
if __name__ == '__main__':
order = Order()
token = 'ACCESS_TOKEN'
order_id = 'ORDER_ID'
response = order.get_order(token, order_id)
if response.status_code == 200:
print(json.dumps(response.json(), indent=4))
else:
print(response.status_code)

Go

package main
import (
"encoding/json"
"fmt"
"net/http"
)
const checkoutUrl = "https://checkout.prod.ua.la"
var orderUrl = fmt.Sprintf("%s/1/order", checkoutUrl)
type (
Response struct {
OrderID string `json:"order_id"`
Status string `json:"status"`
RefNumber string `json:"ref_number"`
Amount float64 `json:"amount"`
}
)
func GetOrder(token, order_id string) (Response, error) {
var response Response
access_token := fmt.Sprintf("Bearer %s", token)
order_url := fmt.Sprintf("%s/%s", orderUrl, order_id)
request, err := http.NewRequest("GET", order_url, nil)
if err != nil {
return response, err
}
request.Header.Set("Content-Type", "application/json")
request.Header.Set("Authorization", access_token)
cli := &http.Client{}
resp, err := cli.Do(request)
if err != nil {
return response, err
}
defer resp.Body.Close()
if err = json.NewDecoder(resp.Body).Decode(&response); err != nil {
return response, err
}
return response, err
}
func main() {
token := "ACCESS_TOKEN"
order_id := "ORDER_ID"
response, err := GetOrder(token, order_id)
if err != nil {
panic(err)
}
fmt.Println(response)
}