Skip to content

Order routes: fulfill, pay, place, refund

The Order Verbs fulfill, pay, place, refund as api.sb routes, with inputs, result, refusals and an example.

Reference for Order, one group of Order routes.

Order.fulfill

Fulfill grants what an Order bought: Entitlements for software and data, a shipment for goods. Verb page.

Text
POST /{namespace}/orders/{order}/fulfill

Path: order. Emits Order.fulfilled.

Inputs

InputTypeRequiredDescription
orderOrderrequiredThe paid Order.

Returns

OutputTypeRequiredDescription
orderOrderrequiredThe fulfilled Order.

Refuses when

CheckErrorFixThen call
The key is valid, but its scopes do not allow this operation.forbiddenUse a key whose scopes cover the operation, or ask an owner of the namespace to grant them.None.
The record is not in a state that allows this Verb, so the call is refused.refusedRead the record, run the Verb that moves it to an allowed state, then retry.None.

Example

Terminal
curl -X POST https://api.sb/leaseline.app/orders/order_dswDnxf2vt/fulfill \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY"
JSON
{
  "api": "https://api.sb/leaseline.app",
  "order": {
    "$id": "https://api.sb/leaseline.app/orders/order_dswDnxf2vt",
    "$type": "Order",
    "total": {
      "amount": 29,
      "currency": "USD"
    },
    "status": "fulfilled"
  },
  "action": {
    "$id": "https://api.sb/leaseline.app/actions/act_br07HsG8MG",
    "operation": "Order.fulfill",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/leaseline.app/actions/act_br07HsG8MG"
  }
}

Order.pay

Pay settles an Order’s amount through the Startup’s payment account and posts the matching Entries. Verb page.

Text
POST /{namespace}/orders/{order}/pay

Path: order. Body, as JSON: the other inputs. Emits Order.paid.

Inputs

InputTypeRequiredDescription
orderOrderrequiredThe placed Order.
paymentMethodstringThe saved method to charge.

Returns

OutputTypeRequiredDescription
orderOrderrequiredThe paid Order.

Refuses when

CheckErrorFixThen call
The operation is part of an Offer the caller has not accepted or paid for.payment-requiredAccept the Offer named in the response, then retry the call.Offer.accept
The key is valid, but its scopes do not allow this operation.forbiddenUse a key whose scopes cover the operation, or ask an owner of the namespace to grant them.None.
The record is not in a state that allows this Verb, so the call is refused.refusedRead the record, run the Verb that moves it to an allowed state, then retry.None.
Stripe disabled charges on the Startup’s payment account because a requirement passed its deadline.charges-disabledHave the owner of record complete the open requirement Task; charges and paid Offers resume on re-enable.None.

Example

Terminal
curl -X POST https://api.sb/leaseline.app/orders/order_dswDnxf2vt/pay \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY"
JSON
{
  "api": "https://api.sb/leaseline.app",
  "order": {
    "$id": "https://api.sb/leaseline.app/orders/order_dswDnxf2vt",
    "$type": "Order",
    "total": {
      "amount": 29,
      "currency": "USD"
    },
    "status": "paid"
  },
  "action": {
    "$id": "https://api.sb/leaseline.app/actions/act_br07HsG8MG",
    "operation": "Order.pay",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/leaseline.app/actions/act_br07HsG8MG"
  }
}

Order.place

Place commits a Customer to buy an Offer once and records the Offer Version and price at that moment. Verb page.

Text
POST /{namespace}/orders/place

Body, as JSON: the inputs. Emits Order.placed.

Inputs

InputTypeRequiredDescription
offerOfferrequiredThe Offer to buy.
quantityintegerUnits. Defaults to 1.
promotionCodestringA promotion code the buyer typed; applies its Coupon when the Coupon covers the Offer.

Returns

OutputTypeRequiredDescription
orderOrderrequiredThe placed Order.

Refuses when

CheckErrorFixThen call
The input does not match the schema of the operation.invalid-inputRead the schema of the operation, then send every required field with the right type.None.
The operation is part of an Offer the caller has not accepted or paid for.payment-requiredAccept the Offer named in the response, then retry the call.Offer.accept
The key is valid, but its scopes do not allow this operation.forbiddenUse a key whose scopes cover the operation, or ask an owner of the namespace to grant them.None.
The record is not in a state that allows this Verb, so the call is refused.refusedRead the record, run the Verb that moves it to an allowed state, then retry.None.

Example

Terminal
curl -X POST https://api.sb/leaseline.app/orders/place \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"offer":"offer_2hzYe1ERo0"}'
JSON
{
  "api": "https://api.sb/leaseline.app",
  "order": {
    "$id": "https://api.sb/leaseline.app/orders/order_dswDnxf2vt",
    "$type": "Order",
    "total": {
      "amount": 29,
      "currency": "USD"
    },
    "status": "placed"
  },
  "action": {
    "$id": "https://api.sb/leaseline.app/actions/act_br07HsG8MG",
    "operation": "Order.place",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/leaseline.app/actions/act_br07HsG8MG"
  }
}

Order.refund

Refund returns all or part of an Order’s payment to the Customer and posts the reversing Entries. Verb page.

Text
POST /{namespace}/orders/{order}/refund

Path: order. Body, as JSON: the other inputs. Emits Order.refunded.

Inputs

InputTypeRequiredDescription
orderOrderrequiredThe paid Order.
amountmoneyThe amount. Defaults to the full payment.
reasontextrequiredWhy the money goes back.

Returns

OutputTypeRequiredDescription
orderOrderrequiredThe refunded Order.

Refuses when

CheckErrorFixThen call
The input does not match the schema of the operation.invalid-inputRead the schema of the operation, then send every required field with the right type.None.
The key is valid, but its scopes do not allow this operation.forbiddenUse a key whose scopes cover the operation, or ask an owner of the namespace to grant them.None.
The record is not in a state that allows this Verb, so the call is refused.refusedRead the record, run the Verb that moves it to an allowed state, then retry.None.

Example

Terminal
curl -X POST https://api.sb/leaseline.app/orders/order_dswDnxf2vt/refund \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"reason":"Example reason"}'
JSON
{
  "api": "https://api.sb/leaseline.app",
  "order": {
    "$id": "https://api.sb/leaseline.app/orders/order_dswDnxf2vt",
    "$type": "Order",
    "total": {
      "amount": 29,
      "currency": "USD"
    },
    "status": "refunded"
  },
  "action": {
    "$id": "https://api.sb/leaseline.app/actions/act_br07HsG8MG",
    "operation": "Order.refund",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/leaseline.app/actions/act_br07HsG8MG"
  }
}