2023-07-20 08:42:04 +02:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html lang="en">
|
2023-07-20 08:48:25 +02:00
|
|
|
|
2023-07-20 08:42:04 +02:00
|
|
|
<head>
|
|
|
|
<meta charset="UTF-8">
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
|
<title>BTC Pay Checker</title>
|
|
|
|
<style>
|
|
|
|
body {
|
|
|
|
font-family: Arial, sans-serif;
|
|
|
|
margin: 0;
|
|
|
|
padding: 0;
|
|
|
|
background-color: #f4f4f4;
|
|
|
|
}
|
2023-07-20 08:48:25 +02:00
|
|
|
|
2023-07-20 08:42:04 +02:00
|
|
|
.container {
|
|
|
|
width: 80%;
|
|
|
|
margin: auto;
|
|
|
|
overflow: hidden;
|
|
|
|
}
|
2023-07-20 08:48:25 +02:00
|
|
|
|
2023-07-20 08:42:04 +02:00
|
|
|
header {
|
|
|
|
background: #50b3a2;
|
|
|
|
color: white;
|
|
|
|
padding-top: 30px;
|
|
|
|
min-height: 70px;
|
|
|
|
border-bottom: #e8491d 3px solid;
|
|
|
|
}
|
2023-07-20 08:48:25 +02:00
|
|
|
|
2023-07-20 08:42:04 +02:00
|
|
|
header a {
|
|
|
|
color: #ffffff;
|
|
|
|
text-decoration: none;
|
|
|
|
text-transform: uppercase;
|
|
|
|
font-size: 16px;
|
|
|
|
}
|
2023-07-20 08:48:25 +02:00
|
|
|
|
2023-07-20 08:42:04 +02:00
|
|
|
header li {
|
|
|
|
float: left;
|
|
|
|
display: inline;
|
|
|
|
padding: 0 20px 0 20px;
|
|
|
|
}
|
2023-07-20 08:48:25 +02:00
|
|
|
|
2023-07-20 08:42:04 +02:00
|
|
|
header #branding {
|
|
|
|
float: left;
|
|
|
|
}
|
2023-07-20 08:48:25 +02:00
|
|
|
|
2023-07-20 08:42:04 +02:00
|
|
|
header #branding h1 {
|
|
|
|
margin: 0;
|
|
|
|
}
|
2023-07-20 08:48:25 +02:00
|
|
|
|
2023-07-20 08:42:04 +02:00
|
|
|
header nav {
|
|
|
|
float: right;
|
|
|
|
margin-top: 10px;
|
|
|
|
}
|
2023-07-20 08:48:25 +02:00
|
|
|
|
|
|
|
header .highlight,
|
|
|
|
header .current a {
|
2023-07-20 08:42:04 +02:00
|
|
|
color: #e8491d;
|
|
|
|
font-weight: bold;
|
|
|
|
}
|
2023-07-20 08:48:25 +02:00
|
|
|
|
2023-07-20 08:42:04 +02:00
|
|
|
header a:hover {
|
|
|
|
color: #cccccc;
|
|
|
|
font-weight: bold;
|
|
|
|
}
|
2023-07-20 08:58:45 +02:00
|
|
|
|
|
|
|
pre {
|
|
|
|
background-color: #282c34;
|
|
|
|
color: #abb2bf;
|
|
|
|
padding: 10px;
|
|
|
|
border-radius: 5px;
|
|
|
|
overflow-x: auto;
|
|
|
|
}
|
|
|
|
|
|
|
|
.keyword {
|
|
|
|
color: #c678dd;
|
|
|
|
}
|
|
|
|
|
|
|
|
.string {
|
|
|
|
color: #98c379;
|
|
|
|
}
|
|
|
|
|
|
|
|
.number {
|
|
|
|
color: #61aeee;
|
|
|
|
}
|
2023-07-20 08:42:04 +02:00
|
|
|
</style>
|
|
|
|
</head>
|
2023-07-20 08:48:25 +02:00
|
|
|
|
2023-07-20 08:42:04 +02:00
|
|
|
<body>
|
|
|
|
<header>
|
|
|
|
<div class="container">
|
|
|
|
<div id="branding">
|
|
|
|
<h1><span class="highlight">BTC</span> Pay Checker</h1>
|
|
|
|
</div>
|
|
|
|
<nav>
|
|
|
|
<ul>
|
2023-07-20 08:47:37 +02:00
|
|
|
<li class="current"><a href="/">Home</a></li>
|
2023-07-20 09:09:43 +02:00
|
|
|
<li class=""><a target="_blank" href="https://gitea.urkob.com/urko/btc-pay-checker">Source code</a>
|
|
|
|
</li>
|
2023-07-20 08:42:04 +02:00
|
|
|
</ul>
|
|
|
|
</nav>
|
|
|
|
</div>
|
|
|
|
</header>
|
|
|
|
|
|
|
|
<div class="container">
|
|
|
|
<h2>How to use the /order POST endpoint</h2>
|
|
|
|
<p>This endpoint allows you to create a new order. It requires a JSON body with the following fields:</p>
|
|
|
|
<ul>
|
|
|
|
<li><strong>order_id:</strong> The ID of the order.</li>
|
|
|
|
<li><strong>client_id:</strong> The ID of the client.</li>
|
|
|
|
<li><strong>amount:</strong> The amount in USD that the client wants to pay.</li>
|
2023-07-20 08:48:25 +02:00
|
|
|
<li><strong>currency:</strong> The currency in which the payment will be made. This should be a valid
|
|
|
|
FiatCurrency value.</li>
|
2023-07-20 08:42:04 +02:00
|
|
|
<li><strong>client_email:</strong> The email of the client.</li>
|
|
|
|
</ul>
|
2023-07-20 08:48:25 +02:00
|
|
|
<h3>Examples</h3>
|
2023-07-20 08:47:37 +02:00
|
|
|
<h4>Go</h4>
|
|
|
|
<pre>
|
2023-07-20 08:58:45 +02:00
|
|
|
<code>
|
|
|
|
<span class="keyword">package</span> main
|
|
|
|
|
|
|
|
<span class="keyword">import</span> (
|
|
|
|
<span class="string">"bytes"</span>
|
|
|
|
<span class="string">"encoding/json"</span>
|
|
|
|
<span class="string">"net/http"</span>
|
|
|
|
)
|
|
|
|
|
|
|
|
<span class="keyword">type</span> Order <span class="keyword">struct</span> {
|
|
|
|
OrderID <span class="keyword">string</span> <span class="string">`json:"order_id"`</span>
|
|
|
|
ClientID <span class="keyword">string</span> <span class="string">`json:"client_id"`</span>
|
|
|
|
Amount <span class="keyword">float64</span> <span class="string">`json:"amount"`</span>
|
|
|
|
Currency <span class="keyword">string</span> <span class="string">`json:"currency"`</span>
|
|
|
|
ClientEmail <span class="keyword">string</span> <span class="string">`json:"client_email"`</span>
|
|
|
|
}
|
|
|
|
|
|
|
|
<span class="keyword">func</span> main() {
|
|
|
|
order := &Order{
|
|
|
|
OrderID: <span class="string">"123"</span>,
|
|
|
|
ClientID: <span class="string">"456"</span>,
|
|
|
|
Amount: <span class="number">100.0</span>,
|
|
|
|
Currency: <span class="string">"USD"</span>,
|
|
|
|
ClientEmail: <span class="string">"client@example.com"</span>,
|
2023-07-20 08:47:37 +02:00
|
|
|
}
|
|
|
|
|
2023-07-20 08:58:45 +02:00
|
|
|
jsonValue, _ := json.Marshal(order)
|
|
|
|
_, err := http.Post("{{host}}/order", <span class="string">"application/json"</span>, bytes.NewBuffer(jsonValue))
|
|
|
|
<span class="keyword">if</span> err != <span class="keyword">nil</span> {
|
|
|
|
<span class="comment">// handle error</span>
|
2023-07-20 08:47:37 +02:00
|
|
|
}
|
2023-07-20 08:58:45 +02:00
|
|
|
}
|
|
|
|
</code>
|
|
|
|
</pre>
|
|
|
|
|
2023-07-20 08:47:37 +02:00
|
|
|
|
|
|
|
<h4>Node.js</h4>
|
|
|
|
<pre>
|
2023-07-20 08:58:45 +02:00
|
|
|
<code>
|
|
|
|
<span class="keyword">const</span> axios = <span class="keyword">require</span>(<span class="string">'axios'</span>);
|
|
|
|
|
|
|
|
<span class="keyword">const</span> order = {
|
|
|
|
order_id: <span class="string">'123'</span>,
|
|
|
|
client_id: <span class="string">'456'</span>,
|
|
|
|
amount: <span class="number">100.0</span>,
|
|
|
|
currency: <span class="string">'USD'</span>,
|
|
|
|
client_email: <span class="string">'client@example.com'</span>
|
|
|
|
};
|
|
|
|
|
|
|
|
axios.post(<span class="string">'{{host}}/order'</span>, order)
|
|
|
|
.then(response => {
|
|
|
|
console.log(response.data);
|
|
|
|
})
|
|
|
|
.catch(error => {
|
|
|
|
console.error(error);
|
|
|
|
});
|
|
|
|
</code>
|
|
|
|
</pre>
|
2023-07-20 08:47:37 +02:00
|
|
|
|
|
|
|
<h4>CURL</h4>
|
|
|
|
<pre>
|
2023-07-20 08:58:45 +02:00
|
|
|
<code>
|
|
|
|
curl -X POST <span class="string">{{host}}/order</span> \
|
|
|
|
-H <span class="string">'Content-Type: application/json'</span> \
|
|
|
|
-d <span class="string">'{
|
|
|
|
"order_id": "123",
|
|
|
|
"client_id": "456",
|
|
|
|
"amount": 100.0,
|
|
|
|
"currency": "USD",
|
|
|
|
"client_email": "client@example.com"
|
|
|
|
}'</span>
|
|
|
|
</code>
|
|
|
|
</pre>
|
2023-07-20 08:47:37 +02:00
|
|
|
|
|
|
|
<h3>Handling the Response</h3>
|
2023-07-20 08:48:25 +02:00
|
|
|
<p>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.</p>
|
|
|
|
<p>Please note that the exact method of displaying the response will depend on the specifics of your application
|
|
|
|
and its user interface.</p>
|
2023-07-20 09:03:22 +02:00
|
|
|
|
|
|
|
|
2023-07-20 09:09:43 +02:00
|
|
|
<h3>Rate Limiting</h3>
|
|
|
|
<p>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.</p>
|
|
|
|
<p>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.</p>
|
|
|
|
<p>This is achieved with the following configuration:</p>
|
2023-07-20 09:03:22 +02:00
|
|
|
|
2023-07-20 09:09:43 +02:00
|
|
|
<pre>
|
2023-07-20 09:03:22 +02:00
|
|
|
<code>
|
|
|
|
s.app.Use(limiter.New(limiter.Config{
|
|
|
|
Max: 5,
|
|
|
|
Expiration: 30 * time.Minute,
|
|
|
|
LimiterMiddleware: limiter.SlidingWindow{},
|
|
|
|
}))
|
|
|
|
</code>
|
|
|
|
</pre>
|
|
|
|
|
2023-07-20 09:09:43 +02:00
|
|
|
<p>Please be aware of this limit when integrating with our API to ensure a smooth user experience.</p>
|
2023-07-20 09:03:22 +02:00
|
|
|
|
2023-07-20 09:09:43 +02:00
|
|
|
</div>
|
2023-07-20 08:42:04 +02:00
|
|
|
</body>
|
2023-07-20 08:48:25 +02:00
|
|
|
|
|
|
|
</html>
|