BTC Pay Checker

How to use the /order POST endpoint

This endpoint allows you to create a new order. It requires a JSON body with the following fields:

Examples

Go

        
            package main

            import (
                "bytes"
                "encoding/json"
                "net/http"
            )

            type Order struct {
                OrderID     string  `json:"order_id"`
                ClientID    string  `json:"client_id"`
                Amount      float64 `json:"amount"`
                Currency    string  `json:"currency"`
                ClientEmail string  `json:"client_email"`
            }

            func main() {
                order := &Order{
                    OrderID:     "123",
                    ClientID:    "456",
                    Amount:      100.0,
                    Currency:    "USD",
                    ClientEmail: "client@example.com",
                }

                jsonValue, _ := json.Marshal(order)
                _, err := http.Post("{{host}}/order", "application/json", bytes.NewBuffer(jsonValue))
                if err != nil {
                    // handle error
                }
            }
        
    

Node.js

        
            const axios = require('axios');

            const order = {
                order_id: '123',
                client_id: '456',
                amount: 100.0,
                currency: 'USD',
                client_email: 'client@example.com'
            };

            axios.post('{{host}}/order', order)
                .then(response => {
                    console.log(response.data);
                })
                .catch(error => {
                    console.error(error);
                });
        
    

CURL

        
            curl -X POST {{host}}/order \
            -H 'Content-Type: application/json' \
            -d '{
                "order_id": "123",
                "client_id": "456",
                "amount": 100.0,
                "currency": "USD",
                "client_email": "client@example.com"
            }'
        
    

Handling the Response

The response from the /order endpoint is an HTML page that should be displayed to the user. This can be done by embedding the response in an iframe, loading it in a new browser window or tab, or by replacing the current page with the response HTML.

Please note that the exact method of displaying the response will depend on the specifics of your application and its user interface.

Rate Limiting

To protect the service from potential denial-of-service (DoS) attacks, we have implemented rate limiting on our server. This is done using a middleware in the Fiber framework.

The current configuration allows a maximum of 5 requests per client within a 30-minute window. If a client exceeds this limit, further requests will be temporarily blocked until the rate falls below the limit.

This is achieved with the following configuration:

    
        s.app.Use(limiter.New(limiter.Config{
            Max:               5,
            Expiration:        30 * time.Minute,
            LimiterMiddleware: limiter.SlidingWindow{},
        }))
    

Please be aware of this limit when integrating with our API to ensure a smooth user experience.