Recurring Billing
Create Subscriptions
- Java
SubscriptionRequest request = new SubscriptionRequest()
.paymentMethodToken("the_token")
.planId("the_plan_id");
Result<Subscription> result = gateway.subscription().create(request);
Specifying merchant account
If you have multiple merchant accounts, you can pass the merchant account ID to specify which
merchant account to use to process transactions for the subscription. If a merchant account ID is
not passed, we'll use your default merchant account. If you would like to change which merchant
account is default, contact us.
Important
The specified merchant account must be in the same currency as the subscription plan, or any
attempted subscription transactions will trigger a
validation error.
If you want to use a merchant account with a different currency, you must create a new plan with
the indicated currency.
- Java
SubscriptionRequest request = new SubscriptionRequest()
.paymentMethodToken("the_token")
.planId("silver_plan_gbp")
.merchantAccountId("gbp_account");
Result<subscription> result = gateway.subscription().create(request);
Overriding plan details
Certain plan attributes can be
overridden
when you pass the details you want to change along with the
paymentMethodToken and planId. You can
override the following plan details:- Price
- Trial duration and trial duration unit
- Start date
- Number of billing cycles
- Add-on details
- Discount details
Transaction flow
The transaction flow depends on when the subscription is set to start and whether it includes a
trial period. If there is no trial period and the subscription is set to bill immediately:- We'll attempt to charge the customer and submit the transaction for settlement right away
-
If that transaction attempt is successful:
- The subscription will be created
- Its status will be Active
- You'll receive a successful result that includes a subscription object with its associated transaction details
-
If that transaction attempt fails:
- No subscription will be created
- You'll receive an error result with information about why the transaction request failed
- The subscription will be created immediately, but its status will be Pending until the first billing date is reached
- On the first billing date, we'll attempt to charge the customer and submit the transaction for settlement
- If that transaction attempt is successful, the subscription status will change to Active
- If that transaction attempt fails, the subscription status will change to Past Due
- The subscription will be created and its status will be Active immediately
- We'll attempt to charge the customer at the end of the trial period
- If that transaction attempt is successful, the subscription status will remain Active
- If that transaction attempt fails, the subscription status will change to Past Due
Note
Before setting up trial periods, be sure to read the risks and requirements in the
Trial Periods
support article.