SubscriptionGatewayInterface
- Type
- Interface
- Namespace
- craft\commerce\base
- Extends
- craft\base\SavableComponentInterface (opens new window)
- 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 (opens new window)
# Public Methods
Method | Description |
---|---|
afterDelete() (opens new window) | Performs actions after a component is deleted. |
afterSave() (opens new window) | Performs actions after a component is saved. |
beforeApplyDelete() (opens new window) | Performs actions before a component delete is applied to the database. |
beforeDelete() (opens new window) | Performs actions before a component is deleted. |
beforeSave() (opens new window) | Performs actions before a component is saved. |
cancelSubscription() | Cancels a subscription. |
displayName() (opens new window) | Returns the display name of this class. |
getBillingIssueDescription() | Return a description of the billing issue (if any) with this subscription. |
getBillingIssueResolveFormHtml() | Return the form HTML for resolving the billing issue (if any) with this subscription. |
getHasBillingIssues() | Returns whether this subscription has billing issues. |
getIsNew() (opens new window) | Returns whether the component is new (unsaved). |
getNextPaymentAmount() | Returns the next payment amount for a subscription, taking into account all discounts. |
getSettings() (opens new window) | Returns an array of the component’s settings. |
getSettingsHtml() (opens new window) | 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() (opens new window) | Returns whether the component should be selectable in component Type selects. |
reactivateSubscription() | Reactivates a subscription. |
refreshPaymentHistory() | Refresh the subscription payment history for a given subscription. |
settingsAttributes() (opens new window) | 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. |
# cancelSubscription()
Cancels a subscription.
View source (opens new window)
Arguments
$subscription
(craft\commerce\elements\Subscription) – The subscription to cancel$parameters
(craft\commerce\models\subscriptions\CancelSubscriptionForm) – Additional parameters to use
Returns
craft\commerce\base\SubscriptionResponseInterface
Throws
- craft\commerce\errors\SubscriptionException
for all subscription-related errors.
# getBillingIssueDescription()
Return a description of the billing issue (if any) with this subscription.
View source (opens new window)
Arguments
$subscription
(craft\commerce\elements\Subscription)
Returns
# getBillingIssueResolveFormHtml()
Return the form HTML for resolving the billing issue (if any) with this subscription.
View source (opens new window)
Arguments
$subscription
(craft\commerce\elements\Subscription)
Returns
# getHasBillingIssues()
Returns whether this subscription has billing issues.
View source (opens new window)
Arguments
$subscription
(craft\commerce\elements\Subscription)
Returns
# getNextPaymentAmount()
Returns the next payment amount for a subscription, taking into account all discounts.
View source (opens new window)
Arguments
$subscription
(craft\commerce\elements\Subscription)
Returns
string (opens new window) – Next payment amount with currency code
# getSubscriptionPayments()
Returns a list of subscription payments for a given subscription.
View source (opens new window)
Arguments
$subscription
(craft\commerce\elements\Subscription)
Returns
craft\commerce\models\subscriptions\SubscriptionPayment[]
# getSubscriptionPlanByReference()
Returns a subscription plan by its reference
View source (opens new window)
Arguments
$reference
(string (opens new window))
Returns
# getSubscriptionPlans()
Returns all subscription plans as array containing hashes with reference
and name
as keys.
View source (opens new window)
Returns
# reactivateSubscription()
Reactivates a subscription.
View source (opens new window)
Arguments
$subscription
(craft\commerce\elements\Subscription) – The canceled subscription to reactivate
Returns
craft\commerce\base\SubscriptionResponseInterface
Throws
# refreshPaymentHistory()
Refresh the subscription payment history for a given subscription.
View source (opens new window)
Arguments
$subscription
(craft\commerce\elements\Subscription)
# subscribe()
Subscribe user to a plan.
View source (opens new window)
Arguments
$user
(craft\elements\User (opens new window)) – The Craft user to subscribe$plan
(craft\commerce\base\Plan) – The plan to subscribe to$parameters
(craft\commerce\models\subscriptions\SubscriptionForm) – Additional parameters to use
Returns
craft\commerce\base\SubscriptionResponseInterface
Throws
- craft\commerce\errors\SubscriptionException
for all subscription-related errors.
# supportsPlanSwitch()
Returns whether this gateway supports switching plans.
View source (opens new window)
Returns
# supportsReactivation()
Returns whether this gateway supports reactivating subscriptions.
View source (opens new window)
Returns
# switchSubscriptionPlan()
Switch a subscription to a different subscription plan.
View source (opens new window)
Arguments
$subscription
(craft\commerce\elements\Subscription) – The subscription to modify$plan
(craft\commerce\base\Plan) – The plan to change the subscription to$parameters
(craft\commerce\models\subscriptions\SwitchPlansForm) – Additional parameters to use