Payments
Create Payment Order
Create a payment order for an invoice to initiate the checkout flow.
POST
/
payments
/
order
Create a gateway payment order for an invoice
curl --request POST \
--url https://billing.example.com/payments/order \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"invoice_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
'import requests
url = "https://billing.example.com/payments/order"
payload = { "invoice_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a" }
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({invoice_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a'})
};
fetch('https://billing.example.com/payments/order', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://billing.example.com/payments/order",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'invoice_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://billing.example.com/payments/order"
payload := strings.NewReader("{\n \"invoice_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://billing.example.com/payments/order")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"invoice_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://billing.example.com/payments/order")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"invoice_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n}"
response = http.request(request)
puts response.read_body{
"ID": "<string>",
"Amount": 123,
"Currency": "<string>",
"Receipt": "<string>"
}{
"error": {
"code": "BAD_REQUEST",
"message": "<string>"
}
}{
"error": {
"code": "BAD_REQUEST",
"message": "<string>"
}
}Body Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
invoice_id | string | Yes | The ID of the invoice to create a payment order for. |
Example Request
curl -X POST https://api.recurso.dev/payments/order \
-H "Content-Type: application/json" \
-d '{
"invoice_id": "inv_5d4c3b2a1f0e9876"
}'
Response
Returns the payment order details including the gateway public key needed for the client-side checkout.{
"order_id": "ord_7a8b9c0d1e2f3456",
"gateway": "razorpay",
"amount": 249900,
"currency": "INR",
"key": "rzp_live_xxxxxxxxxx"
}
The
gateway field indicates which payment provider is configured for the tenant.
Possible values are razorpay or stripe. Use the returned key to initialize
the corresponding client-side checkout SDK.This is a public endpoint used by the checkout flow. The
key returned is the
gateway’s publishable/public key, safe to use on the client side.Errors
| Status | Code | When | Fix |
|---|---|---|---|
| 400 | validation_failed | The request body is malformed, or the invoice ID is not a valid UUID. | Send a well-formed JSON body with a valid invoice UUID. |
| 400 | invoice_already_paid | The invoice is already paid — no new payment order is needed. | Treat as success for collection purposes; fetch the invoice to confirm its status. |
| 404 | not_found | No invoice with that ID exists. | Verify the invoice ID. |
| 429 | rate_limited | This public endpoint has its own rate limit. | Back off and retry after the limit window. |
| 500 | internal_error | The invoice lookup failed, or the payment gateway rejected order creation. | Retry; check the tenant’s gateway connection if it persists. |
Authorizations
Body
application/json
⌘I
Create a gateway payment order for an invoice
curl --request POST \
--url https://billing.example.com/payments/order \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"invoice_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
'import requests
url = "https://billing.example.com/payments/order"
payload = { "invoice_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a" }
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({invoice_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a'})
};
fetch('https://billing.example.com/payments/order', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://billing.example.com/payments/order",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'invoice_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://billing.example.com/payments/order"
payload := strings.NewReader("{\n \"invoice_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://billing.example.com/payments/order")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"invoice_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://billing.example.com/payments/order")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"invoice_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n}"
response = http.request(request)
puts response.read_body{
"ID": "<string>",
"Amount": 123,
"Currency": "<string>",
"Receipt": "<string>"
}{
"error": {
"code": "BAD_REQUEST",
"message": "<string>"
}
}{
"error": {
"code": "BAD_REQUEST",
"message": "<string>"
}
}