Quickstart
Stay organized with collections
Save and categorize content based on your preferences.
Enable the API
Find the API library on the Cloud Console under APIs and Services > Library
. Search for Payments Reseller Subscription API
and enable it.
Once enabled, you will have access to two environments:
Using the Java API client
See the Github Repository for the latest version of the java API client library.
Use the sandbox endpoint
You can override the API endpoint in the java client library as follows:
PaymentsResellerSubscription client = new PaymentsResellerSubscription.Builder(
GoogleNetHttpTransport.newTrustedTransport(),
JacksonFactory.getDefaultInstance(),
requestInitializer)
// Override the root_url for sandbox testing.
.setRootUrl("https://preprod-paymentsresellersubscription.googleapis.com")
.build();
Use oauth authentication for service accounts
If your production environment in on GCP, such as Compute Engine or App Engine, you can directly use:
GoogleCredentials credentials = GoogleCredentials.getApplicationDefault().createScoped(SCOPES);
Otherwise, you can load the service account credential file explicitly.
GoogleCredentials credentials = GoogleCredentials.fromStream(new FileInputStream(jsonPath))
.createScoped(SCOPES);
Then, specify a request initializer that automatically sets the auth token as follows:
HttpRequestInitializer requestInitializer = new HttpCredentialsAdapter(credentials);
PaymentsResellerSubscription client = new PaymentsResellerSubscription.Builder(
HTTP_TRANSPORT, JacksonFactory.getDefaultInstance(),
requestInitializer
).build();
// Issue Subscription Provision API
client.partners()
.subscriptions()
.provision("partners/partnerId",
new Subscription()
.setLineItems(
ImmutableList
.of(new LineItem()
.setProduct("partners/partnerId/products/productId")))
.setPartnerUserToken("user_token")
.setServiceLocation(
new Location().setRegionCode("US")))
.setSubscriptionId("subscriptionId")
.execute();
Use user authorized oauth authentication
Depends on your production environment, OAuth 2.0 and the Google OAuth Client Library for Java provides code samples for authorization code flow in Servlet and AppEngine. You could also refer to the section Command-line authorization code flow in the oauth java client documentation to test the flow locally.
Once you obtained the user authorized credential, you can set the access token as follows:
// Issue Subscription Entitle API
client
.partners()
.subscriptions()
.entitle("partners/partnerId/subscriptions/subscriptionId",
new EntitleSubscriptionRequest())
.setAccessToken(credential.getAccessToken())
.execute();
Please note that we don't need a request initializer for auth credentials when creating the client
object, because the access token is manually specified.
PaymentsResellerSubscription client = new PaymentsResellerSubscription.Builder(
GoogleNetHttpTransport.newTrustedTransport(),
JacksonFactory.getDefaultInstance(),
/* Don't specify an initializer for auth credentials */ request -> {})
.build();
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-13 UTC.
[null,null,["Last updated 2025-08-13 UTC."],[[["\u003cp\u003eEnable the Payments Reseller Subscription API through the Cloud Console to access production and sandbox environments.\u003c/p\u003e\n"],["\u003cp\u003eUtilize the Java API client library, available on GitHub, to interact with the API.\u003c/p\u003e\n"],["\u003cp\u003eAuthenticate using service accounts for server-side applications or OAuth 2.0 for user authorization.\u003c/p\u003e\n"],["\u003cp\u003eOverride the API endpoint to use the sandbox environment for testing purposes.\u003c/p\u003e\n"],["\u003cp\u003eRefer to provided code snippets for implementation details on authentication and API calls.\u003c/p\u003e\n"]]],["To use the Payments Reseller Subscription API, first enable it in the Cloud Console's API Library. Access production or sandbox environments via their respective URLs. Utilize the Java API client from the GitHub repository. For sandbox testing, override the root URL in the client. For service accounts, use `GoogleCredentials` with appropriate scopes, setting a request initializer for authentication. User-authorized OAuth requires setting the access token manually in each request; no request initializer is needed when creating the client.\n"],null,["# Quickstart\n\nEnable the API\n--------------\n\nFind the API library on the Cloud Console under `APIs and Services \u003e Library`. Search for `Payments Reseller Subscription API` and enable it.\n\nOnce enabled, you will have access to two environments:\n\n- production: \u003chttps://paymentsresellersubscription.googleapis.com\u003e\n- sandbox: \u003chttps://preprod-paymentsresellersubscription.googleapis.com\u003e\n\nUsing the Java API client\n-------------------------\n\nSee the [Github Repository](https://github.com/googleapis/google-api-java-client-services/tree/master/clients/google-api-services-paymentsresellersubscription/v1) for the latest version of the java API client library.\n\n### Use the sandbox endpoint\n\nYou can override the API endpoint in the java client library as follows: \n\n PaymentsResellerSubscription client = new PaymentsResellerSubscription.Builder(\n GoogleNetHttpTransport.newTrustedTransport(),\n JacksonFactory.getDefaultInstance(),\n requestInitializer)\n // Override the root_url for sandbox testing.\n .setRootUrl(\"https://preprod-paymentsresellersubscription.googleapis.com\")\n .build();\n\n### Use oauth authentication for service accounts\n\nIf your production environment in on GCP, such as Compute Engine or App Engine, you can directly use: \n\n GoogleCredentials credentials = GoogleCredentials.getApplicationDefault().createScoped(SCOPES);\n\nOtherwise, you can load the service account credential file explicitly. \n\n GoogleCredentials credentials = GoogleCredentials.fromStream(new FileInputStream(jsonPath))\n .createScoped(SCOPES);\n\nThen, specify a request initializer that automatically sets the auth token as follows: \n\n HttpRequestInitializer requestInitializer = new HttpCredentialsAdapter(credentials);\n\n\n PaymentsResellerSubscription client = new PaymentsResellerSubscription.Builder(\n HTTP_TRANSPORT, JacksonFactory.getDefaultInstance(),\n requestInitializer\n ).build();\n\n // Issue Subscription Provision API\n client.partners()\n .subscriptions()\n .provision(\"partners/partnerId\",\n new Subscription()\n .setLineItems(\n ImmutableList\n .of(new LineItem()\n .setProduct(\"partners/partnerId/products/productId\")))\n .setPartnerUserToken(\"user_token\")\n .setServiceLocation(\n new Location().setRegionCode(\"US\")))\n .setSubscriptionId(\"subscriptionId\")\n .execute();\n\n### Use user authorized oauth authentication\n\nDepends on your production environment, [OAuth 2.0 and the Google OAuth Client Library for Java](https://developers.google.com/api-client-library/java/google-oauth-java-client/oauth2#authorization_code_flow) provides code samples for authorization code flow in Servlet and AppEngine. You could also refer to the section [Command-line authorization code flow](https://developers.google.com/api-client-library/java/google-oauth-java-client/oauth2#command-line_authorization_code_flow) in the oauth java client documentation to test the flow locally.\n\nOnce you obtained the user authorized credential, you can set the access token as follows: \n\n // Issue Subscription Entitle API\n client\n .partners()\n .subscriptions()\n .entitle(\"partners/partnerId/subscriptions/subscriptionId\",\n new EntitleSubscriptionRequest())\n .setAccessToken(credential.getAccessToken())\n .execute();\n\nPlease note that we don't need a request initializer for auth credentials when creating the `client` object, because the access token is manually specified. \n\n PaymentsResellerSubscription client = new PaymentsResellerSubscription.Builder(\n GoogleNetHttpTransport.newTrustedTransport(),\n JacksonFactory.getDefaultInstance(),\n /* Don't specify an initializer for auth credentials */ request -\u003e {})\n .build();"]]