Order methods: fulfill, pay, place, refund
The Order Verbs fulfill, pay, place, refund as typed SDK methods, with inputs, result, refusals and an example.
Reference for Order, one group of Order methods.
Order.fulfill
Fulfill grants what an Order bought: Entitlements for software and data, a shipment for goods. Verb page.
interface OrderVerbs {
fulfill(input: OrderFulfillInput, options?: SB.CallOptions): SB.Call<Order>
}Emits Order.fulfilled.
Inputs
| Input | Type | Required | Description |
|---|---|---|---|
order | Order | required | The paid Order. |
Returns
| Output | Type | Required | Description |
|---|---|---|---|
order | Order | required | The fulfilled Order. |
Refuses when
| Check | Error | Fix | Then call |
|---|---|---|---|
| The key is valid, but its scopes do not allow this operation. | forbidden | Use 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. | refused | Read the record, run the Verb that moves it to an allowed state, then retry. | None. |
Example
import { $ } from 'startup-builder'
const order = await $.Order.fulfill({ order: 'order_dswDnxf2vt' })Order.pay
Pay settles an Order’s amount through the Startup’s payment account and posts the matching Entries. Verb page.
interface OrderVerbs {
pay(input: OrderPayInput, options?: SB.CallOptions): SB.Call<Order>
}Emits Order.paid.
Inputs
| Input | Type | Required | Description |
|---|---|---|---|
order | Order | required | The placed Order. |
paymentMethod | string | The saved method to charge. |
Returns
| Output | Type | Required | Description |
|---|---|---|---|
order | Order | required | The paid Order. |
Refuses when
| Check | Error | Fix | Then call |
|---|---|---|---|
| The operation is part of an Offer the caller has not accepted or paid for. | payment-required | Accept the Offer named in the response, then retry the call. | Offer.accept |
| The key is valid, but its scopes do not allow this operation. | forbidden | Use 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. | refused | Read 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-disabled | Have the owner of record complete the open requirement Task; charges and paid Offers resume on re-enable. | None. |
Example
import { $ } from 'startup-builder'
const order = await $.Order.pay({ order: 'order_dswDnxf2vt' })Order.place
Place commits a Customer to buy an Offer once and records the Offer Version and price at that moment. Verb page.
interface OrderVerbs {
place(input: OrderPlaceInput, options?: SB.CallOptions): SB.Call<Order>
}Emits Order.placed.
Inputs
| Input | Type | Required | Description |
|---|---|---|---|
offer | Offer | required | The Offer to buy. |
quantity | integer | Units. Defaults to 1. | |
promotionCode | string | A promotion code the buyer typed; applies its Coupon when the Coupon covers the Offer. |
Returns
| Output | Type | Required | Description |
|---|---|---|---|
order | Order | required | The placed Order. |
Refuses when
| Check | Error | Fix | Then call |
|---|---|---|---|
| The input does not match the schema of the operation. | invalid-input | Read 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-required | Accept the Offer named in the response, then retry the call. | Offer.accept |
| The key is valid, but its scopes do not allow this operation. | forbidden | Use 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. | refused | Read the record, run the Verb that moves it to an allowed state, then retry. | None. |
Example
import { $ } from 'startup-builder'
const order = await $.Order.place({ offer: 'offer_2hzYe1ERo0' })Order.refund
Refund returns all or part of an Order’s payment to the Customer and posts the reversing Entries. Verb page.
interface OrderVerbs {
refund(input: OrderRefundInput, options?: SB.CallOptions): SB.Call<Order>
}Emits Order.refunded.
Inputs
| Input | Type | Required | Description |
|---|---|---|---|
order | Order | required | The paid Order. |
amount | money | The amount. Defaults to the full payment. | |
reason | text | required | Why the money goes back. |
Returns
| Output | Type | Required | Description |
|---|---|---|---|
order | Order | required | The refunded Order. |
Refuses when
| Check | Error | Fix | Then call |
|---|---|---|---|
| The input does not match the schema of the operation. | invalid-input | Read 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. | forbidden | Use 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. | refused | Read the record, run the Verb that moves it to an allowed state, then retry. | None. |
Example
import { $ } from 'startup-builder'
const order = await $.Order.refund({ order: 'order_dswDnxf2vt', reason: 'Example reason' })