pub struct Subscription {
pub plan: Pubkey,
pub subscriber: Pubkey,
pub next_renewal_ts: i64,
pub active: bool,
pub renewals: u32,
pub created_ts: i64,
pub last_amount: u64,
pub last_renewed_ts: i64,
pub trial_ends_at: Option<i64>,
pub in_trial: bool,
pub bump: u8,
}Expand description
Subscription account tracks individual user subscriptions PDA seeds: [“subscription”, plan, subscriber]
Fields§
§plan: PubkeyReference to the plan PDA
subscriber: PubkeyUser’s pubkey (the subscriber)
next_renewal_ts: i64Unix timestamp for next renewal
active: boolWhether subscription is active
renewals: u32Number of renewals processed for this subscription.
This counter increments with each successful renewal payment and is preserved across subscription cancellation and reactivation cycles. When a subscription is canceled and later reactivated, this field retains its historical value rather than resetting to zero.
created_ts: i64Unix timestamp when subscription was created
last_amount: u64Last charged amount for audit purposes
last_renewed_ts: i64Unix timestamp when subscription was last renewed (prevents double-renewal attacks)
trial_ends_at: Option<i64>Unix timestamp when free trial period ends (None if no trial)
When present, indicates the subscription is in or was in a free trial period.
During the trial, no payment is required. After trial_ends_at, the first
renewal will process the initial payment.
in_trial: boolWhether subscription is currently in free trial period
When true, the subscription is active but no payment has been made yet.
The first payment will occur at next_renewal_ts (when trial ends).
bump: u8PDA bump seed
Trait Implementations§
Source§impl BorshDeserialize for Subscription
impl BorshDeserialize for Subscription
fn deserialize_reader<R: Read>(reader: &mut R) -> Result<Self, Error>
Source§fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>
fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>
Source§fn try_from_slice(v: &[u8]) -> Result<Self, Error>
fn try_from_slice(v: &[u8]) -> Result<Self, Error>
fn try_from_reader<R>(reader: &mut R) -> Result<Self, Error>where
R: Read,
Source§impl BorshSerialize for Subscriptionwhere
Pubkey: BorshSerialize,
i64: BorshSerialize,
bool: BorshSerialize,
u32: BorshSerialize,
u64: BorshSerialize,
Option<i64>: BorshSerialize,
u8: BorshSerialize,
impl BorshSerialize for Subscriptionwhere
Pubkey: BorshSerialize,
i64: BorshSerialize,
bool: BorshSerialize,
u32: BorshSerialize,
u64: BorshSerialize,
Option<i64>: BorshSerialize,
u8: BorshSerialize,
Source§impl Clone for Subscription
impl Clone for Subscription
Source§fn clone(&self) -> Subscription
fn clone(&self) -> Subscription
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Subscription
impl Debug for Subscription
Source§impl<'de> Deserialize<'de> for Subscription
impl<'de> Deserialize<'de> for Subscription
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for Subscription
impl PartialEq for Subscription
Source§impl Serialize for Subscription
impl Serialize for Subscription
impl Eq for Subscription
impl StructuralPartialEq for Subscription
Auto Trait Implementations§
impl Freeze for Subscription
impl RefUnwindSafe for Subscription
impl Send for Subscription
impl Sync for Subscription
impl Unpin for Subscription
impl UnwindSafe for Subscription
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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