Create order

Opens a server-priced PayPal REST v2 order for either a bounded credit top-up (intent CAPTURE) or a plan purchase's first period (intent AUTHORIZE).

POST /v1/billing/paypal/order

Addresshttps://api.hanzo.ai/v1/billing/paypal/order
MethodPOST
Operationpost_billing_paypal_order
AuthAuthorization: Bearer $HANZO_API_KEY

Opens a server-priced PayPal REST v2 order for either a bounded credit top-up (intent CAPTURE) or a plan purchase's first period (intent AUTHORIZE).

No balance or subscription row is minted here: the browser hands the returned orderId to the PayPal Smart Buttons SDK for buyer approval, then settles the payment through POST /v1/billing/topup/token or POST /v1/billing/subscribe/card with provider: "paypal".

Request

13 fields, body application/json (required).

FieldInTypeRequiredDescription
X-Idempotency-Keyheaderstring—
amountCentsbodyinteger (int64)—AmountCents is the top-up amount in whole cents when PlanID is empty.
balanceCentsbodyinteger (int64)—BalanceCents is an organization's optional starting usage balance.
couponbodystring—Coupon is an optional plan coupon code for a monthly subscription.
currencybodystring—Currency is the ISO-4217 code (default usd).
intervalbodystring—Interval selects the billing term ("month" or "year").
levelbodyinteger (int64)—Level selects which published price level of the plan to buy.
linesbodybilling.SaleLine[]—Lines are a team's additional seat types bought on the same subscription.
lines[].planIdbodystring—PlanID is the seat type, e.g. "team-premium".
lines[].quantitybodyinteger (int64)—Quantity is the seats of it bought, at least 1.
planIdbodystring—PlanID is the plan slug when buying a plan's first period; empty for a top-up.
quantitybodyinteger (int64)—Quantity is the seat count for a per-seat plan.
storeIdbodystring—StoreID scopes the plan catalog when set.

Response

StatusBodyMeaning
200billing.PayPalOrderOutok
defaultproblem-detailsrefused

200 body — 7 fields.

FieldInTypeAlwaysDescription
amountCentsbodyinteger (int64)—
currencybodystring—
environmentbodystring—
intentbodystring—
orderIdbodystring—
statusbodystring—
testbodyboolean—

Failure carries the platform error shape — see Errors.

Examples

hanzo billing paypal order
import { Configuration, BillingApi } from 'hanzoai';

const api = new BillingApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await api.postBillingPaypalOrder({ amountCents: 0, balanceCents: 0 });
from hanzoai.cloud import ApiClient, Configuration
from hanzoai.cloud.api import BillingApi

client = ApiClient(Configuration(access_token=os.environ["HANZO_API_KEY"]))
result = BillingApi(client).post_billing_paypal_order(amount_cents=0, balance_cents=0)
cfg := hanzoai.NewConfiguration()
cfg.AddDefaultHeader("Authorization", "Bearer "+os.Getenv("HANZO_API_KEY"))
client := hanzoai.NewAPIClient(cfg)

resp, _, err := client.BillingAPI.PostBillingPaypalOrder(context.Background()).Execute()
if err != nil {
	return err
}
use hanzo_client::apis::{configuration::Configuration, billing_api};

let mut cfg = Configuration::new();
cfg.bearer_access_token = std::env::var("HANZO_API_KEY").ok();

let result = billing_api::post_billing_paypal_order(&cfg, Default::default()).await?;
import ai.hanzo.cloud.ApiClient;
import ai.hanzo.cloud.api.BillingApi;

ApiClient client = new ApiClient();
client.setBearerToken(System.getenv("HANZO_API_KEY"));

var result = new BillingApi(client).postBillingPaypalOrder();

The method above is the one at the current release of the document. [email protected] (npm) and [email protected] (PyPI) were generated from an earlier release, where this operation carried a different id, so it spells the method differently — regenerating the clients is what makes the two agree. SDKs →

curl -X POST https://api.hanzo.ai/v1/billing/paypal/order \
  -H "Authorization: Bearer $HANZO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
       "amountCents": 0,
       "balanceCents": 0
     }'

MCP reaches billing through the billing tool, which names its 45 operations with its own verbs — this one among them, under a name only MCP declares. describe explains any of them:

curl -X POST https://api.hanzo.ai/v1/mcp \
  -H "Content-Type: application/json" \
  -d '{
       "jsonrpc": "2.0",
       "id": 1,
       "method": "tools/call",
       "params": {
         "name": "describe",
         "arguments": {
           "op": "list_billing_accounts"
         }
       }
     }'

Billing API · All Hanzo APIs · Interactive reference

Was this page useful?
Broken link or missing step? Drop it in #docs on Discord or open a PR.