Samsung In-App Purchase (IAP) for Galaxy Watch is a Galaxy Store service that allows third-party watch applications to sell in-app items.
IAP for Galaxy Watch only works if your Galaxy Watch is paired with your phone. The IAP Client for watch communicates with the IAP Client for phone which internally manages communication with supporting IAP services and the Samsung ecosystem (such as Samsung Account, Samsung Checkout, and Samsung Rewards). In other words, it acts as an intermediary between watch app and Samsung IAP system of the phone.
You can concentrate on integrating IAP API calls and IAP Server API calls into your watch app.
To integrate IAP for Galaxy Watch :
By integrating IAP features, your watch apps can sell these types of in-app items:
During IAP integration testing, if your application sets to TEST mode, the purchase record is initialized every 60 minutes to allow repurchase.
TEST
During IAP integration testing, if your application is set to TEST mode, the subscription cycle is automatically renewed every 10 minutes and the subscription is automatically canceled after 12 renewals.
This section explains how to prepare your app to sell in-app items using Tizen Extension SDK. You can use Galaxy Watch Studio to make a watch face that prompts for payment after a free trial period, without the complexity of coding.
To prepare for integrating IAP features and testing the integration, do the following.
Create a project in Tizen Studio. The required_version must be at least 2.3.2 in the config.xml file:
required_version
<?xml version="1.0" encoding="UTF-8"?> <widget xmlns:tizen="http://tizen.org/ns/widgets" xmlns="http://www.w3.org/ns/widgets" id="http://yourdomain/webiap" version="1.0.6" viewmodes="maximized"> <tizen:application id="wxwMXRceLO.webiap" package="wxwMXRceLO" required_version="4.0.0"/> </widget>
<tizen:privilege name="http://tizen.org/privilege/billing"/>
During IAP integration, you may need to test IAP features. Samsung IAP needs information about your app and in-app items registered in Seller Portal.
Your app does not need to have IAP features integrated in order to register the app and its in-app items. As IAP integration proceeds, you can upload new versions of your app and new in-app items as needed.
Sign in to Seller Portal (https://seller.samsungapps.com) using your Samsung account.
Click Add New Application
Click Galaxy Watch, select the default language, and click Next.
In the Binary tab, upload your app TPK.
In the App Information tab, enter fundamental app details.
In the Country / Region & Price tab, specify a free or paid app, a paid app price, and countries to sell your items.
In the In App Purchase tab, register one or more in-app items
Don't click *Submit Beta Test * or *Submit * in this step.
For more app registration details, see the App Registration Guide.
For more in-app item registration details, see the Item Registration Guide.
Get in-app items available for purhcase
Purchase an in-app item
Get a list of purchased items
IAP supports three operational modes. One is for enabling billing for item purchases and the other two are for testing IAP functions without billing app users for item purchases.
The Tizen emulator only supports these two modes: IAP_SUCCESS_TEST_MODE IAP_FAILURE_TEST_MODE If you set the mode to IAP_COMMERCIAL_MODE, it is automatically changed to IAP_SUCCESS_TEST_MODE.
IAP_SUCCESS_TEST_MODE
IAP_FAILURE_TEST_MODE
IAP_COMMERCIAL_MODE
To get all registered in-app items from Galaxy Store, use the getItemList() method.
getItemList()
Pass in the index of the first and last item, the item type, service mode, callback function, and user data as parameters.
When the reply is delivered, the GetItemSuccessCallback or ErrorCallback callback is invoked with the JsonObject that stores the query results.
GetItemSuccessCallback
ErrorCallback
JsonObject
For details, see the getItemList()
void getItemList(long startNumber, long endNumber, ItemType type, IAPMode mode, GetItemSuccessCallback successCallback, optional ErrorCallback? errorCallback);
[Callback=FunctionOnly, NoInterfaceObject] interface GetItemSuccessCallback { void onsuccess(JsonObject result); }; [Callback=FunctionOnly, NoInterfaceObject] interface ErrorCallback { void onerror (WebAPIError error); };
Request the available items, and retrieve the item details in the reply callback:
webapis.inapppurchase.getItemList(1, 15, "CONSUMABLE", "IAP_COMMERCIAL_MODE",successCallback, errorCallback);
/* Success callback */ function successCallback(result) { if (result._items.length == 0) { console.log("No item"); } else { for (var i = 0; i < result._items.length; i++) { console.log("Item ID: " + result._items[i].mItemId); console.log("Item Name: " + result._items[i].mItemName); console.log("Item Price: " + result._items[i].mItemPrice); } } } /* Error callback */ function errorCallback(error) { /* Error handling */ }
To purchase items from Galaxy Store, use the startPayment() method.
startPayment()
Pass in the index of the item ID, service mode, callback function, and user data as parameters.
When the reply is delivered, the PaymentSuccessCallback or ErrorCallback callback is invoked with the JsonObject that stores the query results.
PaymentSuccessCallback
For details, see the startPayment()
void startPayment(DOMString itemId, IAPMode mode, PaymentSuccessCallback successCallback, optional ErrorCallback? errorCallback);
[Callback=FunctionOnly, NoInterfaceObject] interface PaymentSuccessCallback { void onsuccess(JsonObject item); }; [Callback=FunctionOnly, NoInterfaceObject] interface ErrorCallback { void onerror (WebAPIError error); };
webapis.inapppurchase.startPayment("item_id", "IAP_COMMERCIAL_MODE", successCallback, errorCallback);
/* Success callback */ function successCallback(item) { console.log("Item ID: " + item.mItemId); console.log("Item Name: " + item.mItemName); console.log("Item Price: " + item.mItemPrice); } /* Error callback */ function errorCallback(error) { /* Error handling */ }
To get all purchased items from Galaxy Stroe, use the getPurchasedItemList() or getPurchasedItemListByIds() method:
getPurchasedItemList()
getPurchasedItemListByIds()
For details, see the getPurchasedItemList() and getPurchasedItemListByIds()
void getPurchasedItemList(long startNumber, long endNumber, TZDate startDate, TZDate endDate, GetItemSuccessCallback successCallback, optional ErrorCallback? errorCallback)
void getPurchasedItemListByIds(DOMString[] itemIds, GetItemSuccessCallback successCallback, optional ErrorCallback? errorCallback)
webapis.inapppurchase.getPurchasedItemList(1, 10, new tizen.TZDate(2020, 01, 01), new tizen.TZDate(2022, 12,31), successCallback, errorCallback);
// item IDs can be obtained by seperating the values returned by the getItemList() with comma(,). webapis.inapppurchase.getPurchasedItemListByIds("item1,item2,item3", successCallback, errorCallback);
During the IAP process, various errors can occur, for example, due to an unstable network, connection error, invalid account, or invalid product.
If an error occurs, your application receives the WebAPIError error type in the ErrorCallback callback. Handle all errors appropriately.
WebAPIError
This server API enables your server and client app to verify that a specified in-app item purchase and payment transaction were successfully completed. The API returns a JSON object with a successful status and details about a successful transaction and the item or with a failure status. This API can help to prevent malicious purchases and ensure that purchase and payment transactions were successful when the client app experiences network interruptions after an item purchase and payment transaction.
https://iap.samsungapps.com/iap/appsItemVerifyIAPReceipt.as?protocolVersion=2.0&purchaseID={purchaseID}
purchaseID
PaymentSuccessCallback()
mPurchaseId
Response parameters may be added, changed, and deleted.
Success
{ "itemId" : "item01", "paymentId":"ZPMTID20131122GBI0015292", "orderId": "S20200106KRA1908790", "itemName":"Test Pack", "itemDesc":"IAP Test Item. Best value!", "purchaseDate":"2020-11-22 04:22:36", "paymentAmount":"9.000", "status":"true", "paymentMethod":"Credit Card", "mode":"REAL", }
Fail
{ "status":"false" }
Besides verifying a purchase, Samsung IAP Server API also obtains service token information and gets detailed information of Auto Recurring Subscription (ARS) item purchase.
After IAP integration, you must check the operation mode before submitting the app. If you submit the app with IAP_SUCCESS_TEST_MODE, the users will get all the items for free. So, before beta release or normal publication, confirm if the operation mode is IAP_COMMERCIAL_MODE.
When you have created an app version that is ready for review testing and normal publication, register the app and its in-app item, and then click Submit.
For more details, see the App Registration Guide.