Polarex.Orders (Polarex v0.5.1)

Copy Markdown View Source

Provides API endpoints related to orders

Summary

Functions

customer_portal_orders_confirm_retry_payment(id, body, opts \\ [])

Confirm Retry Payment

Confirm a retry payment using a Stripe confirmation token.

Request Body

Content Types: application/json

customer_portal_orders_generate_invoice(id, opts \\ [])

@spec customer_portal_orders_generate_invoice(id :: String.t(), opts :: keyword()) ::
  {:ok, map()}
  | {:error,
     Polarex.MissingInvoiceBillingDetails.t()
     | Polarex.OrderNotEligibleForInvoice.t()
     | Polarex.ResourceNotFound.t()}

Generate Order Invoice

Trigger generation of an order's invoice.

customer_portal_orders_get(id, opts \\ [])

@spec customer_portal_orders_get(id :: String.t(), opts :: keyword()) ::
  {:ok, Polarex.CustomerOrder.t()}
  | {:error, Polarex.HTTPValidationError.t() | Polarex.ResourceNotFound.t()}

Get Order

Get an order by ID for the authenticated customer.

customer_portal_orders_get_payment_status(id, opts \\ [])

@spec customer_portal_orders_get_payment_status(id :: String.t(), opts :: keyword()) ::
  {:ok, Polarex.CustomerOrderPaymentStatus.t()}
  | {:error, Polarex.HTTPValidationError.t() | Polarex.ResourceNotFound.t()}

Get Order Payment Status

Get the current payment status for an order.

customer_portal_orders_invoice(id, opts \\ [])

@spec customer_portal_orders_invoice(id :: String.t(), opts :: keyword()) ::
  {:ok, Polarex.CustomerOrderInvoice.t()}
  | {:error, Polarex.HTTPValidationError.t() | Polarex.ResourceNotFound.t()}

Get Order Invoice

Get an order's invoice data.

customer_portal_orders_list(opts \\ [])

@spec customer_portal_orders_list(opts :: keyword()) ::
  {:ok, Polarex.ListResourceCustomerOrder.t()}
  | {:error, Polarex.HTTPValidationError.t()}

List Orders

List orders of the authenticated customer.

Options

  • product_id: Filter by product ID.
  • product_billing_type: Filter by product billing type. recurring will filter data corresponding to subscriptions creations or renewals. one_time will filter data corresponding to one-time purchases.
  • subscription_id: Filter by subscription ID.
  • query: Search by product or organization name.
  • page: Page number, defaults to 1.
  • limit: Size of a page, defaults to 10. Maximum is 100.
  • sorting: Sorting criterion. Several criteria can be used simultaneously and will be applied in order. Add a minus sign - before the criteria name to sort by descending order.

customer_portal_orders_receipt(id, opts \\ [])

@spec customer_portal_orders_receipt(id :: String.t(), opts :: keyword()) ::
  {:ok, Polarex.CustomerOrderReceipt.t()}
  | {:error, Polarex.HTTPValidationError.t() | Polarex.ResourceNotFound.t()}

Get Order Receipt

Get a presigned URL to download an order's receipt PDF.

customer_portal_orders_update(id, body, opts \\ [])

@spec customer_portal_orders_update(
  id :: String.t(),
  body :: Polarex.CustomerOrderUpdate.t(),
  opts :: keyword()
) ::
  {:ok, Polarex.CustomerOrder.t()}
  | {:error, Polarex.HTTPValidationError.t() | Polarex.ResourceNotFound.t()}

Update Order

Update an order for the authenticated customer.

Request Body

Content Types: application/json

orders_create(body, opts \\ [])

@spec orders_create(body :: Polarex.OrderCreate.t(), opts :: keyword()) ::
  {:ok, Polarex.Order.t()} | {:error, Polarex.HTTPValidationError.t()}

Create Order

Create a draft order for an off-session charge against a saved payment method. The order is created with status=draft and no invoice number; call POST /v1/orders/{id}/finalize to attempt the charge.

The organization must have the off_session_charges_enabled feature flag.

Scopes: orders:write

Request Body

Content Types: application/json

orders_export(opts \\ [])

@spec orders_export(opts :: keyword()) ::
  {:ok, String.t()} | {:error, Polarex.HTTPValidationError.t()}

Export Orders

Export orders as a CSV file.

Scopes: orders:read

Options

  • organization_id: Filter by organization ID.
  • product_id: Filter by product ID.

orders_finalize(id, body, opts \\ [])

Finalize Order

Finalize a draft order and synchronously attempt an off-session charge.

On success, the order transitions to paid and benefit grants fire before the response returns. On failure (decline, missing payment method, SCA challenge), the order stays in draft and a 4xx error is returned.

The request fails with 412 if the order is not in draft status.

Scopes: orders:write

Request Body

Content Types: application/json

orders_generate_invoice(id, opts \\ [])

@spec orders_generate_invoice(id :: String.t(), opts :: keyword()) ::
  {:ok, map()}
  | {:error,
     Polarex.MissingInvoiceBillingDetails.t()
     | Polarex.OrderNotEligibleForInvoice.t()
     | Polarex.ResourceNotFound.t()}

Generate Order Invoice

Trigger generation of an order's invoice.

Scopes: orders:read

orders_get(id, opts \\ [])

@spec orders_get(id :: String.t(), opts :: keyword()) ::
  {:ok, Polarex.Order.t()}
  | {:error, Polarex.HTTPValidationError.t() | Polarex.ResourceNotFound.t()}

Get Order

Get an order by ID.

Scopes: orders:read

orders_invoice(id, opts \\ [])

@spec orders_invoice(id :: String.t(), opts :: keyword()) ::
  {:ok, Polarex.OrderInvoice.t()}
  | {:error, Polarex.HTTPValidationError.t() | Polarex.ResourceNotFound.t()}

Get Order Invoice

Get an order's invoice data.

Scopes: orders:read

orders_list(opts \\ [])

@spec orders_list(opts :: keyword()) ::
  {:ok, Polarex.ListResourceOrder.t()}
  | {:error, Polarex.HTTPValidationError.t()}

List Orders

List orders.

Scopes: orders:read

Options

  • organization_id: Filter by organization ID.
  • product_id: Filter by product ID.
  • product_billing_type: Filter by product billing type. recurring will filter data corresponding to subscriptions creations or renewals. one_time will filter data corresponding to one-time purchases.
  • discount_id: Filter by discount ID.
  • customer_id: Filter by customer ID.
  • external_customer_id: Filter by customer external ID.
  • checkout_id: Filter by checkout ID.
  • subscription_id: Filter by subscription ID.
  • page: Page number, defaults to 1.
  • limit: Size of a page, defaults to 10. Maximum is 100.
  • sorting: Sorting criterion. Several criteria can be used simultaneously and will be applied in order. Add a minus sign - before the criteria name to sort by descending order.
  • metadata: Filter by metadata key-value pairs. It uses the deepObject style, e.g. ?metadata[key]=value.

orders_receipt(id, opts \\ [])

@spec orders_receipt(id :: String.t(), opts :: keyword()) ::
  {:ok, Polarex.OrderReceipt.t()}
  | {:error, Polarex.HTTPValidationError.t() | Polarex.ResourceNotFound.t()}

Get Order Receipt

Get a presigned URL to download an order's receipt PDF.

Scopes: orders:read

orders_update(id, body, opts \\ [])

@spec orders_update(
  id :: String.t(),
  body :: Polarex.OrderUpdate.t(),
  opts :: keyword()
) ::
  {:ok, Polarex.Order.t()}
  | {:error, Polarex.HTTPValidationError.t() | Polarex.ResourceNotFound.t()}

Update Order

Update an order.

Scopes: orders:write

Request Body

Content Types: application/json