// This file is auto-generated by oagen. Do not edit.
use crate::client::Client;
#[allow(unused_imports)]
use crate::enums::*;
use crate::error::Error;
#[allow(unused_imports)]
use crate::models::*;
#[allow(unused_imports)]
use serde::Serialize;
pub struct InvoicesApi<'a> {
pub(crate) client: &'a Client,
}
#[derive(Debug, Clone, Serialize)]
pub struct ListParams {
/// Number of items to return per page.
///
/// Defaults to `15`.
#[serde(skip_serializing_if = "Option::is_none")]
pub limit: Option<i64>,
/// Page number to return.
///
/// Defaults to `1`.
#[serde(skip_serializing_if = "Option::is_none")]
pub page: Option<i64>,
/// Free-text search term.
#[serde(skip_serializing_if = "Option::is_none")]
pub search: Option<String>,
/// Which invoice field the search term should be matched against.
#[serde(skip_serializing_if = "Option::is_none")]
pub search_by: Option<InvoicesSearchBy>,
/// Filter by invoice ID.
#[serde(skip_serializing_if = "Option::is_none")]
pub id: Option<String>,
/// Filter by customer email.
#[serde(skip_serializing_if = "Option::is_none")]
pub email: Option<String>,
/// Filter by payment transaction ID.
#[serde(skip_serializing_if = "Option::is_none")]
pub transaction_id: Option<String>,
/// Filter by delivered serial.
#[serde(skip_serializing_if = "Option::is_none")]
pub serial_code: Option<String>,
/// Filter by customer-provided additional information.
#[serde(skip_serializing_if = "Option::is_none")]
pub additional_info: Option<String>,
/// Filter by product or variant title.
#[serde(skip_serializing_if = "Option::is_none")]
pub product_name: Option<String>,
/// Filter by attached Discord data.
#[serde(skip_serializing_if = "Option::is_none")]
pub discord_data: Option<String>,
/// Filter by crypto TXID.
#[serde(skip_serializing_if = "Option::is_none")]
pub crypto_txid: Option<String>,
/// Filter by crypto payment address.
#[serde(skip_serializing_if = "Option::is_none")]
pub crypto_address: Option<String>,
/// Filter by coupon code.
#[serde(skip_serializing_if = "Option::is_none")]
pub coupon_code: Option<String>,
/// Filter by one or more invoice statuses. Repeat the parameter to select several.
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "status[]")]
pub status: Option<Vec<InvoicesStatus>>,
/// Filter by one or more payment methods. Repeat the parameter to select several.
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "payment_methods[]")]
pub payment_methods: Option<Vec<InvoicesPaymentMethods>>,
/// Sort order for the result set.
#[serde(skip_serializing_if = "Option::is_none")]
pub sort: Option<InvoicesSort>,
/// Store slug. Required for OAuth access tokens. API keys may omit it to use their current store, or the first accessible store when no current store is selected.
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "X-STORE")]
pub x_store: Option<String>,
}
impl Default for ListParams {
#[allow(deprecated)]
fn default() -> Self {
Self {
limit: Some(15),
page: Some(1),
search: Default::default(),
search_by: Default::default(),
id: Default::default(),
email: Default::default(),
transaction_id: Default::default(),
serial_code: Default::default(),
additional_info: Default::default(),
product_name: Default::default(),
discord_data: Default::default(),
crypto_txid: Default::default(),
crypto_address: Default::default(),
coupon_code: Default::default(),
status: Default::default(),
payment_methods: Default::default(),
sort: Default::default(),
x_store: Default::default(),
}
}
}
#[derive(Debug, Clone, Serialize)]
pub struct CreateParams {
/// Store slug. Required for OAuth access tokens. API keys may omit it to use their current store, or the first accessible store when no current store is selected.
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "X-STORE")]
pub x_store: Option<String>,
/// Request body sent with this call.
///
/// Required.
#[serde(skip)]
pub body: SdkCreateInvoiceRequestApplicationJson,
}
impl CreateParams {
/// Construct a new `CreateParams` with the required fields set.
#[allow(deprecated)]
pub fn new(body: SdkCreateInvoiceRequestApplicationJson) -> Self {
Self {
x_store: Default::default(),
body,
}
}
}
#[derive(Debug, Clone, Serialize)]
pub struct SearchParams {
/// Store slug. Required for OAuth access tokens. API keys may omit it to use their current store, or the first accessible store when no current store is selected.
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "X-STORE")]
pub x_store: Option<String>,
/// Request body sent with this call.
///
/// Required.
#[serde(skip)]
pub body: SdkSearchInvoicesRequestApplicationJson,
}
impl SearchParams {
/// Construct a new `SearchParams` with the required fields set.
#[allow(deprecated)]
pub fn new(body: SdkSearchInvoicesRequestApplicationJson) -> Self {
Self {
x_store: Default::default(),
body,
}
}
}
#[derive(Debug, Clone, Default, Serialize)]
pub struct GetParams {
/// Store slug. Required for OAuth access tokens. API keys may omit it to use their current store, or the first accessible store when no current store is selected.
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "X-STORE")]
pub x_store: Option<String>,
}
#[derive(Debug, Clone, Default, Serialize)]
pub struct GoToCheckoutParams {
/// Store slug. Required for OAuth access tokens. API keys may omit it to use their current store, or the first accessible store when no current store is selected.
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "X-STORE")]
pub x_store: Option<String>,
}
#[derive(Debug, Clone, Default, Serialize)]
pub struct GetDeliverablesParams {
/// Store slug. Required for OAuth access tokens. API keys may omit it to use their current store, or the first accessible store when no current store is selected.
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "X-STORE")]
pub x_store: Option<String>,
}
#[derive(Debug, Clone, Serialize)]
pub struct MarkCompletedParams {
/// Store slug. Required for OAuth access tokens. API keys may omit it to use their current store, or the first accessible store when no current store is selected.
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "X-STORE")]
pub x_store: Option<String>,
/// Request body sent with this call.
///
/// Required.
#[serde(skip)]
pub body: SdkMarkPendingInvoiceCompletedRequestApplicationJson,
}
impl MarkCompletedParams {
/// Construct a new `MarkCompletedParams` with the required fields set.
#[allow(deprecated)]
pub fn new(body: SdkMarkPendingInvoiceCompletedRequestApplicationJson) -> Self {
Self {
x_store: Default::default(),
body,
}
}
}
#[derive(Debug, Clone, Serialize)]
pub struct MarkVoidedParams {
/// Store slug. Required for OAuth access tokens. API keys may omit it to use their current store, or the first accessible store when no current store is selected.
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "X-STORE")]
pub x_store: Option<String>,
/// Request body sent with this call.
///
/// Required.
#[serde(skip)]
pub body: SdkMarkPendingInvoiceVoidedRequestApplicationJson,
}
impl MarkVoidedParams {
/// Construct a new `MarkVoidedParams` with the required fields set.
#[allow(deprecated)]
pub fn new(body: SdkMarkPendingInvoiceVoidedRequestApplicationJson) -> Self {
Self {
x_store: Default::default(),
body,
}
}
}
#[derive(Debug, Clone, Serialize)]
pub struct IssueReplacementParams {
/// Store slug. Required for OAuth access tokens. API keys may omit it to use their current store, or the first accessible store when no current store is selected.
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "X-STORE")]
pub x_store: Option<String>,
/// Request body sent with this call.
///
/// Required.
#[serde(skip)]
pub body: SdkIssueReplacementForCompletedInvoiceRequestApplicationJson,
}
impl IssueReplacementParams {
/// Construct a new `IssueReplacementParams` with the required fields set.
#[allow(deprecated)]
pub fn new(body: SdkIssueReplacementForCompletedInvoiceRequestApplicationJson) -> Self {
Self {
x_store: Default::default(),
body,
}
}
}
#[derive(Debug, Clone, Serialize)]
pub struct UpdateStatusParams {
/// Store slug. Required for OAuth access tokens. API keys may omit it to use their current store, or the first accessible store when no current store is selected.
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "X-STORE")]
pub x_store: Option<String>,
/// Request body sent with this call.
///
/// Required.
#[serde(skip)]
pub body: SdkUpdateInvoiceStatusRequestApplicationJson,
}
impl UpdateStatusParams {
/// Construct a new `UpdateStatusParams` with the required fields set.
#[allow(deprecated)]
pub fn new(body: SdkUpdateInvoiceStatusRequestApplicationJson) -> Self {
Self {
x_store: Default::default(),
body,
}
}
}
#[derive(Debug, Clone, Serialize)]
pub struct CreateRefundParams {
/// Store slug. Required for OAuth access tokens. API keys may omit it to use their current store, or the first accessible store when no current store is selected.
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "X-STORE")]
pub x_store: Option<String>,
/// Request body sent with this call.
///
/// Required.
#[serde(skip)]
pub body: SdkCreateInvoiceRefundRequestApplicationJson,
}
impl CreateRefundParams {
/// Construct a new `CreateRefundParams` with the required fields set.
#[allow(deprecated)]
pub fn new(body: SdkCreateInvoiceRefundRequestApplicationJson) -> Self {
Self {
x_store: Default::default(),
body,
}
}
}
#[derive(Debug, Clone, Serialize)]
pub struct RetryFulfillmentParams {
/// Store slug. Required for OAuth access tokens. API keys may omit it to use their current store, or the first accessible store when no current store is selected.
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "X-STORE")]
pub x_store: Option<String>,
/// Request body sent with this call.
///
/// Required.
#[serde(skip)]
pub body: SdkCreateFulfillmentRetryRequestApplicationJson,
}
impl RetryFulfillmentParams {
/// Construct a new `RetryFulfillmentParams` with the required fields set.
#[allow(deprecated)]
pub fn new(body: SdkCreateFulfillmentRetryRequestApplicationJson) -> Self {
Self {
x_store: Default::default(),
body,
}
}
}
#[derive(Debug, Clone, Serialize)]
pub struct RetryDynamicDeliveryParams {
/// Store slug. Required for OAuth access tokens. API keys may omit it to use their current store, or the first accessible store when no current store is selected.
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "X-STORE")]
pub x_store: Option<String>,
/// Request body sent with this call.
///
/// Required.
#[serde(skip)]
pub body: SdkCreateDynamicDeliveryRetryRequestApplicationJson,
}
impl RetryDynamicDeliveryParams {
/// Construct a new `RetryDynamicDeliveryParams` with the required fields set.
#[allow(deprecated)]
pub fn new(body: SdkCreateDynamicDeliveryRetryRequestApplicationJson) -> Self {
Self {
x_store: Default::default(),
body,
}
}
}
#[derive(Debug, Clone, Serialize)]
pub struct NotifyFulfillmentParams {
/// Store slug. Required for OAuth access tokens. API keys may omit it to use their current store, or the first accessible store when no current store is selected.
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "X-STORE")]
pub x_store: Option<String>,
/// Request body sent with this call.
///
/// Required.
#[serde(skip)]
pub body: SdkCreateFulfillmentNotificationsRequestApplicationJson,
}
impl NotifyFulfillmentParams {
/// Construct a new `NotifyFulfillmentParams` with the required fields set.
#[allow(deprecated)]
pub fn new(body: SdkCreateFulfillmentNotificationsRequestApplicationJson) -> Self {
Self {
x_store: Default::default(),
body,
}
}
}
impl<'a> InvoicesApi<'a> {
/// List all invoices
///
/// List your store's invoices, 15 per page by default. OAuth callers use the admin grant and select a store with X-STORE. Current membership and role permissions apply to every request.
pub async fn list(
&self,
params: ListParams,
) -> Result<SdkListInvoicesResponseValue200ApplicationJson, Error> {
self.list_with_options(params, None).await
}
/// Variant of [`Self::list`] that accepts per-request [`crate::RequestOptions`].
pub async fn list_with_options(
&self,
params: ListParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkListInvoicesResponseValue200ApplicationJson, Error> {
self.list_raw(params, options)
.await
.map(|response| response.data)
}
/// Returns the typed result together with status, headers, and request ID.
pub async fn list_raw(
&self,
params: ListParams,
options: Option<&crate::RequestOptions>,
) -> Result<crate::RawResponse<SdkListInvoicesResponseValue200ApplicationJson>, Error> {
let path = "/v2/invoices".to_string();
let method = http::Method::GET;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("listInvoices".to_string());
let options = Some(&merged);
self.client
.request_with_query_schema_opts_raw(method, &path, ¶ms, options, "GET /v2/invoices")
.await
}
/// Create an invoice
///
/// Create an invoice for one or more product variants. Credit products are direct-only: send a credits variant by itself, use a quantity covered by its credit rate tiers, and respect the variant quantity increment rules. A subscription plan that offers a trial is priced at the trial, nothing for a free trial and the trial price for a paid one, unless the customer already had a trial of that product; then it is priced at the plan price. Two requests racing for the same trial can be refused with a `422` on `invoice`. A cart carries at most one subscription plan and nothing else; a plan mixed with other products or with a second plan returns `422` on `product_variants.{variant_id}`, and a plan's `quantity` other than 1 returns `422` on `quantity`. A customer who already holds the plan, matched by `customer_email`, is refused with `422` on `invoice` while that subscription is active, trialing, past due, or unpaid, whichever payment method bills it. A subscription scheduled to end still blocks while it can be kept, and the message then tells the customer to keep it from the customer portal. One that can no longer be kept, such as a PayPal subscription cancelled at period end, does not block. For an in-house subscription on hold for an unpaid renewal, the message tells the customer to pay and resume it from the customer portal. A `coupon` discounts only the lines of its kind, set by the coupon's `applies_to`. A `subscriptions` coupon discounts the plan's first `subscription_payments` payments when the `payment_method` can carry the discount: Stripe, which carries more than one discounted payment only on a monthly or yearly plan, or a method the store bills in house. On PayPal, Razorpay, or a weekly or daily Stripe plan discounted for more than one payment, the plan sells at its full price and the coupon is left off the order without an error. A coupon for the other kind, a `subscriptions` coupon on a plan that starts with a trial, and a fixed amount that would make the plan free each return `422` on `coupon`. OAuth callers use the admin grant and select a store with X-STORE. Current membership and role permissions apply to every request.
pub async fn create(
&self,
params: CreateParams,
) -> Result<SdkCreateInvoiceResponseValue201ApplicationJson, Error> {
self.create_with_options(params, None).await
}
/// Variant of [`Self::create`] that accepts per-request [`crate::RequestOptions`].
pub async fn create_with_options(
&self,
params: CreateParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkCreateInvoiceResponseValue201ApplicationJson, Error> {
self.create_raw(params, options)
.await
.map(|response| response.data)
}
/// Returns the typed result together with status, headers, and request ID.
pub async fn create_raw(
&self,
params: CreateParams,
options: Option<&crate::RequestOptions>,
) -> Result<crate::RawResponse<SdkCreateInvoiceResponseValue201ApplicationJson>, Error> {
let path = "/v2/invoices".to_string();
let method = http::Method::POST;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("createInvoice".to_string());
let options = Some(&merged);
self.client
.request_with_body_schema_opts_raw(
method,
&path,
¶ms,
Some(¶ms.body),
options,
"POST /v2/invoices",
)
.await
}
/// Search invoices
///
/// Search invoices with the same filters as the list endpoint, sent in a JSON body instead of query parameters. OAuth callers use the admin grant and select a store with X-STORE. Current membership and role permissions apply to every request.
pub async fn search(
&self,
params: SearchParams,
) -> Result<SdkSearchInvoicesResponseValue200ApplicationJson, Error> {
self.search_with_options(params, None).await
}
/// Variant of [`Self::search`] that accepts per-request [`crate::RequestOptions`].
pub async fn search_with_options(
&self,
params: SearchParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkSearchInvoicesResponseValue200ApplicationJson, Error> {
self.search_raw(params, options)
.await
.map(|response| response.data)
}
/// Returns the typed result together with status, headers, and request ID.
pub async fn search_raw(
&self,
params: SearchParams,
options: Option<&crate::RequestOptions>,
) -> Result<crate::RawResponse<SdkSearchInvoicesResponseValue200ApplicationJson>, Error> {
let path = "/v2/invoices/search".to_string();
let method = http::Method::POST;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("searchInvoices".to_string());
let options = Some(&merged);
self.client
.request_with_body_schema_opts_raw(
method,
&path,
¶ms,
Some(¶ms.body),
options,
"POST /v2/invoices/search",
)
.await
}
/// Retrieve an invoice
///
/// Retrieve an invoice by its ID to check its current payment and delivery state. OAuth callers use the admin grant and select a store with X-STORE. Current membership and role permissions apply to every request.
pub async fn get(
&self,
invoice: &str,
params: GetParams,
) -> Result<SdkGetInvoiceResponseValue200ApplicationJson, Error> {
self.get_with_options(invoice, params, None).await
}
/// Variant of [`Self::get`] that accepts per-request [`crate::RequestOptions`].
pub async fn get_with_options(
&self,
invoice: &str,
params: GetParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkGetInvoiceResponseValue200ApplicationJson, Error> {
self.get_raw(invoice, params, options)
.await
.map(|response| response.data)
}
/// Returns the typed result together with status, headers, and request ID.
pub async fn get_raw(
&self,
invoice: &str,
params: GetParams,
options: Option<&crate::RequestOptions>,
) -> Result<crate::RawResponse<SdkGetInvoiceResponseValue200ApplicationJson>, Error> {
let invoice = crate::client::path_segment(invoice);
let path = format!("/v2/invoices/{invoice}");
let method = http::Method::GET;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("getInvoice".to_string());
let options = Some(&merged);
self.client
.request_with_query_schema_opts_raw(
method,
&path,
¶ms,
options,
"GET /v2/invoices/{invoice}",
)
.await
}
/// Create a checkout session
///
/// Create or reuse a payment session for a pending invoice. Create the invoice first, then send the customer to the returned top-level `payment_url`. A new session answers `201`; if the invoice already has one, that session is returned with `200`. An invoice that costs nothing, or that the customer wallet covers in full, is marked as paid and answers `200` without a `payment_url`; delivery may still be queued. A free trial sold through Stripe, PayPal, or Razorpay is the exception: the customer still has to authorise the subscription with that provider, so it answers with a `payment_url` and the invoice stays pending until they do. An unpaid trial invoice stops being payable after 72 hours, or on those three providers once the trial it sold is about to end, and then answers `422` on `invoice.checkout`. Check for a URL before redirecting and verify payment through signed events or a fresh read. OAuth callers use the admin grant and select a store with X-STORE. Current membership and role permissions apply to every request.
pub async fn go_to_checkout(
&self,
invoice: &str,
params: GoToCheckoutParams,
) -> Result<SdkCreateCheckoutSessionResponseValue200ApplicationJson, Error> {
self.go_to_checkout_with_options(invoice, params, None)
.await
}
/// Variant of [`Self::go_to_checkout`] that accepts per-request [`crate::RequestOptions`].
pub async fn go_to_checkout_with_options(
&self,
invoice: &str,
params: GoToCheckoutParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkCreateCheckoutSessionResponseValue200ApplicationJson, Error> {
self.go_to_checkout_raw(invoice, params, options)
.await
.map(|response| response.data)
}
/// Returns the typed result together with status, headers, and request ID.
pub async fn go_to_checkout_raw(
&self,
invoice: &str,
params: GoToCheckoutParams,
options: Option<&crate::RequestOptions>,
) -> Result<crate::RawResponse<SdkCreateCheckoutSessionResponseValue200ApplicationJson>, Error>
{
let invoice = crate::client::path_segment(invoice);
let path = format!("/v2/invoices/{invoice}/checkout");
let method = http::Method::POST;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("createCheckoutSession".to_string());
let options = Some(&merged);
self.client
.request_with_query_schema_opts_raw(
method,
&path,
¶ms,
options,
"POST /v2/invoices/{invoice}/checkout",
)
.await
}
/// View invoice deliverables
///
/// Retrieve the deliverables sent to the customer, including each product in a multi-product purchase. OAuth callers use the admin grant and select a store with X-STORE. Current membership and role permissions apply to every request.
pub async fn get_deliverables(
&self,
invoice: &str,
params: GetDeliverablesParams,
) -> Result<SdkGetInvoiceDeliverablesResponseValue200ApplicationJson, Error> {
self.get_deliverables_with_options(invoice, params, None)
.await
}
/// Variant of [`Self::get_deliverables`] that accepts per-request [`crate::RequestOptions`].
pub async fn get_deliverables_with_options(
&self,
invoice: &str,
params: GetDeliverablesParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkGetInvoiceDeliverablesResponseValue200ApplicationJson, Error> {
self.get_deliverables_raw(invoice, params, options)
.await
.map(|response| response.data)
}
/// Returns the typed result together with status, headers, and request ID.
pub async fn get_deliverables_raw(
&self,
invoice: &str,
params: GetDeliverablesParams,
options: Option<&crate::RequestOptions>,
) -> Result<crate::RawResponse<SdkGetInvoiceDeliverablesResponseValue200ApplicationJson>, Error>
{
let invoice = crate::client::path_segment(invoice);
let path = format!("/v2/invoices/{invoice}/deliverables");
let method = http::Method::GET;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("getInvoiceDeliverables".to_string());
let options = Some(&merged);
self.client
.request_with_query_schema_opts_raw(
method,
&path,
¶ms,
options,
"GET /v2/invoices/{invoice}/deliverables",
)
.await
}
/// Mark pending invoice completed
///
/// Mark a pending invoice completed and start the normal delivery flow. SellApp normally handles completion after payment is confirmed. Use this only after independently confirming payment or deliberately authorizing delivery without it; the action can release purchased products. OAuth callers use the admin grant and select a store with X-STORE. Current membership and role permissions apply to every request.
pub async fn mark_completed(
&self,
invoice: &str,
params: MarkCompletedParams,
) -> Result<SdkMarkPendingInvoiceCompletedResponseValue200ApplicationJson, Error> {
self.mark_completed_with_options(invoice, params, None)
.await
}
/// Variant of [`Self::mark_completed`] that accepts per-request [`crate::RequestOptions`].
pub async fn mark_completed_with_options(
&self,
invoice: &str,
params: MarkCompletedParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkMarkPendingInvoiceCompletedResponseValue200ApplicationJson, Error> {
self.mark_completed_raw(invoice, params, options)
.await
.map(|response| response.data)
}
/// Returns the typed result together with status, headers, and request ID.
pub async fn mark_completed_raw(
&self,
invoice: &str,
params: MarkCompletedParams,
options: Option<&crate::RequestOptions>,
) -> Result<
crate::RawResponse<SdkMarkPendingInvoiceCompletedResponseValue200ApplicationJson>,
Error,
> {
let invoice = crate::client::path_segment(invoice);
let path = format!("/v2/invoices/{invoice}/mark-completed");
let method = http::Method::PATCH;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("markPendingInvoiceCompleted".to_string());
let options = Some(&merged);
self.client
.request_with_body_schema_opts_raw(
method,
&path,
¶ms,
Some(¶ms.body),
options,
"PATCH /v2/invoices/{invoice}/mark-completed",
)
.await
}
/// Mark pending invoice voided
///
/// Void a pending invoice so it does not proceed to product delivery. OAuth callers use the admin grant and select a store with X-STORE. Current membership and role permissions apply to every request.
pub async fn mark_voided(
&self,
invoice: &str,
params: MarkVoidedParams,
) -> Result<SdkMarkPendingInvoiceVoidedResponseValue200ApplicationJson, Error> {
self.mark_voided_with_options(invoice, params, None).await
}
/// Variant of [`Self::mark_voided`] that accepts per-request [`crate::RequestOptions`].
pub async fn mark_voided_with_options(
&self,
invoice: &str,
params: MarkVoidedParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkMarkPendingInvoiceVoidedResponseValue200ApplicationJson, Error> {
self.mark_voided_raw(invoice, params, options)
.await
.map(|response| response.data)
}
/// Returns the typed result together with status, headers, and request ID.
pub async fn mark_voided_raw(
&self,
invoice: &str,
params: MarkVoidedParams,
options: Option<&crate::RequestOptions>,
) -> Result<crate::RawResponse<SdkMarkPendingInvoiceVoidedResponseValue200ApplicationJson>, Error>
{
let invoice = crate::client::path_segment(invoice);
let path = format!("/v2/invoices/{invoice}/mark-voided");
let method = http::Method::PATCH;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("markPendingInvoiceVoided".to_string());
let options = Some(&merged);
self.client
.request_with_body_schema_opts_raw(
method,
&path,
¶ms,
Some(¶ms.body),
options,
"PATCH /v2/invoices/{invoice}/mark-voided",
)
.await
}
/// Issue replacement for completed invoice
///
/// Issue replacement deliverables for a completed purchase. This creates a new invoice and marks it completed, then starts the normal delivery and sales-notification flow. It is not just an edit to the old delivery. OAuth callers use the admin grant and select a store with X-STORE. Current membership and role permissions apply to every request.
pub async fn issue_replacement(
&self,
invoice: &str,
params: IssueReplacementParams,
) -> Result<SdkIssueReplacementForCompletedInvoiceResponseValue200ApplicationJson, Error> {
self.issue_replacement_with_options(invoice, params, None)
.await
}
/// Variant of [`Self::issue_replacement`] that accepts per-request [`crate::RequestOptions`].
pub async fn issue_replacement_with_options(
&self,
invoice: &str,
params: IssueReplacementParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkIssueReplacementForCompletedInvoiceResponseValue200ApplicationJson, Error> {
self.issue_replacement_raw(invoice, params, options)
.await
.map(|response| response.data)
}
/// Returns the typed result together with status, headers, and request ID.
pub async fn issue_replacement_raw(
&self,
invoice: &str,
params: IssueReplacementParams,
options: Option<&crate::RequestOptions>,
) -> Result<
crate::RawResponse<SdkIssueReplacementForCompletedInvoiceResponseValue200ApplicationJson>,
Error,
> {
let invoice = crate::client::path_segment(invoice);
let path = format!("/v2/invoices/{invoice}/issue-replacement");
let method = http::Method::PATCH;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("issueReplacementForCompletedInvoice".to_string());
let options = Some(&merged);
self.client
.request_with_body_schema_opts_raw(
method,
&path,
¶ms,
Some(¶ms.body),
options,
"PATCH /v2/invoices/{invoice}/issue-replacement",
)
.await
}
/// Update invoice status
///
/// Change a purchase through the invoice compatibility operation. Set status to COMPLETED, VOIDED, REVIEW, or DISPUTING. Dispute transitions schedule community-access revocation and a dispute webhook. Requires the `invoice` credential ability and store ownership. OAuth callers use the admin grant and select a store with X-STORE. Current membership and role permissions apply to every request.
pub async fn update_status(
&self,
invoice: &str,
params: UpdateStatusParams,
) -> Result<SdkUpdateInvoiceStatusResponseValue200ApplicationJson, Error> {
self.update_status_with_options(invoice, params, None).await
}
/// Variant of [`Self::update_status`] that accepts per-request [`crate::RequestOptions`].
pub async fn update_status_with_options(
&self,
invoice: &str,
params: UpdateStatusParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkUpdateInvoiceStatusResponseValue200ApplicationJson, Error> {
self.update_status_raw(invoice, params, options)
.await
.map(|response| response.data)
}
/// Returns the typed result together with status, headers, and request ID.
pub async fn update_status_raw(
&self,
invoice: &str,
params: UpdateStatusParams,
options: Option<&crate::RequestOptions>,
) -> Result<crate::RawResponse<SdkUpdateInvoiceStatusResponseValue200ApplicationJson>, Error>
{
let invoice = crate::client::path_segment(invoice);
let path = format!("/v2/invoices/{invoice}/status");
let method = http::Method::PATCH;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("updateInvoiceStatus".to_string());
let options = Some(&merged);
self.client
.request_with_body_schema_opts_raw(
method,
&path,
¶ms,
Some(¶ms.body),
options,
"PATCH /v2/invoices/{invoice}/status",
)
.await
}
/// Create invoice refund
///
/// Request a full or partial provider refund using the same idempotent refund ledger as the dashboard. Amounts are decimal currency strings, never floating-point numbers. Requires the `invoice` token ability. OAuth callers use the admin grant and select a store with X-STORE. Current membership and role permissions apply to every request.
pub async fn create_refund(
&self,
invoice: &str,
params: CreateRefundParams,
) -> Result<SdkCreateInvoiceRefundResponseValue200ApplicationJson, Error> {
self.create_refund_with_options(invoice, params, None).await
}
/// Variant of [`Self::create_refund`] that accepts per-request [`crate::RequestOptions`].
pub async fn create_refund_with_options(
&self,
invoice: &str,
params: CreateRefundParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkCreateInvoiceRefundResponseValue200ApplicationJson, Error> {
self.create_refund_raw(invoice, params, options)
.await
.map(|response| response.data)
}
/// Returns the typed result together with status, headers, and request ID.
pub async fn create_refund_raw(
&self,
invoice: &str,
params: CreateRefundParams,
options: Option<&crate::RequestOptions>,
) -> Result<crate::RawResponse<SdkCreateInvoiceRefundResponseValue200ApplicationJson>, Error>
{
let invoice = crate::client::path_segment(invoice);
let path = format!("/v2/invoices/{invoice}/refunds");
let method = http::Method::POST;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("createInvoiceRefund".to_string());
let options = Some(&merged);
self.client
.request_with_body_schema_opts_raw(
method,
&path,
¶ms,
Some(¶ms.body),
options,
"POST /v2/invoices/{invoice}/refunds",
)
.await
}
/// Create fulfillment retry
///
/// Retry failed delivery steps for a paid or partially fulfilled purchase. Repeated requests retry the same failed steps without creating duplicate work. OAuth callers use the admin grant and select a store with X-STORE. Current membership and role permissions apply to every request.
pub async fn retry_fulfillment(
&self,
invoice: &str,
params: RetryFulfillmentParams,
) -> Result<SdkCreateFulfillmentRetryResponseValue200ApplicationJson, Error> {
self.retry_fulfillment_with_options(invoice, params, None)
.await
}
/// Variant of [`Self::retry_fulfillment`] that accepts per-request [`crate::RequestOptions`].
pub async fn retry_fulfillment_with_options(
&self,
invoice: &str,
params: RetryFulfillmentParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkCreateFulfillmentRetryResponseValue200ApplicationJson, Error> {
self.retry_fulfillment_raw(invoice, params, options)
.await
.map(|response| response.data)
}
/// Returns the typed result together with status, headers, and request ID.
pub async fn retry_fulfillment_raw(
&self,
invoice: &str,
params: RetryFulfillmentParams,
options: Option<&crate::RequestOptions>,
) -> Result<crate::RawResponse<SdkCreateFulfillmentRetryResponseValue200ApplicationJson>, Error>
{
let invoice = crate::client::path_segment(invoice);
let path = format!("/v2/invoices/{invoice}/fulfillment-retries");
let method = http::Method::POST;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("createFulfillmentRetry".to_string());
let options = Some(&merged);
self.client
.request_with_body_schema_opts_raw(
method,
&path,
¶ms,
Some(¶ms.body),
options,
"POST /v2/invoices/{invoice}/fulfillment-retries",
)
.await
}
/// Create dynamic delivery retry
///
/// Retry one same-store dynamic delivered product after validating order, line-item, variant, and webhook ownership. Callers should avoid concurrent retries for the same delivered product. OAuth callers use the admin grant and select a store with X-STORE. Current membership and role permissions apply to every request.
pub async fn retry_dynamic_delivery(
&self,
invoice: &str,
params: RetryDynamicDeliveryParams,
) -> Result<SdkCreateDynamicDeliveryRetryResponseValue200ApplicationJson, Error> {
self.retry_dynamic_delivery_with_options(invoice, params, None)
.await
}
/// Variant of [`Self::retry_dynamic_delivery`] that accepts per-request [`crate::RequestOptions`].
pub async fn retry_dynamic_delivery_with_options(
&self,
invoice: &str,
params: RetryDynamicDeliveryParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkCreateDynamicDeliveryRetryResponseValue200ApplicationJson, Error> {
self.retry_dynamic_delivery_raw(invoice, params, options)
.await
.map(|response| response.data)
}
/// Returns the typed result together with status, headers, and request ID.
pub async fn retry_dynamic_delivery_raw(
&self,
invoice: &str,
params: RetryDynamicDeliveryParams,
options: Option<&crate::RequestOptions>,
) -> Result<
crate::RawResponse<SdkCreateDynamicDeliveryRetryResponseValue200ApplicationJson>,
Error,
> {
let invoice = crate::client::path_segment(invoice);
let path = format!("/v2/invoices/{invoice}/dynamic-delivery-retries");
let method = http::Method::POST;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("createDynamicDeliveryRetry".to_string());
let options = Some(&merged);
self.client
.request_with_body_schema_opts_raw(
method,
&path,
¶ms,
Some(¶ms.body),
options,
"POST /v2/invoices/{invoice}/dynamic-delivery-retries",
)
.await
}
/// Create fulfillment notifications
///
/// Resend fulfillment notifications for all or selected same-store product variants on a completed invoice. OAuth callers use the admin grant and select a store with X-STORE. Current membership and role permissions apply to every request.
pub async fn notify_fulfillment(
&self,
invoice: &str,
params: NotifyFulfillmentParams,
) -> Result<SdkCreateFulfillmentNotificationsResponseValue200ApplicationJson, Error> {
self.notify_fulfillment_with_options(invoice, params, None)
.await
}
/// Variant of [`Self::notify_fulfillment`] that accepts per-request [`crate::RequestOptions`].
pub async fn notify_fulfillment_with_options(
&self,
invoice: &str,
params: NotifyFulfillmentParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkCreateFulfillmentNotificationsResponseValue200ApplicationJson, Error> {
self.notify_fulfillment_raw(invoice, params, options)
.await
.map(|response| response.data)
}
/// Returns the typed result together with status, headers, and request ID.
pub async fn notify_fulfillment_raw(
&self,
invoice: &str,
params: NotifyFulfillmentParams,
options: Option<&crate::RequestOptions>,
) -> Result<
crate::RawResponse<SdkCreateFulfillmentNotificationsResponseValue200ApplicationJson>,
Error,
> {
let invoice = crate::client::path_segment(invoice);
let path = format!("/v2/invoices/{invoice}/fulfillment-notifications");
let method = http::Method::POST;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("createFulfillmentNotifications".to_string());
let options = Some(&merged);
self.client
.request_with_body_schema_opts_raw(
method,
&path,
¶ms,
Some(¶ms.body),
options,
"POST /v2/invoices/{invoice}/fulfillment-notifications",
)
.await
}
}