Orders
Generate Order Invoice
Trigger generation of an order’s invoice.
POST
/
v1
/
customer-portal
/
orders
/
{id}
/
invoice
Go (SDK)
package main
import(
"context"
macropaygo "github.com/web3group/macropay-go-main"
"os"
"github.com/web3group/macropay-go-main/models/operations"
"log"
)
func main() {
ctx := context.Background()
s := macropaygo.New()
res, err := s.CustomerPortal.Orders.GenerateInvoice(ctx, operations.CustomerPortalOrdersGenerateInvoiceSecurity{
CustomerSession: os.Getenv("MACROPAY_CUSTOMER_SESSION"),
}, "<value>")
if err != nil {
log.Fatal(err)
}
if res.Any != nil {
// handle response
}
}import macropay_sdk
from macropay_sdk import Macropay
with Macropay() as macropay:
res = macropay.customer_portal.orders.generate_invoice(security=macropay_sdk.CustomerPortalOrdersGenerateInvoiceSecurity(
customer_session="<YOUR_BEARER_TOKEN_HERE>",
), id="<value>")
# Handle response
print(res)import { Macropay } from "@macropayments/sdk";
const macropay = new Macropay();
async function run() {
const result = await macropay.customerPortal.orders.generateInvoice({
customerSession: process.env["MACROPAY_CUSTOMER_SESSION"] ?? "",
}, {
id: "<value>",
});
console.log(result);
}
run();declare(strict_types=1);
require 'vendor/autoload.php';
use Macropay;
use Macropay\Models\Operations;
$sdk = Macropay\Macropay::builder()->build();
$requestSecurity = new Operations\CustomerPortalOrdersGenerateInvoiceSecurity(
customerSession: '<YOUR_BEARER_TOKEN_HERE>',
);
$response = $sdk->customerPortal->orders->generateInvoice(
security: $requestSecurity,
id: '<value>'
);
if ($response->any !== null) {
// handle response
}curl --request POST \
--url https://api.macropay.ai/v1/customer-portal/orders/{id}/invoice \
--header 'Authorization: Bearer <token>'const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.macropay.ai/v1/customer-portal/orders/{id}/invoice', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));HttpResponse<String> response = Unirest.post("https://api.macropay.ai/v1/customer-portal/orders/{id}/invoice")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.macropay.ai/v1/customer-portal/orders/{id}/invoice")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"error": "<string>",
"detail": "<string>"
}Once the invoice is generated, it’s permanent and cannot be modified.Make sure the billing details (name and address) are correct before generating the invoice. You can update them before generating the invoice by calling the
PATCH /v1/customer-portal/orders/{id} endpoint.After successfully calling this endpoint, you get a
202 response, meaning
the generation of the invoice has been scheduled. It usually only takes a few
seconds before you can retrieve the invoice using the GET /v1/customer-portal/orders/{id}/invoice endpoint.If you want a reliable notification when the invoice is ready, you can listen to the
order.updated webhook and check the is_invoice_generated field.Authorizations
customer_sessionmember_session
Customer session tokens are specific tokens that are used to authenticate customers on your organization. You can create those sessions programmatically using the Create Customer Session endpoint.
Path Parameters
The order ID.
Response
Successful Response
⌘I
Go (SDK)
package main
import(
"context"
macropaygo "github.com/web3group/macropay-go-main"
"os"
"github.com/web3group/macropay-go-main/models/operations"
"log"
)
func main() {
ctx := context.Background()
s := macropaygo.New()
res, err := s.CustomerPortal.Orders.GenerateInvoice(ctx, operations.CustomerPortalOrdersGenerateInvoiceSecurity{
CustomerSession: os.Getenv("MACROPAY_CUSTOMER_SESSION"),
}, "<value>")
if err != nil {
log.Fatal(err)
}
if res.Any != nil {
// handle response
}
}import macropay_sdk
from macropay_sdk import Macropay
with Macropay() as macropay:
res = macropay.customer_portal.orders.generate_invoice(security=macropay_sdk.CustomerPortalOrdersGenerateInvoiceSecurity(
customer_session="<YOUR_BEARER_TOKEN_HERE>",
), id="<value>")
# Handle response
print(res)import { Macropay } from "@macropayments/sdk";
const macropay = new Macropay();
async function run() {
const result = await macropay.customerPortal.orders.generateInvoice({
customerSession: process.env["MACROPAY_CUSTOMER_SESSION"] ?? "",
}, {
id: "<value>",
});
console.log(result);
}
run();declare(strict_types=1);
require 'vendor/autoload.php';
use Macropay;
use Macropay\Models\Operations;
$sdk = Macropay\Macropay::builder()->build();
$requestSecurity = new Operations\CustomerPortalOrdersGenerateInvoiceSecurity(
customerSession: '<YOUR_BEARER_TOKEN_HERE>',
);
$response = $sdk->customerPortal->orders->generateInvoice(
security: $requestSecurity,
id: '<value>'
);
if ($response->any !== null) {
// handle response
}curl --request POST \
--url https://api.macropay.ai/v1/customer-portal/orders/{id}/invoice \
--header 'Authorization: Bearer <token>'const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.macropay.ai/v1/customer-portal/orders/{id}/invoice', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));HttpResponse<String> response = Unirest.post("https://api.macropay.ai/v1/customer-portal/orders/{id}/invoice")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.macropay.ai/v1/customer-portal/orders/{id}/invoice")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"error": "<string>",
"detail": "<string>"
}