Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
121 changes: 60 additions & 61 deletions billing.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ type Feature struct {
AvatarURL string `json:"avatar_url"`
}

// BillingMoney represents money amounts with formatting.
type BillingMoney struct {
// BillingFee represents money amounts with formatting.
type BillingFee struct {
APIResource

Amount int64 `json:"amount"`
Expand All @@ -32,32 +32,31 @@ type BillingProduct struct {
Currency string `json:"currency"`
Name string `json:"name"`
IsDefault bool `json:"is_default"`
Plans []Plan `json:"plans"`
Plans []Plan `json:"plans,omitempty"`
}

// Plan represents a billing plan.
type Plan struct {
APIResource

Object string `json:"object"`
ID string `json:"id"`
Name string `json:"name"`
Fee *BillingMoney `json:"fee"`
AnnualMonthlyFee *BillingMoney `json:"annual_monthly_fee"`
AnnualFee *BillingMoney `json:"annual_fee"`
Description string `json:"description"`
ProductID string `json:"product_id"`
Product *BillingProduct `json:"product"`
IsDefault bool `json:"is_default"`
IsRecurring bool `json:"is_recurring"`
PubliclyVisible bool `json:"publicly_visible"`
HasBaseFee bool `json:"has_base_fee"`
ForPayerType string `json:"for_payer_type"`
Slug string `json:"slug"`
AvatarURL string `json:"avatar_url"`
Features []Feature `json:"features"`
FreeTrialEnabled bool `json:"free_trial_enabled"`
FreeTrialDays *int `json:"free_trial_days"`
Object string `json:"object"`
ID string `json:"id"`
Name string `json:"name"`
Fee *BillingFee `json:"fee"`
AnnualMonthlyFee *BillingFee `json:"annual_monthly_fee"`
AnnualFee *BillingFee `json:"annual_fee"`
Description *string `json:"description"`
ProductID string `json:"product_id"`
IsDefault bool `json:"is_default"`
IsRecurring bool `json:"is_recurring"`
PubliclyVisible bool `json:"publicly_visible"`
HasBaseFee bool `json:"has_base_fee"`
ForPayerType string `json:"for_payer_type"`
Slug string `json:"slug"`
AvatarURL *string `json:"avatar_url"`
Features []Feature `json:"features,omitempty"`
FreeTrialEnabled bool `json:"free_trial_enabled"`
FreeTrialDays *int `json:"free_trial_days"`
}

// PlanList contains a list of plans.
Expand All @@ -75,28 +74,28 @@ type BillingPaymentMethod struct {
Object string `json:"object"`
ID string `json:"id"`
PayerID string `json:"payer_id"`
PaymentMethod string `json:"payment_method"`
PaymentType string `json:"payment_type"`
IsDefault *bool `json:"is_default"`
Gateway string `json:"gateway"`
GatewayExternalID string `json:"gateway_external_id"`
GatewayExternalAccountID *string `json:"gateway_external_account_id"`
Last4 string `json:"last4"`
Status string `json:"status"`
WalletType string `json:"wallet_type"`
CardType string `json:"card_type"`
ExpiryYear int `json:"expiry_year"`
ExpiryMonth int `json:"expiry_month"`
CreatedAt int64 `json:"created_at"`
UpdatedAt int64 `json:"updated_at"`
IsRemovable *bool `json:"is_removable"`
WalletType *string `json:"wallet_type,omitempty"`
CardType *string `json:"card_type"`
ExpiryYear *int `json:"expiry_year,omitempty"`
ExpiryMonth *int `json:"expiry_month,omitempty"`
CreatedAt int64 `json:"created_at,omitempty"`
UpdatedAt int64 `json:"updated_at,omitempty"`
IsRemovable bool `json:"is_removable"`
}

// BillingSubscriptionItemNextPayment represents next payment info.
type BillingSubscriptionItemNextPayment struct {
APIResource

Amount *BillingMoney `json:"amount"`
Date *int64 `json:"date"`
Amount BillingFee `json:"amount"`
Date int64 `json:"date"`
}

// Payer represents a billing payer (user or organization).
Expand All @@ -109,48 +108,48 @@ type Payer struct {

// User payer only
UserID *string `json:"user_id"`
FirstName *string `json:"first_name"`
LastName *string `json:"last_name"`
Email *string `json:"email"`
FirstName *string `json:"first_name,omitempty"`
LastName *string `json:"last_name,omitempty"`
Email *string `json:"email,omitempty"`

// Org payer only
OrganizationID *string `json:"organization_id"`
OrganizationName *string `json:"organization_name"`

// Used for both org and user payers
ImageURL string `json:"image_url"`
ImageURL string `json:"image_url,omitempty"`

CreatedAt int64 `json:"created_at"`
UpdatedAt int64 `json:"updated_at"`
CreatedAt int64 `json:"created_at,omitempty"`
UpdatedAt int64 `json:"updated_at,omitempty"`
}

// SubscriptionItem represents a billing subscription item.
type SubscriptionItem struct {
APIResource

Object string `json:"object"`
ID string `json:"id"`
InstanceID string `json:"instance_id"`
Status string `json:"status"`
PlanID *string `json:"plan_id"`
Plan *Plan `json:"plan"`
PlanPeriod string `json:"plan_period"`
PaymentMethodID string `json:"payment_method_id"`
PaymentMethod *BillingPaymentMethod `json:"payment_method"`
LifetimePaid *BillingMoney `json:"lifetime_paid"`
Amount *BillingMoney `json:"amount"`
NextPayment *BillingSubscriptionItemNextPayment `json:"next_payment"`
PayerID string `json:"payer_id"`
Payer *Payer `json:"payer"`
IsFreeTrial bool `json:"is_free_trial"`
PeriodStart int64 `json:"period_start"`
PeriodEnd *int64 `json:"period_end"`
ProrationDate string `json:"proration_date"`
CanceledAt *int64 `json:"canceled_at"`
PastDueAt *int64 `json:"past_due_at"`
EndedAt *int64 `json:"ended_at"`
CreatedAt int64 `json:"created_at"`
UpdatedAt int64 `json:"updated_at"`
Object string `json:"object"`
ID string `json:"id"`
InstanceID string `json:"instance_id"`
Status string `json:"status"`
PlanID *string `json:"plan_id"`
Plan *Plan `json:"plan,omitempty"`
PlanPeriod string `json:"plan_period"`
PaymentMethodID string `json:"payment_method_id"`
PaymentMethod *BillingPaymentMethod `json:"payment_method,omitempty"`
LifetimePaid BillingFee `json:"lifetime_paid,omitempty"`
Amount BillingFee `json:"amount,omitempty"`
NextPayment BillingSubscriptionItemNextPayment `json:"next_payment,omitempty"`
PayerID string `json:"payer_id"`
Payer Payer `json:"payer,omitempty"`
IsFreeTrial bool `json:"is_free_trial"`
PeriodStart int64 `json:"period_start"`
PeriodEnd *int64 `json:"period_end"`
ProrationDate string `json:"proration_date,omitempty"`
CanceledAt *int64 `json:"canceled_at"`
PastDueAt *int64 `json:"past_due_at"`
EndedAt *int64 `json:"ended_at"`
CreatedAt int64 `json:"created_at"`
UpdatedAt int64 `json:"updated_at"`
}

// SubscriptionItemList contains a list of subscription items.
Expand Down
Loading
Loading