pub struct Subscriptions { /* private fields */ }Expand description
Subscriptions — the core object. Access via Nombaone::subscriptions.
use nombaone::SubscriptionCreateParams;
let subscription = nombaone
.subscriptions()
.create(SubscriptionCreateParams {
customer_id: "nbo000000000001cus".into(),
price_id: "nbo000000000001prc".into(),
payment_method_id: Some("nbo000000000001pmt".into()),
..Default::default()
})
.await?;
println!("{}", subscription.status); // "active"Implementations§
Source§impl Subscriptions
impl Subscriptions
Sourcepub fn schedule(&self) -> SubscriptionSchedules
pub fn schedule(&self) -> SubscriptionSchedules
Scheduled (next-cycle) changes.
Sourcepub fn dunning(&self) -> SubscriptionDunning
pub fn dunning(&self) -> SubscriptionDunning
Recovery/dunning state (read-only).
Sourcepub fn create(&self, params: SubscriptionCreateParams) -> ApiCall<Subscription>
pub fn create(&self, params: SubscriptionCreateParams) -> ApiCall<Subscription>
Create a subscription. This can move money (the first charge), so the SDK
sends an Idempotency-Key automatically and reuses it across retries.
§Errors
422 CLIENT_VALIDATION_FAILED— e.g. a missing payment method without a trial.409 SUBSCRIPTION_PAYMENT_METHOD_REQUIRED
Sourcepub fn retrieve(&self, id: &str) -> ApiCall<Subscription>
pub fn retrieve(&self, id: &str) -> ApiCall<Subscription>
Sourcepub fn update(
&self,
id: &str,
params: SubscriptionUpdateParams,
) -> ApiCall<Subscription>
pub fn update( &self, id: &str, params: SubscriptionUpdateParams, ) -> ApiCall<Subscription>
Edit metadata or the default payment method. For price/quantity/interval
changes use change — those prorate.
Sourcepub fn list(&self, params: SubscriptionListParams) -> Paginator<Subscription>
pub fn list(&self, params: SubscriptionListParams) -> Paginator<Subscription>
List subscriptions, newest first.
Sourcepub fn list_events(
&self,
id: &str,
params: ListPageParams,
) -> Paginator<DomainEvent>
pub fn list_events( &self, id: &str, params: ListPageParams, ) -> Paginator<DomainEvent>
The subscription’s audit trail of domain events, newest first.
Sourcepub fn pause(
&self,
id: &str,
params: SubscriptionPauseParams,
) -> ApiCall<Subscription>
pub fn pause( &self, id: &str, params: SubscriptionPauseParams, ) -> ApiCall<Subscription>
Pause billing. The subscription keeps its place in the cycle and resumes cleanly.
§Errors
409 SUBSCRIPTION_ILLEGAL_TRANSITION
Sourcepub fn resume(&self, id: &str) -> ApiCall<Subscription>
pub fn resume(&self, id: &str) -> ApiCall<Subscription>
Resume a paused subscription.
Sourcepub fn cancel(
&self,
id: &str,
params: SubscriptionCancelParams,
) -> ApiCall<Subscription>
pub fn cancel( &self, id: &str, params: SubscriptionCancelParams, ) -> ApiCall<Subscription>
Cancel a subscription — immediately (default) or at period end.
nombaone
.subscriptions()
.cancel("nbo000000000001sub", SubscriptionCancelParams {
mode: Some(CancelMode::AtPeriodEnd),
..Default::default()
})
.await?;Sourcepub fn resubscribe(
&self,
id: &str,
params: SubscriptionResubscribeParams,
) -> ApiCall<Subscription>
pub fn resubscribe( &self, id: &str, params: SubscriptionResubscribeParams, ) -> ApiCall<Subscription>
Start a fresh subscription for a canceled one’s customer, reusing the old price/payment method unless overridden. The subscription must be terminal.
§Errors
409 SUBSCRIPTION_NOT_TERMINAL
Sourcepub fn change(
&self,
id: &str,
params: SubscriptionChangeParams,
) -> ApiCall<Subscription>
pub fn change( &self, id: &str, params: SubscriptionChangeParams, ) -> ApiCall<Subscription>
Change price or quantity mid-cycle, prorating by default. Switching the
billing interval mid-cycle is unsupported
(PRORATION_INTERVAL_SWITCH_UNSUPPORTED) — queue it with
schedule().create() instead.
Sourcepub fn update_payment_method(
&self,
id: &str,
params: SubscriptionUpdatePaymentMethodParams,
) -> ApiCall<PaymentMethod>
pub fn update_payment_method( &self, id: &str, params: SubscriptionUpdatePaymentMethodParams, ) -> ApiCall<PaymentMethod>
Swap the payment method that bills this subscription — the card-update
path during dunning. Exactly one of payment_method_reference or
checkout_token.
Returns the attached PaymentMethod (not the subscription): this
endpoint swaps the card and hands back the new payment method.
Sourcepub fn retrieve_upcoming_invoice(&self, id: &str) -> ApiCall<UpcomingInvoice>
pub fn retrieve_upcoming_invoice(&self, id: &str) -> ApiCall<UpcomingInvoice>
Preview the next invoice without charging or storing anything.
Sourcepub fn apply_discount(
&self,
id: &str,
params: SubscriptionApplyDiscountParams,
) -> ApiCall<Discount>
pub fn apply_discount( &self, id: &str, params: SubscriptionApplyDiscountParams, ) -> ApiCall<Discount>
Apply a coupon to this subscription only.
Sourcepub fn remove_discount(&self, id: &str) -> ApiCall<Discount>
pub fn remove_discount(&self, id: &str) -> ApiCall<Discount>
Remove the subscription’s active discount. Returns the ended discount.