SubscriptionGatewayInterface

Type
Interface
Namespace
craft\commerce\base
Extends
craft\base\SavableComponentInterface
Implemented by
craft\commerce\base\SubscriptionGateway, craft\commerce\gateways\Dummy
Since
2.0

SubscriptionGatewayInterface defines the common interface to be implemented by gateway classes that support subscriptions.

View source

Public Methods

MethodDescription
afterDelete()Performs actions after a component is deleted.
afterSave()Performs actions after a component is saved.
beforeDelete()Performs actions before a component is deleted.
beforeSave()Performs actions before a component is saved.
cancelSubscription()Cancels a subscription.
displayName()Returns the display name of this class.
getIsNew()Returns whether the component is new (unsaved).
getNextPaymentAmount()Returns the next payment amount for a subscription, taking into account all discounts.
getSettings()Returns an array of the component’s settings.
getSettingsHtml()Returns the component’s settings HTML.
getSubscriptionPayments()Returns a list of subscription payments for a given subscription.
getSubscriptionPlanByReference()Returns a subscription plan by its reference
getSubscriptionPlans()Returns all subscription plans as array containing hashes with reference and name as keys.
isSelectable()Returns whether the component should be selectable in component Type selects.
reactivateSubscription()Reactivates a subscription.
settingsAttributes()Returns the list of settings attribute names.
subscribe()Subscribe user to a plan.
supportsPlanSwitch()Returns whether this gateway supports switching plans.
supportsReactivation()Returns whether this gateway supports reactivating subscriptions.
switchSubscriptionPlan()Switch a subscription to a different subscription plan.
validate()Validates the component.

cancelSubscription()

Cancels a subscription.

View source

Arguments

Returns

craft\commerce\base\SubscriptionResponseInterface

Throws

Signature

public abstract craft\commerce\base\SubscriptionResponseInterface cancelSubscription ( \craft\commerce\elements\Subscription $subscription, craft\commerce\models\subscriptions\CancelSubscriptionForm $parameters )

getNextPaymentAmount()

Returns the next payment amount for a subscription, taking into account all discounts.

View source

Arguments

  • $subscription (\craft\commerce\elements\Subscription)

Returns

string – Next payment amount with currency code

Signature

public abstract string getNextPaymentAmount ( \craft\commerce\elements\Subscription $subscription )

getSubscriptionPayments()

Returns a list of subscription payments for a given subscription.

View source

Arguments

  • $subscription (\craft\commerce\elements\Subscription)

Returns

craft\commerce\models\subscriptions\SubscriptionPayment[]

Signature

public abstract craft\commerce\models\subscriptions\SubscriptionPayment[] getSubscriptionPayments ( \craft\commerce\elements\Subscription $subscription )

getSubscriptionPlanByReference()

Returns a subscription plan by its reference

View source

Arguments

Returns

string

Signature

public abstract string getSubscriptionPlanByReference ( \craft\commerce\base\string $reference )

getSubscriptionPlans()

Returns all subscription plans as array containing hashes with reference and name as keys.

View source

Returns

array

Signature

public abstract array getSubscriptionPlans ( )

reactivateSubscription()

Reactivates a subscription.

View source

Arguments

  • $subscription (\craft\commerce\elements\Subscription) – The canceled subscription to reactivate

Returns

craft\commerce\base\SubscriptionResponseInterface

Throws

Signature

public abstract craft\commerce\base\SubscriptionResponseInterface reactivateSubscription ( \craft\commerce\elements\Subscription $subscription )

subscribe()

Subscribe user to a plan.

View source

Arguments

Returns

craft\commerce\base\SubscriptionResponseInterface

Throws

Signature

public abstract craft\commerce\base\SubscriptionResponseInterface subscribe ( craft\elements\User $user, craft\commerce\base\Plan $plan, craft\commerce\models\subscriptions\SubscriptionForm $parameters )

supportsPlanSwitch()

Returns whether this gateway supports switching plans.

View source

Returns

boolean

Signature

public abstract boolean supportsPlanSwitch ( )

supportsReactivation()

Returns whether this gateway supports reactivating subscriptions.

View source

Returns

boolean

Signature

public abstract boolean supportsReactivation ( )

switchSubscriptionPlan()

Switch a subscription to a different subscription plan.

View source

Arguments

Returns

craft\commerce\base\SubscriptionResponseInterface

Signature

public abstract craft\commerce\base\SubscriptionResponseInterface switchSubscriptionPlan ( \craft\commerce\elements\Subscription $subscription, craft\commerce\base\Plan $plan, craft\commerce\models\subscriptions\SwitchPlansForm $parameters )