Skip to main content

SubscriptionsClient

Struct SubscriptionsClient 

pub struct SubscriptionsClient<T> { /* private fields */ }
Expand description

Service for creating donation subscriptions

Configuration for subscription levels can be found in ProductConfiguration.

Implementations§

§

impl<T> SubscriptionsClient<T>
where T: GrpcService<Body>, <T as GrpcService<Body>>::Error: Into<Box<dyn Error + Send + Sync>>, <T as GrpcService<Body>>::ResponseBody: Body<Data = Bytes> + Send + 'static, <<T as GrpcService<Body>>::ResponseBody as Body>::Error: Into<Box<dyn Error + Send + Sync>> + Send,

pub fn new(inner: T) -> SubscriptionsClient<T>

pub fn with_origin(inner: T, origin: Uri) -> SubscriptionsClient<T>

pub fn with_interceptor<F>( inner: T, interceptor: F, ) -> SubscriptionsClient<InterceptedService<T, F>>
where F: Interceptor, <T as GrpcService<Body>>::ResponseBody: Default, T: Service<Request<Body>, Response = Response<<T as GrpcService<Body>>::ResponseBody>>, <T as Service<Request<Body>>>::Error: Into<Box<dyn Error + Send + Sync>> + Send + Sync,

pub fn send_compressed( self, encoding: CompressionEncoding, ) -> SubscriptionsClient<T>

Compress requests with the given encoding.

This requires the server to support it otherwise it might respond with an error.

pub fn accept_compressed( self, encoding: CompressionEncoding, ) -> SubscriptionsClient<T>

Enable decompressing responses.

pub fn max_decoding_message_size(self, limit: usize) -> SubscriptionsClient<T>

Limits the maximum size of a decoded message.

Default: 4MB

pub fn max_encoding_message_size(self, limit: usize) -> SubscriptionsClient<T>

Limits the maximum size of an encoded message.

Default: usize::MAX

pub async fn update_subscriber( &mut self, request: impl IntoRequest<UpdateSubscriberRequest>, ) -> Result<Response<UpdateSubscriberResponse>, Status>

Creates a subscriber record if it does not exist, otherwise refreshes its last access time.

Subscribers MUST periodically hit this endpoint to update the access time on the subscription record. Subscribers SHOULD attempt to make an update call approximately every 3 days. Not accessing this endpoint for an extended period of time will result in the subscription being canceled.

pub async fn delete_subscriber( &mut self, request: impl IntoRequest<DeleteSubscriberRequest>, ) -> Result<Response<DeleteSubscriberResponse>, Status>

Cancels any current subscription at the end of the current subscription period.

Note: Apple IAP subscriptions do not support server-side cancellation, so this method should only be called after cancelling a subscription from storekit to keep server data up to date.

pub async fn create_stripe_payment_method( &mut self, request: impl IntoRequest<CreateStripePaymentMethodRequest>, ) -> Result<Response<CreateStripePaymentMethodResponse>, Status>

Returns a Stripe client secret that can be used to set up a new payment method with Stripe.

pub async fn create_pay_pal_payment_method( &mut self, request: impl IntoRequest<CreatePayPalPaymentMethodRequest>, ) -> Result<Response<CreatePayPalPaymentMethodResponse>, Status>

Returns a PayPal billing agreement approval URL and token that can be used to set up PayPal as a payment method.

The presented billing agreement may be localized. Callers should set their language preferences via an “Accept-Language” header on the request: https://datatracker.ietf.org/doc/html/rfc3282#section-3

pub async fn set_default_payment_method( &mut self, request: impl IntoRequest<SetDefaultPaymentMethodRequest>, ) -> Result<Response<SetDefaultPaymentMethodResponse>, Status>

Sets the default payment method for a subscriber.

pub async fn set_subscription_level( &mut self, request: impl IntoRequest<SetSubscriptionLevelRequest>, ) -> Result<Response<SetSubscriptionLevelResponse>, Status>

Sets the subscription level and currency for a subscriber.

pub async fn get_subscription_information( &mut self, request: impl IntoRequest<GetSubscriptionInformationRequest>, ) -> Result<Response<GetSubscriptionInformationResponse>, Status>

Returns information about the current subscription associated with the provided subscriber_id if one exists.

Although it uses Stripe’s values, the status field in the response is generic, with Braintree-specific values mapped to Stripe’s. Since we don’t support trials or unpaid subscriptions, the associated statuses will never be returned by the API.

pub async fn get_receipt_credential( &mut self, request: impl IntoRequest<GetReceiptCredentialRequest>, ) -> Result<Response<GetReceiptCredentialResponse>, Status>

Create a receipt from a valid payment invoice that can be used to obtain an entitlement

This request is repeatable so long as the ReceiptCredentialRequest remains the same. Clients should use the same ReceiptCredentialRequest value until they attempt to redeem the resulting ReceiptCredentialPresentation. After this point, the ReceiptCredentialRequest MUST NOT be reused or you may not be able to redeem a valid payment invoice. Clients SHOULD retry requests at this endpoint with the same ReceiptCredentialRequest value until receiving a response. After receiving a response, clients should then compute the ReceiptCredentialPresentation and redeem it at the receipt redemption endpoint. Once the first attempt is made there, the same ReceiptCredentialRequest MUST NOT be used again to request a receipt credential.

Note that you may in fact redeem TWO or more invoices for the same ReceiptCredentialRequest while retrying this operation if a later invoice gets paid while you are retrying. However, the returned receipt is always for the latest invoice, so it will have the latest expiration possible and no entitlement time will be lost. The important thing is not to reuse ReceiptCredentialRequest after you have started attempting to redeem the associated ReceiptCredentialPresentation. Then you may produce a ReceiptCredentialPresentation for a later invoice that cannot be redeemed.

Clients MUST validate that the generated receipt credential’s level and expiration matches their expectations.

pub async fn set_iap_subscription( &mut self, request: impl IntoRequest<SetIapSubscriptionRequest>, ) -> Result<Response<SetIapSubscriptionResponse>, Status>

Set a token that represents an IAP subscription made with App Store/Google Play Billing.

To set up an App Store subscription:

  1. Create a subscriber with UpdateSubscriber (you must regularly refresh this subscriber)
  2. Create a subscription with the App Store directly via StoreKit and obtain a originalTransactionId.
  3. Call this RPC with the originalTransactionId
  4. Obtain a receipt via GetReceiptCredential which can then be used to obtain the entitlement

Play Billing: Set a purchaseToken that represents an IAP subscription made with Google Play Billing.

To set up a subscription with Google Play Billing:

  1. Create a subscriber with UpdateSubscriber (you must regularly refresh this subscriber)
  2. Create a subscription with Google Play Billing directly and obtain a purchaseToken. Do not acknowledge the purchaseToken.
  3. Call this RPC with the purchaseToken
  4. Obtain a receipt via GetReceiptCredential which can then be used to obtain the entitlement

After calling this method, the payment is confirmed. Callers must durably store their subscriber_id before calling this method to ensure their payment is tracked.

Once a purchaseToken to is posted to a subscriber_id, the same subscriber_id must not be used with another payment method. A different playbilling purchaseToken can be posted to the same subscriber_id, in this case the subscription associated with the old purchaseToken will be cancelled.

pub async fn get_bank_mandate( &mut self, request: impl IntoRequest<GetBankMandateRequest>, ) -> Result<Response<GetBankMandateResponse>, Status>

Returns a localized bank mandate for the specified bank transfer type.

Callers should set their language preferences via an “Accept-Language” header on the request: https://datatracker.ietf.org/doc/html/rfc3282#section-3

Trait Implementations§

§

impl<T> Clone for SubscriptionsClient<T>
where T: Clone,

§

fn clone(&self) -> SubscriptionsClient<T>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl<T> Debug for SubscriptionsClient<T>
where T: Debug,

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> !Freeze for SubscriptionsClient<T>

§

impl<T> RefUnwindSafe for SubscriptionsClient<T>
where T: RefUnwindSafe,

§

impl<T> Send for SubscriptionsClient<T>
where T: Send,

§

impl<T> Sync for SubscriptionsClient<T>
where T: Sync,

§

impl<T> Unpin for SubscriptionsClient<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for SubscriptionsClient<T>
where T: UnsafeUnpin,

§

impl<T> UnwindSafe for SubscriptionsClient<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> IntoRequest<T> for T

§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
§

impl<L> LayerExt<L> for L

§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in [Layered].
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more