public class SubscriptionService
extends java.lang.Object
Service class for working with subscription resources.
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 |
SubscriptionService.SubscriptionCancelRequest
Request class for
cancel(java.lang.String) . |
static class |
SubscriptionService.SubscriptionCreateRequest
Request class for
create() . |
static class |
SubscriptionService.SubscriptionGetRequest
Request class for
get(java.lang.String) . |
static class |
SubscriptionService.SubscriptionListRequest<S>
Request class for
list() . |
static class |
SubscriptionService.SubscriptionUpdateRequest
Request class for
update(java.lang.String) . |
Constructor and Description |
---|
SubscriptionService(HttpClient httpClient)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
SubscriptionService.SubscriptionListRequest<java.lang.Iterable<Subscription>> |
all() |
SubscriptionService.SubscriptionCancelRequest |
cancel(java.lang.String identity)
Immediately cancels a subscription; no more payments will be created under it.
|
SubscriptionService.SubscriptionCreateRequest |
create()
Creates a new subscription object
|
SubscriptionService.SubscriptionGetRequest |
get(java.lang.String identity)
Retrieves the details of a single subscription.
|
SubscriptionService.SubscriptionListRequest<ListResponse<Subscription>> |
list()
Returns a cursor-paginated list of your subscriptions.
|
SubscriptionService.SubscriptionUpdateRequest |
update(java.lang.String identity)
Updates a subscription object.
|
public SubscriptionService(HttpClient httpClient)
Constructor. Users of this library should have no need to call this - an instance of this class can be obtained by calling GoCardlessClient.subscriptions()
.
public SubscriptionService.SubscriptionCreateRequest create()
Creates a new subscription object
public SubscriptionService.SubscriptionListRequest<ListResponse<Subscription>> list()
Returns a cursor-paginated list of your subscriptions.
public SubscriptionService.SubscriptionListRequest<java.lang.Iterable<Subscription>> all()
public SubscriptionService.SubscriptionGetRequest get(java.lang.String identity)
Retrieves the details of a single subscription.
public SubscriptionService.SubscriptionUpdateRequest update(java.lang.String identity)
Updates a subscription object.
This fails with:
validation_failed
if invalid data is provided when attempting to update a subscription.
subscription_not_active
if the subscription is no longer active.
subscription_already_ended
if the subscription has taken all payments.
mandate_payments_require_approval
if the amount is being changed and the mandate requires approval.
number_of_subscription_amendments_exceeded
error if the subscription amount has already been changed 10 times.
forbidden
if the amount is being changed, and the subscription was created by an app and you are not authenticated as that app, or if the subscription was not created by an app and you are authenticated as an app
resource_created_by_another_app
if the app fee is being changed, and the subscription was created by an app other than the app you are authenticated as
public SubscriptionService.SubscriptionCancelRequest cancel(java.lang.String identity)
Immediately cancels a subscription; no more payments will be created under it. Any metadata supplied to this endpoint will be stored on the payment cancellation event it causes.
This will fail with a cancellation_failed error if the subscription is already cancelled or finished.