Diversify Your Payment Options with Samsung Pay
-
Similar Topics
-
By Samsung Newsroom
Samsung Wallet allows users to conveniently store and access payment cards, passes, and now also custom gift cards—all in one secure place. With gift card integration, partners can deliver a personalized and rewarding experience to their users, enhancing brand connection and user convenience.
In this article, you learn how to create and integrate your own gift card as a partner using Samsung Wallet’s card template system. Learn to customize visuals, define key details like balance and expiration date, and enable a seamless ‘Add to Samsung Wallet’ experience for your customers.
Gift card setup
Are you ready to dive into the world of Samsung Wallet and create your first card template? Follow these simple steps to get started and bring your ideas to life!
Step 1: Complete the onboarding process if you have not done it already. For details, check out the Onboarding Guide.
Step 2: Log in to the Wallet Partners Portal. This is your gateway to creating and managing your wallet cards.
Step 3: Once logged in, head over to the Wallet Cards section. Here, you find the Create Wallet Card option. For more details about creating a card, don’t forget to check out the Manage Wallet Cards documentation.
Step 4: Choose the Gift Card template from the list of available card templates.
Step 5: Customize your card. Now comes the fun part! Modify the card information to suit your needs. Through adjusting colors, adding logos, or tweaking text, this is where your creativity shines.
Step 6: Launch your card once you are satisfied with your edits. For more details on launching, refer to the Launch Wallet Cards guide.
NoteManaging multiple cards through the Wallet Partners Portal can be challenging. Samsung offers Server APIs to simplify the process, enabling you to create and modify Samsung Wallet card templates efficiently, without relying on the portal. Explore the following blog topic for detailed insights: Create Samsung Wallet Card Templates Using the Server API. Gift card specifications
Before generating the Card Data token for the ‘Add to Samsung Wallet’ button, it’s essential to understand the structure of a sample gift card.
Every gift card in Samsung Wallet is built from a defined set of data fields that determine how the card looks and functions. These fields are part of the card’s JSON structure and control everything from how the card title appears to how barcode data is delivered when scanned.
The following examples illustrate how different card elements map to the gift card specifications. Each image highlights a specific group of parameters used when creating a gift card for Samsung Wallet.
Basic gift card information
This image illustrates the core elements that define the basic structure of a gift card in Samsung Wallet. It highlights the required fields—such as title, appLinkName, appLinkData, and appLinkLogo—which control the card’s main display name and linked actions. Optional parameters like bgImage enhance the visual design by allowing a custom background. Together, these specifications form the foundation of the card’s visible layout and branding.
This image demonstrates the specification fields that define the card’s balance, expiration date, and barcode data in Samsung Wallet.
This image illustrates how the barcode appears when the user taps the Pay button on the gift card. The displayed barcode corresponds to barcode.serialType, which specifies the presentation format (such as BARCODE or SERIALNUMBER). This configuration allows users to redeem their gift cards seamlessly by scanning the code at a merchant terminal.
This image demonstrates the use of the csInfo field to store customer support information. Telephone number, email address, and website address information can all be stored in it.
This image illustrates how the gift card’s display language adapts to the user's device language settings through the localization field. Localization allows the user to serve content in multiple languages. When a user sets their device to a specific language, the corresponding localized content is displayed on their device.
These specifications collectively define how your gift card appears and behaves in Samsung Wallet. For more detailed insights, check out the comprehensive Gift Card document.
Gift card JSON structure
Once you’ve reviewed the gift card specifications, the next step is to define them in the JSON structure. This data structure contains all the parameters that describe your gift card—including its title, amount, expiration date, barcode details, and optional links. The JSON is used to generate the Card Data token, which securely transfers the card information when users tap ‘Add to Samsung Wallet’.
The following is an example JSON file for a sample gift card:
{ "card": { "type": "giftcard", "subType": "others", "data": [ { "refId": {refId}, "createdAt": {createdAt}, "updatedAt": {updatedAt}, "language": "en", "attributes": { "title": "SAMPLE GIFT CARD", "eventId": "event-001", "logoImage": "https://djcpagh05u38x.cloudfront.net/wlt/kr/stg/IHGhULmHRiqfhI73YdQZcA/GhDKJ4z2Q5O23CwuXSupBg.png", "logoImage.darkUrl": "https://djcpagh05u38x.cloudfront.net/wlt/kr/stg/IHGhULmHRiqfhI73YdQZcA/zdzSwFKbTvuvAz35MSKmzw.png", "providerName": "Gift Card Provider name testing", "user": "John Smith", "csInfo": "{\"call\":\"(+82) 1588-3366\",\"website\":\"https://www.samsung.com/us/\"}", "appLinkLogo": "https://d3unf4s5rp9dfh.cloudfront.net/TANGO/03-11-2025-wallet-gift-card-applink-logo-image.png", "appLinkName": "Gift Card Link", "appLinkData": "https://developer.samsung.com/wallet", "bgImage": "https://d3unf4s5rp9dfh.cloudfront.net/TANGO/03-11-2025-wallet-gift-card-design-v2.png", "fontColor": "", "amount": "100P", "startDate": {startDate}, "endDate": {endDate}, "barcode.value": "SDC0102025", "barcode.serialType": "QRCODE", "barcode.ptFormat": "QRCODESERIAL", "barcode.ptSubFormat": "QR_CODE" }, "localization": [ { "language": "ko", "attributes": { "title": "삼성 월렛" } } ] } ] } } NoteIf you do not specify a fontColor value, it automatically adapts to your system settings. For instance, in dark mode, the font color is light, and in light mode, it is dark. Gift card testing with the ‘Add to Wallet’ test tool
You have created a gift card in the Wallet Partners Portal, now check if the card works properly before further development process. Follow these steps to check the card.
Sign in to the Add to Wallet test tool, navigate to the Playground section, select the gift card from the dropdown menu, and press Add to Samsung Wallet.
Navigate to the Add to Wallet menu on the Add to Wallet test tool site and follow the step-by-step guide provided in the Add to Samsung Wallet Test section in the Online Test Tool documentation.
‘Add to Samsung Wallet’ implementation
After testing the card with the ‘Add to Wallet’ test tool, you can let users add it directly to Samsung Wallet. Implement the ‘Add to Samsung Wallet’ button so that user can add the card to their wallet. For more details, refer to the Implementing ATW button documentation.
In the ‘Add to Samsung Wallet’ button implementation process, the generated JWT token expires after 30 seconds. As a result, you need to implement the server logic so that this token generates after the user interaction like pressing a button. See the Implementing "Add to Wallet" in an Android Application blog to get details on the server-side logic implementation process of an ‘Add to Samsung Wallet’ button in an Android application.
Conclusion
Bringing your gift cards to Samsung Wallet creates a secure, seamless, and branded experience for your users. By defining your card data, generating the token, and enabling the Add to Samsung Wallet flow, you make digital gifting effortless and engaging. Start integrating today and let users enjoy convenient, personalized gifting within Samsung Wallet.
Related resources
Utilize the Add to Samsung Wallet service for digital cards Introduce Loyalty Cards to Your Application with Samsung Wallet Implementing "Add to Wallet" in an Android Application Seamlessly Integrate "Add to Wallet" for Samsung Wallet View the full blog at its source
-
By Samsung Newsroom
Samsung Wallet allows users to conveniently store and access payment cards, passes, and now also custom gift cards—all in one secure place. With gift card integration, partners can deliver a personalized and rewarding experience to their users, enhancing brand connection and user convenience.
In this article, you learn how to create and integrate your own gift card as a partner using Samsung Wallet’s card template system. Learn to customize visuals, define key details like balance and expiration date, and enable a seamless ‘Add to Samsung Wallet’ experience for your customers.
Gift card setup
Are you ready to dive into the world of Samsung Wallet and create your first card template? Follow these simple steps to get started and bring your ideas to life!
Step 1: Complete the onboarding process if you have not done it already. For details, check out the Onboarding Guide.
Step 2: Log in to the Wallet Partners Portal. This is your gateway to creating and managing your wallet cards.
Step 3: Once logged in, head over to the Wallet Cards section. Here, you find the Create Wallet Card option. For more details about creating a card, don’t forget to check out the Manage Wallet Cards documentation.
Step 4: Choose the Gift Card template from the list of available card templates.
Step 5: Customize your card. Now comes the fun part! Modify the card information to suit your needs. Through adjusting colors, adding logos, or tweaking text, this is where your creativity shines.
Step 6: Launch your card once you are satisfied with your edits. For more details on launching, refer to the Launch Wallet Cards guide.
NoteManaging multiple cards through the Wallet Partners Portal can be challenging. Samsung offers Server APIs to simplify the process, enabling you to create and modify Samsung Wallet card templates efficiently, without relying on the portal. Explore the following blog topic for detailed insights: Create Samsung Wallet Card Templates Using the Server API. Gift card specifications
Before generating the Card Data token for the ‘Add to Samsung Wallet’ button, it’s essential to understand the structure of a sample gift card.
Every gift card in Samsung Wallet is built from a defined set of data fields that determine how the card looks and functions. These fields are part of the card’s JSON structure and control everything from how the card title appears to how barcode data is delivered when scanned.
The following examples illustrate how different card elements map to the gift card specifications. Each image highlights a specific group of parameters used when creating a gift card for Samsung Wallet.
Basic gift card information
This image illustrates the core elements that define the basic structure of a gift card in Samsung Wallet. It highlights the required fields—such as title, appLinkName, appLinkData, and appLinkLogo—which control the card’s main display name and linked actions. Optional parameters like bgImage enhance the visual design by allowing a custom background. Together, these specifications form the foundation of the card’s visible layout and branding.
This image demonstrates the specification fields that define the card’s balance, expiration date, and barcode data in Samsung Wallet.
This image illustrates how the barcode appears when the user taps the Pay button on the gift card. The displayed barcode corresponds to barcode.serialType, which specifies the presentation format (such as BARCODE or SERIALNUMBER). This configuration allows users to redeem their gift cards seamlessly by scanning the code at a merchant terminal.
This image demonstrates the use of the csInfo field to store customer support information. Telephone number, email address, and website address information can all be stored in it.
This image illustrates how the gift card’s display language adapts to the user's device language settings through the localization field. Localization allows the user to serve content in multiple languages. When a user sets their device to a specific language, the corresponding localized content is displayed on their device.
These specifications collectively define how your gift card appears and behaves in Samsung Wallet. For more detailed insights, check out the comprehensive Gift Card document.
Gift card JSON structure
Once you’ve reviewed the gift card specifications, the next step is to define them in the JSON structure. This data structure contains all the parameters that describe your gift card—including its title, amount, expiration date, barcode details, and optional links. The JSON is used to generate the Card Data token, which securely transfers the card information when users tap ‘Add to Samsung Wallet’.
The following is an example JSON file for a sample gift card:
{ "card": { "type": "giftcard", "subType": "others", "data": [ { "refId": {refId}, "createdAt": {createdAt}, "updatedAt": {updatedAt}, "language": "en", "attributes": { "title": "SAMPLE GIFT CARD", "eventId": "event-001", "logoImage": "https://djcpagh05u38x.cloudfront.net/wlt/kr/stg/IHGhULmHRiqfhI73YdQZcA/GhDKJ4z2Q5O23CwuXSupBg.png", "logoImage.darkUrl": "https://djcpagh05u38x.cloudfront.net/wlt/kr/stg/IHGhULmHRiqfhI73YdQZcA/zdzSwFKbTvuvAz35MSKmzw.png", "providerName": "Gift Card Provider name testing", "user": "John Smith", "csInfo": "{\"call\":\"(+82) 1588-3366\",\"website\":\"https://www.samsung.com/us/\"}", "appLinkLogo": "https://d3unf4s5rp9dfh.cloudfront.net/TANGO/03-11-2025-wallet-gift-card-applink-logo-image.png", "appLinkName": "Gift Card Link", "appLinkData": "https://developer.samsung.com/wallet", "bgImage": "https://d3unf4s5rp9dfh.cloudfront.net/TANGO/03-11-2025-wallet-gift-card-design-v2.png", "fontColor": "", "amount": "100P", "startDate": {startDate}, "endDate": {endDate}, "barcode.value": "SDC0102025", "barcode.serialType": "QRCODE", "barcode.ptFormat": "QRCODESERIAL", "barcode.ptSubFormat": "QR_CODE" }, "localization": [ { "language": "ko", "attributes": { "title": "삼성 월렛" } } ] } ] } } NoteIf you do not specify a fontColor value, it automatically adapts to your system settings. For instance, in dark mode, the font color is light, and in light mode, it is dark. Gift card testing with the ‘Add to Wallet’ test tool
You have created a gift card in the Wallet Partners Portal, now check if the card works properly before further development process. Follow these steps to check the card.
Sign in to the Add to Wallet test tool, navigate to the Playground section, select the gift card from the dropdown menu, and press Add to Samsung Wallet.
Navigate to the Add to Wallet menu on the Add to Wallet test tool site and follow the step-by-step guide provided in the Add to Samsung Wallet Test section in the Online Test Tool documentation.
‘Add to Samsung Wallet’ implementation
After testing the card with the ‘Add to Wallet’ test tool, you can let users add it directly to Samsung Wallet. Implement the ‘Add to Samsung Wallet’ button so that user can add the card to their wallet. For more details, refer to the Implementing ATW button documentation.
In the ‘Add to Samsung Wallet’ button implementation process, the generated JWT token expires after 30 seconds. As a result, you need to implement the server logic so that this token generates after the user interaction like pressing a button. See the Implementing "Add to Wallet" in an Android Application blog to get details on the server-side logic implementation process of an ‘Add to Samsung Wallet’ button in an Android application.
Conclusion
Bringing your gift cards to Samsung Wallet creates a secure, seamless, and branded experience for your users. By defining your card data, generating the token, and enabling the Add to Samsung Wallet flow, you make digital gifting effortless and engaging. Start integrating today and let users enjoy convenient, personalized gifting within Samsung Wallet.
Related resources
Utilize the Add to Samsung Wallet service for digital cards Introduce Loyalty Cards to Your Application with Samsung Wallet Implementing "Add to Wallet" in an Android Application Seamlessly Integrate "Add to Wallet" for Samsung Wallet View the full blog at its source
-
By Samsung Newsroom
SmartThings continues to invest in the Developer Center with tools for partners such as Test Suite, Product Cloning, and Certification by Similarity to simplify product integration and certification for a single product or an entire portfolio. After obtaining Works with SmartThings (WWST) certification, Analytics helps our partners gain valuable insights about how users interact with their products.
With the goal of making integration easy for partners, SmartThings added another tool in the integration process called the Device Profile Builder, allowing partners to specify a device’s capabilities and how it interacts within the SmartThings ecosystem.
“We’ve heard from developers that they wanted an easier way to build their devices with SmartThings. A tool with an intuitive user-friendly interface that would work for any device,” says Nate Porras, Senior Product Manager at SmartThings. “We feel like we accomplished that with Device Profile Builder.”
SmartThings currently offers Device Profile Builder for Cloud integrations and soon for Direct Connected and Mobile Connected integrations.
Read on to learn about Device Profile Builder and how to get started.
Device Profile Builder
SmartThings Device Profile Builder is a web-based tool that assists developers with creating Device Profiles, which define a device and its features on the SmartThings platform through Capabilities. It contains the Components—which is a group of SmartThings Capabilities—and metadata (ID, name, ownership, and more) of a device, defining how a device on the SmartThings platform behaves. For example, with a light, the component contains four common Capabilities for lights including Switch, Switch Level, Color Control, and Color Temperature.
Use Device Profile Builder to:
Define how you want your products to look to users in the SmartThings app
Set SmartThings Capabilities for each of your products
Get Started
How to use the SmartThings Device Profile Builder:
Visit the Products section in the SmartThings Certification Console where you can add a new product or edit an existing one. Under Integration Details / Device Capabilities, click Create a profile here. Or here is the direct link to the Device Profile Builder. Click the button Add new Device Profile and enter a unique name. Add your Capabilities and Components. You can also use product category specific templates to make the process faster. Use the Dashboard View to set how you want your product's icon, action, and state to look in the SmartThings App. Click Create Profile. After creating, you will have options to View, Publish, Edit, Clone, Download File, Upload file, and Delete under the Actions menu. Publish your Device Profile and use it to finish creating your product. Then submit your product to obtain the Works with SmartThings (WWST) certification. You can re-use a device profile for similar products or create as many variations as you need for your portfolio of products.
Use Device Profile Builder when Creating a Product
Below is the Create Product section in the Certification Console.
In this section, you can provide the product details displayed to users across the SmartThings ecosystem. Some of these include your product name, product image, and product description to help users identify your product. Plus you can add purchase link URLs so users can buy your product.
When creating a product in the Certification Console, you can use Device Profile Builder to add your device profiles. Under Integration Details / Device Capabilities, click Create a profile here or Edit an existing profile.
After finishing adding a product in the Certification Console, you can test it using Test Suite, and then go on to submit it for Works with SmartThings Certification (WWST).
Here are images from the Device Profile Builder. We’ll use the Capabilities for your devices as part of the Works with SmartThings certification.
Templates
Get started faster with Templates. Templates are prebuilt sets of required and suggested Capabilities for common product types that help you create your device profile effortlessly. Simply select a product type and apply it to your component.
Download / Upload File
For even more customization, you can use the Download / Upload File functions to modify the JSON file. If you have a more complex scenario you want to configure, this functionality gives visibility into all the fields. For example, this can be useful for certain devices that have specific preference thresholds or operating limits, which can be configured for normal or alarm states. There is also an ability for more granular control of what your device looks like in the SmartThings app.
Want to integrate your products with SmartThings? Visit our Developer Center to get started and access Device Profile Builder.
View the full blog at its source
-
By Samsung Newsroom
Samsung In-App Purchase (IAP) offers developers a robust solution for handling digital transactions within mobile applications available on Galaxy Store. Whether it is selling digital goods, handling subscriptions, or managing refunds, Samsung IAP is designed to offer a smooth, secure experience. The Samsung IAP Orders API expands the scope of these benefits. You can fetch all the payments and refunds history according to specified dates. This content guides you through the essential components for implementing both the Samsung IAP and Samsung IAP Orders APIs.
Figure 1: Sample Application UI In this tutorial, we provide a sample application called Book Spot, which offers users the option to subscribe to their favorite books and consumable items, such as text fonts, for purchase. After purchase, users can consume the item. Finally, developers can view all their payment and refund history on specific dates by calling the Samsung IAP Orders API from the back-end server.
Prerequisites
Before implementing in-app purchases in your app, do the following to enable a smooth and effective execution of the process while developing your own application:
Integrate the Samsung IAP SDK into your application. For more information about the IAP SDK integration, you can follow the Integration of Samsung IAP Services in Android Apps article. Upload the application for Beta testing on Samsung Galaxy Store. A step-by-step guide with screenshots has been provided in the documentation. For more details, see the section “Production Closed Beta Test” on the Test Guide. Finally, create items on the Seller Portal so that users can purchase or subscribe to them while using the application. For more details about the available items that the Seller Portal supports, see the Programming Guide. For the sample application, we have already completed these steps. Some example items were already created in Seller Portal, such as books and fonts so that you can consume and subscribe to them while using this sample application.
Implementation of Item Purchase
Now that the application and items are ready, you can implement the purchase functionality in your application like in the sample below:
When clicking "Buy," the startPayment() method is called, specifying parameters for item ID and the OnPaymentListener interface, which handles the results of the payment transaction. The onPayment() callback returns whether the purchase has succeeded or failed. The purchaseVo object is instantiated and in case it is not null, it holds the purchase results. If the purchase is successful, then it validates the purchase showing its ID. If the purchase is not successful, a purchaseError message is shown. For more information, check the Purchase an in-app item section. iapHelper.startPayment(itemId, String.valueOf(1), new OnPaymentListener() { @Override public void onPayment(@NonNull ErrorVo errorVo, @Nullable PurchaseVo purchaseVo) { if (purchaseVo != null) { // Purchase Successful Log.d("purchaseId" , purchaseVo.getPurchaseId().toString()); Toast.makeText(getApplicationContext() ,"Purchase Successfully", Toast.LENGTH_SHORT).show(); } else { Log.d("purchaseError" , errorVo.toString()); Toast.makeText(getApplicationContext() ,"Purchase Failed", Toast.LENGTH_SHORT).show(); } } }); Implementation of Item Consumption
After successfully purchasing an item, the user can then consume it. In the sample code below, when "Consumed" is selected, the consumePurchaseItems() triggers the consume functionality. This is necessary as items must be marked as consumed so they can be purchased again:
The consumePurchaseItems() method is called specifying the parameters for purchaseId and the OnConsumePurchasedItemsListener() interface, which handles the item data and results. This code also checks if consuming the purchased items succeeded or failed: If the errorVo parameter is not null and there is no error with the purchase, which can be verified with the IAP_ERROR_NONE response code, then the “Purchase Acknowledged” message is displayed. However, if there is an error, the errorVo parameter returns an error description with the getErrorString() getter, along with the “Acknowledgment Failed” message. iapHelper.consumePurchasedItems(purchaseId, new OnConsumePurchasedItemsListener() { @Override public void onConsumePurchasedItems(@NonNull ErrorVo errorVo, @NonNull ArrayList<ConsumeVo>arrayList) { if (errorVo != null && errorVo.getErrorCode() == iapHelper.IAP_ERROR_NONE) { Toast.makeText(getApplicationContext() ,"Purchase Acknowledged", Toast.LENGTH_SHORT).show(); } else { Toast.makeText(getApplicationContext(), "Acknowledgment Failed: " + errorVo.getErrorString(), Toast.LENGTH_SHORT).show(); } } }); Implementation of Item Subscription
Besides purchasing and consuming items, you can also subscribe to them in your applications. Similar to the validation done for the consumable item purchase, you validate the subscription with a purchase ID if the purchase is successful. Use the same code snippet specified for “Item Purchase.” For more information, check the Implementation of Item Purchase section.
Implementation of the Samsung IAP Orders API
The Samsung IAP Orders API is used to view all payments and refunds on a specific date. It does this by fetching the payments and refunds history within the date you specified. Let’s implement the Samsung IAP Orders API and create a server to listen to its notifications. Through server-to-server communication, the API returns all orders data for the application.
Configuring the Server
You can develop a Spring Boot server for this purpose. Here are the guidelines on how to set up this server:
Set up a Spring Boot Project. For more information, follow the steps on Developing Your First Spring Boot Application. Set up your server endpoint: Create a controller for the Samsung IAP Orders API in an integrated development environment (IDE) after importing the Spring Boot project you created. This helps managing all in-app order-related activities and processing them within your application.
The controller receives POST requests sent from Samsung’s IAP orders service ensuring the communication with your application.
Get Payment and Refund History
To view all payments and refunds:
You must make a POST request to the Samsung IAP Orders API endpoint with the required headers specified below. If you specify a date, all the payment history for this date is returned. Otherwise, it only returns all the data from the day before the current date. API Endpoint: https://devapi.samsungapps.com/iap/seller/orders
Method: POST
Headers:
Add the following fields to the request header. For more information, see the Create an Access Token page, which helps you understand how to create the access token in detail. The token is used for authorization. You can also get the Service Account ID by clicking the Assistance > API Service tabs on Seller Portal. For more details, read the section Create a service account and visit Seller Portal.
Header Name
Description
Required/Optional
Values
Content-Type
Format of the request body
Required
application/json
Authorization
Authorization security header
Required
Bearer: access_token
Service Account ID
This ID can be created in Seller Portal and is used to generate the JSON Web Token (JWT)
Required
service-account-id
Parameters:
The following parameters can be used to build your POST request.
Name
Type
Required/Optional
Description
sellerSeq
String
Required
Your seller deeplink, which is found in your profile in Seller Portal and consists of a 12-digit number.
packageName
String
Optional
Used to view payment and refund data. You can provide the application package name. When a package name is not specified, the data for all applications is shown.
requestDate
String
Optional
Specify a date from which to view the payment and refund data. If the date is not specified, the data from a day before your current date is returned.
continuationToken
String
Optional
Use this if you want to check if there is a continuation for the data on the next page. If there is no more data, the response is null.
To implement REST API support, add the following OkHttp library dependencies to your application's build.gradle file:
implementation 'com.squareup.okhttp3:okhttp: version' implementation 'com.google.code.gson:gson: version' A detailed description of the request items can be found in the Request section of the Samsung IAP Orders API documentation. For more information on the server communication, see Samsung IAP Server API. Here is a brief summary of the code below:
A POST request is mapped to the /orders URL, which logs the request. The previously described parameters containing the data you specified are formatted in a JSON body using the String.format() method. The outgoing request is logged in a JSON body format. A RequestBody is instantiated containing the JSON data, formatted for an HTTP request to be sent to the server with the specified token and Service Account ID. This code also handles multiple results your request can return: The onFailure() method is called when the network request fails for some reason, providing any error details using the IOException exception. If the request succeeds, the onResponse() method returns the response body or any response exception found. @RestController @RequestMapping(value = "/iap", method = RequestMethod.POST) public class OrdersController { private final OkHttpClient client = new OkHttpClient(); @GetMapping("/orders") public void sendToServer() { System.out.println("POST request received"); // Log the request // Define parameters values, use according to your requirement // String packageName = "com.example.app_name "; // String requestDate = "20240615"; // String continuationToken = "XXXXXXXXXXX…….XXXXXX"; String sellerSeq = "0000000XXXXX"; // Create the JSON body, use packageName, requestDate, continuationToken according to your requirement String jsonBody = String.format( "{\"sellerSeq\":\"%s\"}", sellerSeq ); // Create the request body RequestBody body = RequestBody.create(jsonBody, MediaType.parse("application/json; charset=utf-8")); // Access token String token = "0DjT9yzrYUKDoGbVUlXXXXXX"; // Build the request Request request = new Request.Builder() .url("https://devapi.samsungapps.com/iap/seller/orders") .post(body) .addHeader("Authorization","Bearer " + token) .addHeader("service-account-id", "85412253-21b2-4d84-8ff5-XXXXXXXXXXXX") .addHeader("content-type", "application/json") .build(); client.newCall(request).enqueue(new Callback() { @Override public void onFailure(@NotNull Call call, @NotNull IOException e) { System.err.println("Request failed: " + e.getMessage()); } @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { if (response.isSuccessful()) { String responseBody = response.body().string(); System.out.println("Response: " + responseBody); } else { System.err.println("Unexpected response code: " + response.code()); System.err.println("Response body: " + response.body().string()); } response.close(); // Close the response body } }); } } Congratulations! You have just built the Spring Boot server to handle API POST requests using the OkHttpClient to manage HTTP requests and responses for your sample application.
Example Response
As previously mentioned, a JSON-formatted response is returned to your request. For detailed descriptions of each response body element, see the “Response” section of the Samsung IAP Orders API documentation. The following output format is a sample in which only some of the response-body data is presented.
In this case, the continuationToken parameter key returns null because there is no continuation for the data on the next page. The orderItemList parameter key lists all the orders with specific details, such as orderId, countryId, packageName, among others. { "continuationToken": null, "orderItemList": [ { "orderId": "S20230210KR019XXXXX", "purchaseId": "a778b928b32ed0871958e8bcfb757e54f0bc894fa8df7dd8dbb553cxxxxxxxx", "contentId": "000005059XXX", "countryId": "USA", "packageName": "com.abc.xyz" }, { "orderId": "S20230210KR019XXXXX", "purchaseId": "90a5df78f7815623eb34f567eb0413fb0209bb04dad1367d7877edxxxxxxxx", "contentId": "000005059XXX", "countryId": "USA", "packageName": "com.abc.xyz" }, ] } Usually, the responses contain all the relevant information about user purchases, such as the in-app item title, price, and payment status. Therefore, you can use the information and create views for an easier order management.
NoteIf the IAP operating mode is configured to test mode, the API response is empty. This is because the API is configured to operate and return a response only in production mode. Conclusion
You have learned how to implement item purchase, consumption, and registration, as well as how to integrate the Samsung IAP Orders API and configure a server to fetch all the payment and refund history within specific dates.
Integrating the Samsung IAP Orders API functionality into your server is an essential step in managing your application payments history to ensure a seamless experience to users. Now, you can implement the Samsung IAP Orders API into your application to track all payments, refunds and make your business more manageable.
Related Resources
For additional information on this topic, see the resources below:
Download the Android Sample Application Source Code Add Samsung In-App Purchase service to your app Samsung IAP Orders API Integration of Samsung IAP Services in Android Apps View the full blog at its source
-
-
-
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.