Introduction
The Samsung IAP Subscription server APIs empower builders to effectively handle Samsung In-App Buy (IAP) subscriptions, together with cancellation, refund, revocation, and standing verify. These APIs function the muse for implementing subscription administration options inside your utility administration server.
Integrating the Samsung IAP server APIs along with your backend server simplifies subscription administration. This integration lets you cancel subscriptions and forestall additional billing for customers, revoke entry to subscription-based content material, course of refunds primarily based on consumer requests, and verify subscription standing to find out validity and present state.
A well-structured backend implementation streamlines subscription administration, making certain clients obtain dependable service and minimizing potential points associated to billing, entry, and refunds.
Stipulations
To ascertain server-to-server communication between the Samsung IAP service and your server, observe these important steps.
- Develop a Subscription Utility – Guarantee your utility helps subscription operations.
- Add Binary for Beta Testing – Submit your utility for testing in Vendor Portal.
- Create Subscriptions – Arrange subscription merchandise in Vendor Portal for consumer subscriptions.
Finishing these steps ensures a seamless integration of Samsung IAP into your utility. For detailed steerage, go to Register an app and in-app gadgets in Vendor Portal.
Implementation of the Samsung Subscription APIs
The Samsung IAP Subscription server APIs are used to handle subscription-related operations, together with cancellations, revocations, refunds, and standing checks.
To leverage these APIs successfully, establishing a backend server is important. This safe server-to-server communication facilitates environment friendly dealing with of all subscription-related operations between the Samsung IAP service and your server.
API Overview
The Samsung IAP Subscription server API gives endpoints for effectively managing subscription-based operations. It permits builders to cancel, revoke, refund, and verify the standing of subscriptions. This API additionally facilitates strong operations and environment friendly administration of consumer subscriptions, all whereas making certain safety and authentication by the usage of applicable headers.
Base Endpoint
The Samsung IAP Subscription server APIs want a safe endpoint for managing subscriptions.
https://devapi.samsungapps.com/iap/vendor/v6/functions//purchases/subscriptions/
Extra detailed data is offered by the Assist Documentation.
Headers
To make sure safe communication with the Samsung IAP service, the next headers have to be included in each request.
- Content material-Sort – Defines the format of the request physique. For JSON content material, use utility/json.
- Authorization – Makes use of an entry token for authentication. The format needs to be (Bearer
). Seek advice from the Create an Entry Token web page for particulars on producing an entry token. - Service Account ID – Obtained from Vendor Portal below Help > API Service. This ID is required to generate a JSON Net Token (JWT). For extra detailed data, go to the Create a Service Account part in Vendor Portal.
These headers collectively guarantee safe and authenticated API requests, enabling seamless integration with the Samsung IAP service.
Supported Strategies
The Samsung IAP Subscription server API allows environment friendly subscription administration. Builders can cancel, revoke, or refund subscriptions utilizing PATCH requests, and verify subscription standing utilizing GET requests.
Configuring the Server
You possibly can develop a Spring Boot server for this function. Listed here are the rules for setting it up.
- Create a Spring Boot Challenge – For detailed steps, consult with Growing Your First Spring Boot Utility.
- Set Up the Server Endpoint:
- Create a controller for Samsung IAP Subscription APIs inside your IDE after importing the Spring Boot mission. This controller manages all in-app subscription actions.
- The controller performs
PATCHandGETrequests with the Samsung IAP service, making certain communication along with your server.
Performing a PATCH Request
The PATCH request is used to cancel, refund, or revoke a subscription. Comply with these steps to proceed.
- Making a Request Physique
To cancel, refund, or revoke a subscription, a selected request physique have to be created for every operation. When interacting with Samsung IAP service, you ship a well-structured API request tailor-made to the particular motion you want to execute. Beneath are the request codecs for varied subscription operations.
// Cancel a subscription
RequestBody physique = RequestBody.create(
MediaType.parse("utility/json"),
"{"motion" : "cancel"}"
);
// Revoke a subscription
RequestBody physique = RequestBody.create(
MediaType.parse("utility/json"),
"{"motion" : "revoke"}"
);
// Refund a subscription
RequestBody physique = RequestBody.create(
MediaType.parse("utility/json"),
"{"motion" : "refund"}"
);
- Constructing the PATCH Request (Cancel, Revoke or Refund Subscription)
The PATCH technique in REST APIs is used for partial updates of assets, enabling you to ship solely the particular fields that want modification quite than all the useful resource. The PATCH request wants a request physique to specify the supposed motion. To execute a subscription administration request, it’s essential to assemble a safe HTTP request that features all essential headers and authentication particulars.
Request request = new Request.Builder()
.url(API_URL)
.patch(physique)
.addHeader("Content material-Sort", "utility/json")
.addHeader("Authorization", "Bearer " + ACCESS_TOKEN)
.addHeader("service-account-id", SERVICE_ACCOUNT_ID)
.construct();
- Executing the PATCH Request
As soon as the PATCH request is ready, execute it utilizing the OkHttpClient, making certain correct request dealing with and response processing.
@CrossOrigin(origins = "*")
@RequestMapping(worth = "/cancel", technique = RequestMethod.PATCH )
public void patchRequest(){
// Set request physique as JSON with required motion.
// Initialize PATCH request, set physique, add headers, and finalize setup.
consumer.newCall(request).enqueue(new Callback() {
@Override
public void onFailure(Name name, IOException e) {
// deal with exception
}
@Override
public void onResponse(Name name, Response response) throws IOException {
// deal with response
response.shut();
}
});
}
Instance Response
This response signifies that the request was processed efficiently and with out errors.
{
"code" : "0000",
"message" : "Success"
}
Performing a GET Request
The GET request is used to retrieve the standing of a subscription. Comply with these steps to proceed.
- Constructing the GET Request
The GET technique is primarily used to retrieve or learn knowledge from a server. To verify the standing of a subscription, the GET technique is required to retrieve detailed merchandise data. This kind of request doesn’t require a request physique; solely the mandatory headers for authentication are wanted.
Request request = new Request.Builder()
.url(API_URL)
.addHeader("Content material-Sort", "utility/json")
.addHeader("Authorization", "Bearer " + ACCESS_TOKEN)
.addHeader("service-account-id", SERVICE_ACCOUNT_ID)
.construct();
- Executing the GET Request
As soon as the GET request is ready, execute it utilizing the OkHttpClient to retrieve and effectively course of the response knowledge.
@GetMapping("/get")
public void getRequest(){
// Initialize GET request, add headers, and finalize setup.
consumer.newCall(request).enqueue(new Callback() {
@Override
public void onFailure(Name name, IOException e) {
// deal with exception
}
@Override
public void onResponse(Name name, Response response) throws IOException {
// deal with response
}
});
}
Instance Response
If the GET request executes efficiently, it returns the standing of the subscription as a response.
{
"subscriptionPurchaseDate": "2025-04-28 04:54:06 UTC",
"subscriptionEndDate": "2025-04-28 05:54:06 UTC",
"subscriptionStatus": "CANCEL",
"subscriptionFirstPurchaseID": "55541a3d363c9dee6194614024ee2177c72a9dec51fe8dba5b44503f57dc9aec",
"countryCode": "USA",
"value": {
"localCurrencyCode": "USD",
"localPrice": 15,
"supplyPrice": 15
}, ...
}
Deploying and Testing the Server
For the server to carry out API calls, it could use a publicly accessible URL. You possibly can deploy the mission to acquire the URL. For testing functions, you would possibly deploy it on a platform like CodeSandbox, which gives a publicly accessible URL just like https://abcde-8080.csb.app/iap/xxxx.
Conclusion
By correctly integrating the Samsung IAP Subscription server APIs, builders can guarantee seamless dealing with of subscription-related actions inside their functions. The implementation of safe server-to-server communication ensures environment friendly subscription administration and considerably enhances the general consumer expertise.
References
- Obtain Pattern Server Supply Code
- Samsung IAP Subscription Documentation
- Combine the Samsung In-App Buy Orders API with Your Utility
Elevate your perspective with NextTech Information, the place innovation meets perception.
Uncover the most recent breakthroughs, get unique updates, and join with a worldwide community of future-focused thinkers.
Unlock tomorrow’s traits right now: learn extra, subscribe to our e-newsletter, and turn out to be a part of the NextTech neighborhood at NextTech-news.com

