Subscriptions

June 5, 2026 ยท View on GitHub

Use the /subscriptions resource to create, update, retrieve, and cancel subscriptions and their associated plans.

SubscriptionsController subscriptionsController = client.getSubscriptionsController();

Class Name

SubscriptionsController

Methods

Create Billing Plan

Creates a plan that defines pricing and billing cycle details for subscriptions.

CompletableFuture<ApiResponse<BillingPlan>> createBillingPlanAsync(
    final CreateBillingPlanInput input)

Authentication

This endpoint requires Oauth2

Parameters

ParameterTypeTagsDescription
inputCreateBillingPlanInputRequiredInput structure for the method CreateBillingPlanAsync

Response Type

200: A successful request returns the HTTP 200 OK status code and a JSON response body that shows billing plan details.

This method returns an ApiResponse instance. The getResult() getter of this instance returns the response data which is of type BillingPlan.

Example Usage

CreateBillingPlanInput createBillingPlanInput = new CreateBillingPlanInput.Builder(
    null
)
.prefer("return=minimal")
.body(new PlanRequest.Builder(
        "product_id2",
        "name6",
        Arrays.asList(
            new SubscriptionBillingCycle.Builder(
                new Frequency.Builder(
                    IntervalUnit.DAY
                )
                .intervalCount(1)
                .build(),
                TenureType.REGULAR,
                8
            )
            .totalCycles(1)
            .build()
        ),
        new PaymentPreferences.Builder()
            .autoBillOutstanding(true)
            .setupFeeFailureAction(SetupFeeFailureAction.CANCEL)
            .paymentFailureThreshold(0)
            .build()
    )
    .status(PlanRequestStatus.ACTIVE)
    .quantitySupported(false)
    .build())
.build();

subscriptionsController.createBillingPlanAsync(createBillingPlanInput).thenAccept(result -> {
    // TODO success callback handler
    System.out.println(result);
}).exceptionally(exception -> {
    Throwable cause = exception.getCause();

    if (cause instanceof SubscriptionErrorException) {
        SubscriptionErrorException subscriptionErrorException = (SubscriptionErrorException) cause;
        subscriptionErrorException.printStackTrace();
    } else {
        // fallback for unexpected errors
        exception.printStackTrace();
    }

    return null;
});

Errors

HTTP Status CodeError DescriptionException Class
400Bad Request. Request is not well-formed, syntactically incorrect, or violates schema.SubscriptionErrorException
401Authentication failed due to missing authorization header, or invalid authentication credentials.SubscriptionErrorException
403Authorization failed due to insufficient permissions.SubscriptionErrorException
422The requested action could not be performed, semantically incorrect, or failed business validation.SubscriptionErrorException
500An internal server error has occurred.SubscriptionErrorException
DefaultThe error response.SubscriptionErrorException

List Billing Plans

Lists billing plans.

CompletableFuture<ApiResponse<PlanCollection>> listBillingPlansAsync(
    final ListBillingPlansInput input)

Authentication

This endpoint requires Oauth2

Parameters

ParameterTypeTagsDescription
inputListBillingPlansInputRequiredInput structure for the method ListBillingPlansAsync

Response Type

200: A successful request returns the HTTP 200 OK status code and a JSON response body that lists billing plans.

This method returns an ApiResponse instance. The getResult() getter of this instance returns the response data which is of type PlanCollection.

Example Usage

ListBillingPlansInput listBillingPlansInput = new ListBillingPlansInput.Builder()
    .prefer("return=minimal")
    .pageSize(10)
    .page(1)
    .totalRequired(false)
    .build();

subscriptionsController.listBillingPlansAsync(listBillingPlansInput).thenAccept(result -> {
    // TODO success callback handler
    System.out.println(result);
}).exceptionally(exception -> {
    Throwable cause = exception.getCause();

    if (cause instanceof SubscriptionErrorException) {
        SubscriptionErrorException subscriptionErrorException = (SubscriptionErrorException) cause;
        subscriptionErrorException.printStackTrace();
    } else {
        // fallback for unexpected errors
        exception.printStackTrace();
    }

    return null;
});

Errors

HTTP Status CodeError DescriptionException Class
400Request is not well-formed, syntactically incorrect, or violates schema.SubscriptionErrorException
401Authentication failed due to missing authorization header, or invalid authentication credentials.SubscriptionErrorException
403Authorization failed due to insufficient permissions.SubscriptionErrorException
404The specified resource does not exist.SubscriptionErrorException
500An internal server error has occurred.SubscriptionErrorException
DefaultThe error response.SubscriptionErrorException

Get Billing Plan

Shows details for a plan, by ID.

CompletableFuture<ApiResponse<BillingPlan>> getBillingPlanAsync(
    final String id)

Authentication

This endpoint requires Oauth2

Parameters

ParameterTypeTagsDescription
idStringTemplate, RequiredThe ID of the plan.

Response Type

200: A successful request returns the HTTP 200 OK status code and a JSON response body that shows plan details.

This method returns an ApiResponse instance. The getResult() getter of this instance returns the response data which is of type BillingPlan.

Example Usage

String id = "id0";

subscriptionsController.getBillingPlanAsync(id).thenAccept(result -> {
    // TODO success callback handler
    System.out.println(result);
}).exceptionally(exception -> {
    Throwable cause = exception.getCause();

    if (cause instanceof SubscriptionErrorException) {
        SubscriptionErrorException subscriptionErrorException = (SubscriptionErrorException) cause;
        subscriptionErrorException.printStackTrace();
    } else {
        // fallback for unexpected errors
        exception.printStackTrace();
    }

    return null;
});

Errors

HTTP Status CodeError DescriptionException Class
401Authentication failed due to missing authorization header, or invalid authentication credentials.SubscriptionErrorException
403Authorization failed due to insufficient permissions.SubscriptionErrorException
404The specified resource does not exist.SubscriptionErrorException
500An internal server error has occurred.SubscriptionErrorException
DefaultThe error response.SubscriptionErrorException

Patch Billing Plan

Updates a plan with the CREATED or ACTIVE status. For an INACTIVE plan, you can make only status updates. You can patch these attributes and objects: Attribute or object Operations description replace payment_preferences.auto_bill_outstanding replace taxes.percentage replace payment_preferences.payment_failure_threshold replace payment_preferences.setup_fee replace payment_preferences.setup_fee_failure_action replace name replace

CompletableFuture<ApiResponse<Void>> patchBillingPlanAsync(
    final PatchBillingPlanInput input)

Authentication

This endpoint requires Oauth2

Parameters

ParameterTypeTagsDescription
inputPatchBillingPlanInputRequiredInput structure for the method PatchBillingPlanAsync

Response Type

204: A successful request returns the HTTP 204 No Content status code with no JSON response body.

void

Example Usage

PatchBillingPlanInput patchBillingPlanInput = new PatchBillingPlanInput.Builder(
    "id0",
    null
)
.body(Arrays.asList(
        new Patch.Builder(
            PatchOp.ADD
        )
        .build()
    ))
.build();

subscriptionsController.patchBillingPlanAsync(patchBillingPlanInput).thenAccept(result -> {
    // TODO success callback handler
    System.out.println(result);
}).exceptionally(exception -> {
    Throwable cause = exception.getCause();

    if (cause instanceof SubscriptionErrorException) {
        SubscriptionErrorException subscriptionErrorException = (SubscriptionErrorException) cause;
        subscriptionErrorException.printStackTrace();
    } else {
        // fallback for unexpected errors
        exception.printStackTrace();
    }

    return null;
});

Errors

HTTP Status CodeError DescriptionException Class
400Request is not well-formed, syntactically incorrect, or violates schema.SubscriptionErrorException
401Authentication failed due to missing authorization header, or invalid authentication credentials.SubscriptionErrorException
403Authorization failed due to insufficient permissions.SubscriptionErrorException
404The specified resource does not exist.SubscriptionErrorException
422The requested action could not be performed, semantically incorrect, or failed business validation.SubscriptionErrorException
500An internal server error has occurred.SubscriptionErrorException
DefaultThe error response.SubscriptionErrorException

Activate Billing Plan

Activates a plan, by ID.

CompletableFuture<ApiResponse<Void>> activateBillingPlanAsync(
    final String id)

Authentication

This endpoint requires Oauth2

Parameters

ParameterTypeTagsDescription
idStringTemplate, RequiredThe ID of the plan.

Response Type

204: A successful request returns the HTTP 204 No Content status code with no JSON response body.

void

Example Usage

String id = "id0";

subscriptionsController.activateBillingPlanAsync(id).thenAccept(result -> {
    // TODO success callback handler
    System.out.println(result);
}).exceptionally(exception -> {
    Throwable cause = exception.getCause();

    if (cause instanceof SubscriptionErrorException) {
        SubscriptionErrorException subscriptionErrorException = (SubscriptionErrorException) cause;
        subscriptionErrorException.printStackTrace();
    } else {
        // fallback for unexpected errors
        exception.printStackTrace();
    }

    return null;
});

Errors

HTTP Status CodeError DescriptionException Class
401Authentication failed due to missing authorization header, or invalid authentication credentials.SubscriptionErrorException
403Authorization failed due to insufficient permissions.SubscriptionErrorException
404The specified resource does not exist.SubscriptionErrorException
422The requested action could not be performed, semantically incorrect, or failed business validation.SubscriptionErrorException
500An internal server error has occurred.SubscriptionErrorException
DefaultThe error response.SubscriptionErrorException

Deactivate Billing Plan

Deactivates a plan, by ID.

CompletableFuture<ApiResponse<Void>> deactivateBillingPlanAsync(
    final String id)

Authentication

This endpoint requires Oauth2

Parameters

ParameterTypeTagsDescription
idStringTemplate, RequiredThe ID of the plan.

Response Type

204: A successful request returns the HTTP 204 No Content status code with no JSON response body.

void

Example Usage

String id = "id0";

subscriptionsController.deactivateBillingPlanAsync(id).thenAccept(result -> {
    // TODO success callback handler
    System.out.println(result);
}).exceptionally(exception -> {
    Throwable cause = exception.getCause();

    if (cause instanceof SubscriptionErrorException) {
        SubscriptionErrorException subscriptionErrorException = (SubscriptionErrorException) cause;
        subscriptionErrorException.printStackTrace();
    } else {
        // fallback for unexpected errors
        exception.printStackTrace();
    }

    return null;
});

Errors

HTTP Status CodeError DescriptionException Class
401Authentication failed due to missing authorization header, or invalid authentication credentials.SubscriptionErrorException
403Authorization failed due to insufficient permissions.SubscriptionErrorException
404The specified resource does not exist.SubscriptionErrorException
422The requested action could not be performed, semantically incorrect, or failed business validation.SubscriptionErrorException
500An internal server error has occurred.SubscriptionErrorException
DefaultThe error response.SubscriptionErrorException

Update Billing Plan Pricing Schemes

Updates pricing for a plan. For example, you can update a regular billing cycle from $5 per month to $7 per month.

CompletableFuture<ApiResponse<Void>> updateBillingPlanPricingSchemesAsync(
    final UpdateBillingPlanPricingSchemesInput input)

Authentication

This endpoint requires Oauth2

Parameters

ParameterTypeTagsDescription
inputUpdateBillingPlanPricingSchemesInputRequiredInput structure for the method UpdateBillingPlanPricingSchemesAsync

Response Type

204: A successful request returns the HTTP 204 No Content status code with no JSON response body.

void

Example Usage

UpdateBillingPlanPricingSchemesInput updateBillingPlanPricingSchemesInput = new UpdateBillingPlanPricingSchemesInput.Builder(
    "id0",
    null
)
.body(new UpdatePricingSchemesRequest.Builder(
        Arrays.asList(
            new UpdatePricingScheme.Builder(
                34,
                new SubscriptionPricingScheme.Builder()
                    .build()
            )
            .build()
        )
    )
    .build())
.build();

subscriptionsController.updateBillingPlanPricingSchemesAsync(updateBillingPlanPricingSchemesInput).thenAccept(result -> {
    // TODO success callback handler
    System.out.println(result);
}).exceptionally(exception -> {
    Throwable cause = exception.getCause();

    if (cause instanceof SubscriptionErrorException) {
        SubscriptionErrorException subscriptionErrorException = (SubscriptionErrorException) cause;
        subscriptionErrorException.printStackTrace();
    } else {
        // fallback for unexpected errors
        exception.printStackTrace();
    }

    return null;
});

Errors

HTTP Status CodeError DescriptionException Class
400Bad Request. Request is not well-formed, syntactically incorrect, or violates schema.SubscriptionErrorException
401Authentication failed due to missing authorization header, or invalid authentication credentials.SubscriptionErrorException
403Authorization failed due to insufficient permissions.SubscriptionErrorException
404The specified resource does not exist.SubscriptionErrorException
422The requested action could not be performed, semantically incorrect, or failed business validation.SubscriptionErrorException
500An internal server error has occurred.SubscriptionErrorException
DefaultThe error response.SubscriptionErrorException

Create Subscription

Creates a subscription.

CompletableFuture<ApiResponse<Subscription>> createSubscriptionAsync(
    final CreateSubscriptionInput input)

Authentication

This endpoint requires Oauth2

Parameters

ParameterTypeTagsDescription
inputCreateSubscriptionInputRequiredInput structure for the method CreateSubscriptionAsync

Response Type

200: A successful request returns the HTTP 200 OK status code and a JSON response body that shows subscription details.

This method returns an ApiResponse instance. The getResult() getter of this instance returns the response data which is of type Subscription.

Example Usage

CreateSubscriptionInput createSubscriptionInput = new CreateSubscriptionInput.Builder(
    null
)
.prefer("return=minimal")
.body(new CreateSubscriptionRequest.Builder(
        "plan_id8"
    )
    .autoRenewal(false)
    .build())
.build();

subscriptionsController.createSubscriptionAsync(createSubscriptionInput).thenAccept(result -> {
    // TODO success callback handler
    System.out.println(result);
}).exceptionally(exception -> {
    Throwable cause = exception.getCause();

    if (cause instanceof SubscriptionErrorException) {
        SubscriptionErrorException subscriptionErrorException = (SubscriptionErrorException) cause;
        subscriptionErrorException.printStackTrace();
    } else {
        // fallback for unexpected errors
        exception.printStackTrace();
    }

    return null;
});

Errors

HTTP Status CodeError DescriptionException Class
400Bad Request. Request is not well-formed, syntactically incorrect, or violates schema.SubscriptionErrorException
401Authentication failed due to missing authorization header, or invalid authentication credentials.SubscriptionErrorException
403Authorization failed due to insufficient permissions.SubscriptionErrorException
422The requested action could not be performed, semantically incorrect, or failed business validation.SubscriptionErrorException
500An internal server error has occurred.SubscriptionErrorException
DefaultThe error response.SubscriptionErrorException

List Subscriptions

List all subscriptions for merchant account.

CompletableFuture<ApiResponse<SubscriptionCollection>> listSubscriptionsAsync(
    final ListSubscriptionsInput input)

Authentication

This endpoint requires Oauth2

Parameters

ParameterTypeTagsDescription
inputListSubscriptionsInputRequiredInput structure for the method ListSubscriptionsAsync

Response Type

200: A successful request returns the HTTP 200 OK status code and a JSON response body that lists the subscriptions.

This method returns an ApiResponse instance. The getResult() getter of this instance returns the response data which is of type SubscriptionCollection.

Example Usage

ListSubscriptionsInput listSubscriptionsInput = new ListSubscriptionsInput.Builder()
    .pageSize(10)
    .page(1)
    .build();

subscriptionsController.listSubscriptionsAsync(listSubscriptionsInput).thenAccept(result -> {
    // TODO success callback handler
    System.out.println(result);
}).exceptionally(exception -> {
    Throwable cause = exception.getCause();

    if (cause instanceof SubscriptionErrorException) {
        SubscriptionErrorException subscriptionErrorException = (SubscriptionErrorException) cause;
        subscriptionErrorException.printStackTrace();
    } else {
        // fallback for unexpected errors
        exception.printStackTrace();
    }

    return null;
});

Errors

HTTP Status CodeError DescriptionException Class
400Request is not well-formed, syntactically incorrect, or violates schema.SubscriptionErrorException
401Authentication failed due to missing authorization header, or invalid authentication credentials.SubscriptionErrorException
403Authorization failed due to insufficient permissions.SubscriptionErrorException
500An internal server error has occurred.SubscriptionErrorException
DefaultThe error response.SubscriptionErrorException

Get Subscription

Shows details for a subscription, by ID.

CompletableFuture<ApiResponse<Subscription>> getSubscriptionAsync(
    final GetSubscriptionInput input)

Authentication

This endpoint requires Oauth2

Parameters

ParameterTypeTagsDescription
inputGetSubscriptionInputRequiredInput structure for the method GetSubscriptionAsync

Response Type

200: A successful request returns the HTTP 200 OK status code and a JSON response body that shows subscription details.

This method returns an ApiResponse instance. The getResult() getter of this instance returns the response data which is of type Subscription.

Example Usage

GetSubscriptionInput getSubscriptionInput = new GetSubscriptionInput.Builder(
    "id0"
)
.build();

subscriptionsController.getSubscriptionAsync(getSubscriptionInput).thenAccept(result -> {
    // TODO success callback handler
    System.out.println(result);
}).exceptionally(exception -> {
    Throwable cause = exception.getCause();

    if (cause instanceof SubscriptionErrorException) {
        SubscriptionErrorException subscriptionErrorException = (SubscriptionErrorException) cause;
        subscriptionErrorException.printStackTrace();
    } else {
        // fallback for unexpected errors
        exception.printStackTrace();
    }

    return null;
});

Errors

HTTP Status CodeError DescriptionException Class
401Authentication failed due to missing authorization header, or invalid authentication credentials.SubscriptionErrorException
403Authorization failed due to insufficient permissions.SubscriptionErrorException
404The specified resource does not exist.SubscriptionErrorException
500An internal server error has occurred.SubscriptionErrorException
DefaultThe error response.SubscriptionErrorException

Patch Subscription

Updates a subscription which could be in ACTIVE or SUSPENDED status. You can override plan level default attributes by providing customised values for plan path in the patch request. You cannot update attributes that have already completed (Example - trial cycles canโ€™t be updated if completed). Once overridden, changes to plan resource will not impact subscription. Any price update will not impact billing cycles within next 10 days (Applicable only for subscriptions funded by PayPal account). Following are the fields eligible for patch. Attribute or object Operations billing_info.outstanding_balance replace custom_id add,replace plan.billing_cycles[@sequence==n]. pricing_scheme.fixed_price add,replace plan.billing_cycles[@sequence==n]. pricing_scheme.tiers replace plan.billing_cycles[@sequence==n]. total_cycles replace plan.payment_preferences. auto_bill_outstanding replace plan.payment_preferences. payment_failure_threshold replace plan.taxes.inclusive add,replace plan.taxes.percentage add,replace shipping_amount add,replace start_time replace subscriber.shipping_address add,replace subscriber.payment_source (for subscriptions funded by card payments) replace

CompletableFuture<ApiResponse<Void>> patchSubscriptionAsync(
    final PatchSubscriptionInput input)

Authentication

This endpoint requires Oauth2

Parameters

ParameterTypeTagsDescription
inputPatchSubscriptionInputRequiredInput structure for the method PatchSubscriptionAsync

Response Type

204: A successful request returns the HTTP 204 No Content status code with no JSON response body.

void

Example Usage

PatchSubscriptionInput patchSubscriptionInput = new PatchSubscriptionInput.Builder(
    "id0",
    null
)
.body(Arrays.asList(
        new Patch.Builder(
            PatchOp.ADD
        )
        .build()
    ))
.build();

subscriptionsController.patchSubscriptionAsync(patchSubscriptionInput).thenAccept(result -> {
    // TODO success callback handler
    System.out.println(result);
}).exceptionally(exception -> {
    Throwable cause = exception.getCause();

    if (cause instanceof SubscriptionErrorException) {
        SubscriptionErrorException subscriptionErrorException = (SubscriptionErrorException) cause;
        subscriptionErrorException.printStackTrace();
    } else {
        // fallback for unexpected errors
        exception.printStackTrace();
    }

    return null;
});

Errors

HTTP Status CodeError DescriptionException Class
400Request is not well-formed, syntactically incorrect, or violates schema.SubscriptionErrorException
401Authentication failed due to missing authorization header, or invalid authentication credentials.SubscriptionErrorException
403Authorization failed due to insufficient permissions.SubscriptionErrorException
404The specified resource does not exist.SubscriptionErrorException
422The requested action could not be performed, semantically incorrect, or failed business validation.SubscriptionErrorException
500An internal server error has occurred.SubscriptionErrorException
DefaultThe error response.SubscriptionErrorException

Revise Subscription

Updates the quantity of the product or service in a subscription. You can also use this method to switch the plan and update the shipping_amount, shipping_address values for the subscription. This type of update requires the buyer's consent.

CompletableFuture<ApiResponse<ModifySubscriptionResponse>> reviseSubscriptionAsync(
    final ReviseSubscriptionInput input)

Authentication

This endpoint requires Oauth2

Parameters

ParameterTypeTagsDescription
inputReviseSubscriptionInputRequiredInput structure for the method ReviseSubscriptionAsync

Response Type

200: A successful request returns the HTTP 200 OK status code and a JSON response body that shows subscription details.

This method returns an ApiResponse instance. The getResult() getter of this instance returns the response data which is of type ModifySubscriptionResponse.

Example Usage

ReviseSubscriptionInput reviseSubscriptionInput = new ReviseSubscriptionInput.Builder(
    "id0",
    null
)
.build();

subscriptionsController.reviseSubscriptionAsync(reviseSubscriptionInput).thenAccept(result -> {
    // TODO success callback handler
    System.out.println(result);
}).exceptionally(exception -> {
    Throwable cause = exception.getCause();

    if (cause instanceof SubscriptionErrorException) {
        SubscriptionErrorException subscriptionErrorException = (SubscriptionErrorException) cause;
        subscriptionErrorException.printStackTrace();
    } else {
        // fallback for unexpected errors
        exception.printStackTrace();
    }

    return null;
});

Errors

HTTP Status CodeError DescriptionException Class
400Bad Request. Request is not well-formed, syntactically incorrect, or violates schema.SubscriptionErrorException
401Authentication failed due to missing authorization header, or invalid authentication credentials.SubscriptionErrorException
403Authorization failed due to insufficient permissions.SubscriptionErrorException
404The specified resource does not exist.SubscriptionErrorException
422The requested action could not be performed, semantically incorrect, or failed business validation.SubscriptionErrorException
500An internal server error has occurred.SubscriptionErrorException
DefaultThe error response.SubscriptionErrorException

Suspend Subscription

Suspends the subscription.

CompletableFuture<ApiResponse<Void>> suspendSubscriptionAsync(
    final SuspendSubscriptionInput input)

Authentication

This endpoint requires Oauth2

Parameters

ParameterTypeTagsDescription
inputSuspendSubscriptionInputRequiredInput structure for the method SuspendSubscriptionAsync

Response Type

204: A successful request returns the HTTP 204 No Content status code with no JSON response body.

void

Example Usage

SuspendSubscriptionInput suspendSubscriptionInput = new SuspendSubscriptionInput.Builder(
    "id0",
    null
)
.build();

subscriptionsController.suspendSubscriptionAsync(suspendSubscriptionInput).thenAccept(result -> {
    // TODO success callback handler
    System.out.println(result);
}).exceptionally(exception -> {
    Throwable cause = exception.getCause();

    if (cause instanceof SubscriptionErrorException) {
        SubscriptionErrorException subscriptionErrorException = (SubscriptionErrorException) cause;
        subscriptionErrorException.printStackTrace();
    } else {
        // fallback for unexpected errors
        exception.printStackTrace();
    }

    return null;
});

Errors

HTTP Status CodeError DescriptionException Class
400Bad Request. Request is not well-formed, syntactically incorrect, or violates schema.SubscriptionErrorException
401Authentication failed due to missing authorization header, or invalid authentication credentials.SubscriptionErrorException
403Authorization failed due to insufficient permissions.SubscriptionErrorException
404The specified resource does not exist.SubscriptionErrorException
422The requested action could not be performed, semantically incorrect, or failed business validation.SubscriptionErrorException
500An internal server error has occurred.SubscriptionErrorException
DefaultThe error response.SubscriptionErrorException

Cancel Subscription

Cancels the subscription.

CompletableFuture<ApiResponse<Void>> cancelSubscriptionAsync(
    final CancelSubscriptionInput input)

Authentication

This endpoint requires Oauth2

Parameters

ParameterTypeTagsDescription
inputCancelSubscriptionInputRequiredInput structure for the method CancelSubscriptionAsync

Response Type

204: A successful request returns the HTTP 204 No Content status code with no JSON response body.

void

Example Usage

CancelSubscriptionInput cancelSubscriptionInput = new CancelSubscriptionInput.Builder(
    "id0",
    null
)
.build();

subscriptionsController.cancelSubscriptionAsync(cancelSubscriptionInput).thenAccept(result -> {
    // TODO success callback handler
    System.out.println(result);
}).exceptionally(exception -> {
    Throwable cause = exception.getCause();

    if (cause instanceof SubscriptionErrorException) {
        SubscriptionErrorException subscriptionErrorException = (SubscriptionErrorException) cause;
        subscriptionErrorException.printStackTrace();
    } else {
        // fallback for unexpected errors
        exception.printStackTrace();
    }

    return null;
});

Errors

HTTP Status CodeError DescriptionException Class
400Bad Request. Request is not well-formed, syntactically incorrect, or violates schema.SubscriptionErrorException
401Authentication failed due to missing authorization header, or invalid authentication credentials.SubscriptionErrorException
403Authorization failed due to insufficient permissions.SubscriptionErrorException
404The specified resource does not exist.SubscriptionErrorException
422The requested action could not be performed, semantically incorrect, or failed business validation.SubscriptionErrorException
500An internal server error has occurred.SubscriptionErrorException
DefaultThe error response.SubscriptionErrorException

Activate Subscription

Activates the subscription.

CompletableFuture<ApiResponse<Void>> activateSubscriptionAsync(
    final ActivateSubscriptionInput input)

Authentication

This endpoint requires Oauth2

Parameters

ParameterTypeTagsDescription
inputActivateSubscriptionInputRequiredInput structure for the method ActivateSubscriptionAsync

Response Type

204: A successful request returns the HTTP 204 No Content status code with no JSON response body.

void

Example Usage

ActivateSubscriptionInput activateSubscriptionInput = new ActivateSubscriptionInput.Builder(
    "id0",
    null
)
.build();

subscriptionsController.activateSubscriptionAsync(activateSubscriptionInput).thenAccept(result -> {
    // TODO success callback handler
    System.out.println(result);
}).exceptionally(exception -> {
    Throwable cause = exception.getCause();

    if (cause instanceof SubscriptionErrorException) {
        SubscriptionErrorException subscriptionErrorException = (SubscriptionErrorException) cause;
        subscriptionErrorException.printStackTrace();
    } else {
        // fallback for unexpected errors
        exception.printStackTrace();
    }

    return null;
});

Errors

HTTP Status CodeError DescriptionException Class
400Bad Request. Request is not well-formed, syntactically incorrect, or violates schema.SubscriptionErrorException
401Authentication failed due to missing authorization header, or invalid authentication credentials.SubscriptionErrorException
403Authorization failed due to insufficient permissions.SubscriptionErrorException
404The specified resource does not exist.SubscriptionErrorException
422The requested action could not be performed, semantically incorrect, or failed business validation.SubscriptionErrorException
500An internal server error has occurred.SubscriptionErrorException
DefaultThe error response.SubscriptionErrorException

Capture Subscription

Captures an authorized payment from the subscriber on the subscription.

CompletableFuture<ApiResponse<SubscriptionTransactionDetails>> captureSubscriptionAsync(
    final CaptureSubscriptionInput input)

Authentication

This endpoint requires Oauth2

Parameters

ParameterTypeTagsDescription
inputCaptureSubscriptionInputRequiredInput structure for the method CaptureSubscriptionAsync

Response Type

200: A successful request returns the HTTP 200 OK status code and a JSON response body that shows subscription details.

This method returns an ApiResponse instance. The getResult() getter of this instance returns the response data which is of type SubscriptionTransactionDetails.

Example Usage

CaptureSubscriptionInput captureSubscriptionInput = new CaptureSubscriptionInput.Builder(
    "id0",
    null
)
.build();

subscriptionsController.captureSubscriptionAsync(captureSubscriptionInput).thenAccept(result -> {
    // TODO success callback handler
    System.out.println(result);
}).exceptionally(exception -> {
    Throwable cause = exception.getCause();

    if (cause instanceof SubscriptionErrorException) {
        SubscriptionErrorException subscriptionErrorException = (SubscriptionErrorException) cause;
        subscriptionErrorException.printStackTrace();
    } else {
        // fallback for unexpected errors
        exception.printStackTrace();
    }

    return null;
});

Errors

HTTP Status CodeError DescriptionException Class
400Bad Request. Request is not well-formed, syntactically incorrect, or violates schema.SubscriptionErrorException
401Authentication failed due to missing authorization header, or invalid authentication credentials.SubscriptionErrorException
403Authorization failed due to insufficient permissions.SubscriptionErrorException
404The specified resource does not exist.SubscriptionErrorException
422The requested action could not be performed, semantically incorrect, or failed business validation.SubscriptionErrorException
500An internal server error has occurred.SubscriptionErrorException
DefaultThe error response.SubscriptionErrorException

List Subscription Transactions

Lists transactions for a subscription.

CompletableFuture<ApiResponse<TransactionsList>> listSubscriptionTransactionsAsync(
    final ListSubscriptionTransactionsInput input)

Authentication

This endpoint requires Oauth2

Parameters

ParameterTypeTagsDescription
inputListSubscriptionTransactionsInputRequiredInput structure for the method ListSubscriptionTransactionsAsync

Response Type

200: A successful request returns the HTTP 200 OK status code and a JSON response body that shows subscription details.

This method returns an ApiResponse instance. The getResult() getter of this instance returns the response data which is of type TransactionsList.

Example Usage

ListSubscriptionTransactionsInput listSubscriptionTransactionsInput = new ListSubscriptionTransactionsInput.Builder(
    "id0",
    "start_time6",
    "end_time2"
)
.build();

subscriptionsController.listSubscriptionTransactionsAsync(listSubscriptionTransactionsInput).thenAccept(result -> {
    // TODO success callback handler
    System.out.println(result);
}).exceptionally(exception -> {
    Throwable cause = exception.getCause();

    if (cause instanceof SubscriptionErrorException) {
        SubscriptionErrorException subscriptionErrorException = (SubscriptionErrorException) cause;
        subscriptionErrorException.printStackTrace();
    } else {
        // fallback for unexpected errors
        exception.printStackTrace();
    }

    return null;
});

Errors

HTTP Status CodeError DescriptionException Class
400Bad Request. Request is not well-formed, syntactically incorrect, or violates schema.SubscriptionErrorException
401Authentication failed due to missing authorization header, or invalid authentication credentials.SubscriptionErrorException
403Authorization failed due to insufficient permissions.SubscriptionErrorException
404The specified resource does not exist.SubscriptionErrorException
500An internal server error has occurred.SubscriptionErrorException
DefaultThe error response.SubscriptionErrorException