public class Subscription
extends java.lang.Object
Represents a subscription resource returned from the API.
Subscriptions create payments according to a schedule.
The following rules apply when specifying recurrence:
month
nor day_of_month
are present, the subscription will recur from the start_date
based on the interval_unit
.month
or day_of_month
are present, the recurrence rules will be applied from the start_date
, and the following validations apply:interval_unit | month | day_of_month |
---|---|---|
yearly | optional (required if day_of_month provided) |
optional (required if month |
provided) | ||
monthly | invalid | required |
weekly | invalid | invalid |
Examples:
interval_unit | interval | month | day_of_month | valid? |
---|---|---|---|---|
yearly | 1 | january | -1 | valid |
yearly | 1 | march | invalid - missing day_of_month |
|
monthly | 6 | 12 | valid | |
monthly | 6 | august | 12 | invalid - month must be blank |
weekly | 2 | valid | ||
weekly | 2 | october | 10 | invalid - month and day_of_month |
must be blank |
When a charge date falls on a non-business day, one of two things will happen:
-1
as the day_of_month
, the charge date will be rolled backwards to the previous business day (i.e., the last working day of the month).Modifier and Type | Class and Description |
---|---|
static class |
Subscription.IntervalUnit |
static class |
Subscription.Links |
static class |
Subscription.Month |
static class |
Subscription.Status |
static class |
Subscription.UpcomingPayment |
Modifier and Type | Method and Description |
---|---|
java.lang.Integer |
getAmount()
Amount in pence (GBP), cents (AUD/EUR), öre (SEK), or øre (DKK).
|
java.lang.Integer |
getAppFee()
The amount to be deducted from each payment as an app fee, to be paid to the partner integration which created the subscription, in pence (GBP), cents (AUD/EUR), öre (SEK), or øre (DKK).
|
java.lang.String |
getCreatedAt()
Fixed timestamp, recording when this resource was created.
|
java.lang.String |
getCurrency()
ISO 4217 currency code.
|
java.lang.Integer |
getDayOfMonth()
As per RFC 2445.
|
java.lang.String |
getEndDate()
Date on or after which no further payments should be created.
|
java.lang.String |
getId()
Unique identifier, beginning with “SB”.
|
java.lang.Integer |
getInterval()
Number of
interval_units between customer charge dates. |
Subscription.IntervalUnit |
getIntervalUnit()
The unit of time between customer charge dates.
|
Subscription.Links |
getLinks() |
java.util.Map<java.lang.String,java.lang.String> |
getMetadata()
Key-value store of custom data.
|
Subscription.Month |
getMonth()
Name of the month on which to charge a customer.
|
java.lang.String |
getName()
Optional name for the subscription.
|
java.lang.String |
getPaymentReference()
An optional payment reference.
|
java.lang.String |
getStartDate()
The date on which the first payment should be charged.
|
Subscription.Status |
getStatus()
One of:
pending_customer_approval : the subscription is waiting for customer approval before becoming active customer_approval_denied : the customer did not approve the subscription active : the subscription is currently active and will continue to create payments finished : all of the payments scheduled for creation under this subscription have been created cancelled : the subscription has been cancelled and will no longer create payments |
java.util.List<Subscription.UpcomingPayment> |
getUpcomingPayments()
Up to 10 upcoming payments with the amount, in pence, and charge date for each.
|
public java.lang.Integer getAmount()
Amount in pence (GBP), cents (AUD/EUR), öre (SEK), or øre (DKK).
public java.lang.Integer getAppFee()
The amount to be deducted from each payment as an app fee, to be paid to the partner integration which created the subscription, in pence (GBP), cents (AUD/EUR), öre (SEK), or øre (DKK).
public java.lang.String getCreatedAt()
Fixed timestamp, recording when this resource was created.
public java.lang.String getCurrency()
ISO 4217 currency code. Currently GBP
, EUR
, SEK
, and DKK
are supported.
public java.lang.Integer getDayOfMonth()
As per RFC 2445. The day of the month to charge customers on. 1
-28
or -1
to indicate the last day of the month.
public java.lang.String getEndDate()
Date on or after which no further payments should be created. If this field is blank and count
is not specified, the subscription will continue forever.
Deprecated: This field will be removed in a future API version. Use count
to specify a number of payments instead.
public java.lang.String getId()
Unique identifier, beginning with “SB”.
public java.lang.Integer getInterval()
Number of interval_units
between customer charge dates. Must be greater than or equal to 1
. Must result in at least one charge date per year. Defaults to 1
.
public Subscription.IntervalUnit getIntervalUnit()
The unit of time between customer charge dates. One of weekly
, monthly
or yearly
.
public Subscription.Links getLinks()
public java.util.Map<java.lang.String,java.lang.String> getMetadata()
Key-value store of custom data. Up to 3 keys are permitted, with key names up to 50 characters and values up to 500 characters.
public Subscription.Month getMonth()
Name of the month on which to charge a customer. Must be lowercase.
public java.lang.String getName()
Optional name for the subscription. This will be set as the description on each payment created. Must not exceed 255 characters.
public java.lang.String getPaymentReference()
An optional payment reference. This will be set as the reference on each payment created and will appear on your customer’s bank statement. See the documentation for the create payment endpoint for more details.
Restricted: You need your own Service User Number to specify a payment reference for Bacs payments.
public java.lang.String getStartDate()
The date on which the first payment should be charged. Must be within one year of creation and on or after the mandate’s next_possible_charge_date
. When blank, this will be set as the mandate’s next_possible_charge_date
.
public Subscription.Status getStatus()
One of:
pending_customer_approval
: the subscription is waiting for customer approval before becoming activecustomer_approval_denied
: the customer did not approve the subscriptionactive
: the subscription is currently active and will continue to create paymentsfinished
: all of the payments scheduled for creation under this subscription have been createdcancelled
: the subscription has been cancelled and will no longer create paymentspublic java.util.List<Subscription.UpcomingPayment> getUpcomingPayments()
Up to 10 upcoming payments with the amount, in pence, and charge date for each.