Pay for an order with a Stripe Shared Payment Token
pay_orderPay for an order made with request_order without the confirm page, using a Stripe Shared Payment Token that your user approved (for example in Stripe Link). request_order returns payment: the amount per unit in USD, max_quantity and payment_handlers with the Stripe network_id to issue the token to; the token must allow at least amount × quantity in USD (plus sales tax where Egonex collects it, calculated from the shipping address for an item that ships and from the card's billing address otherwise; if the token doesn't cover it, nothing is charged and the error gives the total). Egonex creates the order for your user (a guest account on the email you give; receipts and seller replies go to that email). The result has the same status and order as check_request (order has its title, quantity, amount and deadlines), so you can tell your user where the order stands. The seller confirms an order before the buyer pays: when the result has status waiting_for_seller, the order was sent to the seller and nothing was charged; once check_request shows ready_to_pay, call pay_order again with the same request_id and buyer_email and a valid token (or your user pays from the link Egonex emails them). If the seller declines or doesn't respond, the order closes and nothing is charged. If the first pay_order result already has status ready_to_pay, the seller accepted right away and nothing was charged yet either: call pay_order again now in the same way. When the result has status paid and order.accept_by, the token was charged first and the seller has until then to accept; if they decline or don't respond, your user is refunded. For an item that ships (payment.requires_shipping_address), the pay_order call that charges must have shipping_address and shipping_address_confirmed=true, otherwise nothing is charged (shipping_address_required / shipping_address_not_confirmed): before you pay, ask your user for the full address, read it back to them and pass it only once they say it's right. A call that only sends the order to the seller charges nothing and doesn't keep an address: pass it on the call that pays. An address that fails the format check (the error names the field) or that Stripe can't place for sales tax is refused with shipping_address_invalid, and nothing is charged. The address becomes the order's shipping address only once the payment goes through (if it doesn't, nothing is kept and you can retry with a corrected address); order.ship_to then shows its city, state, ZIP code and country (never the name or street). After payment pay_order can't change it: a different address is refused (shipping_address_locked), and your user tells the seller in the Egonex chat instead. If your user pays on Egonex (the confirm page, or the link in Egonex's email), they enter the address there and no address you passed is used. If the email already has an Egonex account, nothing is charged and your user should pay on the confirm_url page instead. If Stripe declines the token, nothing is charged: retry with a new token and the same buyer_email. check_request then shows ready_to_pay when the seller had already accepted the order (pay it the same way as above), and payment_failed otherwise (or give confirm_url to your user). If the payment couldn't be confirmed (payment_error), it may or may not have gone through: don't call pay_order again while check_request shows payment_in_progress (Egonex is checking with Stripe, usually a few minutes; nothing is charged twice meanwhile). When it no longer does: if it shows paid, nothing more is needed; if it shows payment_failed or ready_to_pay, ask your user for a new approval and call pay_order again with the new token (not the same one). If the listing sold out meanwhile, or there aren't that many left, nothing is charged (sold_out / stock_short; stock_short says how many are left when it is 3 or fewer): search again, or call pay_order again with a smaller quantity. If the seller isn't taking new orders right now and hasn't accepted this order yet, nothing is charged (seller_not_taking_orders): choose another listing, or ask the seller with ask_seller. Errors end with their code in parentheses, the same code the REST API returns (for example (shipping_address_required), (invalid_input), (not_found)). After an order is placed, everything about it (confirming delivery, a problem with it, a refund or a cancellation) is handled on Egonex, in your user's chat with the seller (a buyer without an Egonex account opens it from the link in Egonex's email), not through these tools. Pass quote_id from quote_order (the one given to request_order, or a new one for the same listing and quantity) to charge exactly the quoted total: if the price, shipping, sales tax, agreed price or quantity changed, or the quote expired, nothing is charged (quote_changed / quote_expired / quote_not_found): call quote_order again. When the seller accepts first, quote the order with quote_order and request_id right before the call that charges. Only call this after your user agreed to the purchase and to Egonex's terms.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"request_id": "<request_id>",
"shared_payment_token": "<shared_payment_token>",
"buyer_email": "<buyer_email>",
"accept_terms": "<accept_terms>"
},
"name": "pay_order"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| quantity | No | How many units (items, hours, sessions...) at the listed price. Default 1. | |
| quote_id | No | Optional: quote_id from quote_order (it lasts 15 minutes). | |
| buyer_name | No | Optional name shown to the seller. | |
| request_id | Yes | The id returned by request_order. | |
| buyer_email | Yes | Your user's email address. Receipts, the order and seller replies go there. | |
| accept_terms | Yes | true only if your user agreed to Egonex's Terms of Service and Privacy Policy (payment.terms_url). | |
| delivery_days | No | Days the seller has to deliver once the order starts (it starts when it is paid and accepted), by the listing's kind: a physical item 1 to 30 (days to send it out, not the time in transit), a digital product 1 to 7, a service 1 to 60 (the day of the lesson or service). Anything else is rejected with 400. Default: the listing's delivery_days when it has one, else 3 (1 for a digital product). | |
| shipping_address | No | For an item that ships (payment.requires_shipping_address): where to ship it, as your user confirmed it. Required on the call that charges (when the seller accepts first, the call after they accept); a call that only sends the order doesn't keep it, and after payment it can't be changed. US addresses: 2-letter state code and a 5-digit ZIP code or ZIP+4. | |
| shared_payment_token | Yes | The Stripe Shared Payment Token (spt_...) your user approved for this purchase. | |
| shipping_address_confirmed | No | true only if you read shipping_address back to your user and they said it's right. Required with shipping_address on the call that charges. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| next | Yes | What happens next. | |
| paid | Yes | true = the payment went through. | |
| order | Yes | The order this request led to: made with pay_order, or placed by your user in the chat after confirming. Times are given only where they matter for the status. | |
| status | Yes | Where the order stands, as check_request reports it: pending (waiting for your user to confirm or decline; nothing has happened yet), declined (your user chose not to go ahead), expired (nobody acted within 7 days; the link no longer works), listing_unavailable (the listing isn't for sale anymore (taken down or sold out), so the request can't go ahead), message_sent (earlier message requests only: the message was sent to the seller as your user), awaiting_order (orders only: your user confirmed and the chat is open, but they haven't placed the order yet), payment_in_progress (orders only: a payment is being processed), payment_failed (orders only: a pay_order payment didn't go through; nothing was charged and the order can still be paid), waiting_for_seller (orders only: the order was sent to the seller, who hasn't accepted yet; nothing has been charged), ready_to_pay (orders only: the order is waiting to be paid (pay_order again, or your user pays on Egonex)), paid (orders only: paid; waiting for the seller to deliver), delivered (orders only: the seller marked it delivered; waiting for your user to confirm receipt), refund_requested (orders only: your user asked for a refund; Egonex is handling it), return_requested (orders only: the item has to go back for the refund: your user ships it by order.return_ship_by and adds the tracking number on Egonex), return_in_transit (orders only: the item is on its way back; the refund follows once it arrives and the seller confirms), return_delivered (orders only: the returned item arrived; waiting for the seller to confirm receipt, then the refund follows), completed (orders only: the order is complete), refund_pending (orders only: canceled after payment; the refund hasn't gone through yet), refunded (orders only: canceled after payment; your user was refunded), closed_unpaid (orders only: the order closed before anything was charged (close_reason says why)). | |
| request_id | Yes | The request. |