Native
native iap for galaxy watch 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 the watch app and samsung iap phone system you can concentrate on integrating iap api calls and iap server api calls into your watch app to integrate iap for galaxy watch using tizen extension sdk, iap native apis enables you to easily integrate iap functionality into your watch app, such as configuring iaps, getting item details, offering and selling items, and managing purchased items using galaxy watch studio formerly galaxy watch designer , you can make your own watch face that prompts for payment after a free trial period, without the complexity of coding for more details, see the galaxy watch studio online tutorial by integrating iap features, your watch apps can sell these types of in-app items item type description consumable app users can use items only one time for example, coins, special powers, or gems nonconsumable app users can use items any number of times for example, e-books or game boards items cannot be repurchased noteduring iap integration testing, if your application is set to test mode, the purchase record is initialized every 60 minutes to allow repurchase autorecurring subscription these items are purchased automatically at specific intervals app users can access items such as magazines, e-zines, or newspapers any number of times during a free trial or while their paid subscriptions are active app users can cancel at any time after purchase during subscription period app users can repurchase items after cancellation noteduring 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 integrate iap into your watch app 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 see the galaxy watch studio online tutorial for more information to prepare for integrating iap features and testing the integration, perform the following steps 1 create a project create a project in tizen studio the application api version must be at least 2 3 2 in the tizen-manifest xml file <?xml version="1 0" encoding="utf-8" standalone="no"?> <manifest xmlns="http //tizen org/ns/packages" api-version="4 0 0" package="org tizen nativeiap" version="1 0 0"> </manifest> 2 add permissions to tizen-manifest xml <privileges> <privilege>http //tizen org/privilege/billing</privilege> </privileges> 3 register app and in-app items in seller portal 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 noteyour 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 to register an app and its in-app items 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 cautiondon't click *submit beta test * or *submit * in this step 4 integrate iap features #include <iap-galaxyapps h> get in-app items available for purchase purchase an in-app item get a list of purchased items operation mode 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 mode description iap_galaxyapps_commercial_mode financial transactions do occur for successful requests, and actual results are returned successful or failed the app gets in-app item information of the app whose status in seller portal is for sale iap_galaxyapps_success_test_mode financial transactions do not occur app users are not billed for item purchases , and successful results are always returned the app gets in-app item information of the app whose status in seller portal is registering or updating iap_galaxyapps_failure_test_mode all iap requests fail negative testing to ensure that your app can handle errors such as improper input and user actions notethe tizen emulator only supports these two modes iap_galaxyapps_success_test_mode iap_galaxyapps_failure_test_mode if you set the mode to iap_galaxyapps_commercial_mode, it is automatically changed to iap_galaxyapps_success_test_mode get in-app items available for purchase to get all registered in-app items from galaxy store, use the iap_galaxyapps_get_item_list method 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 iap_galaxyapps_reply_cb callback is invoked with the iap_galaxyapps_h object that stores the query results to get the request result from the iap_galaxyapps_h object, use the iap_galaxyapps_get_value method if the request was successful, you can get all the item details from the iap_galaxyapps_h object using the iap_galaxyapps_foreach_item_info method request for details, see the iap_galaxyapps_get_item_list int iap_galaxyapps_get_item_list int start_number, int end_number, const char *item_type, iap_galaxyapps_mode_e mode, iap_galaxyapps_reply_cb reply_cb, void *user_data response typedef void * iap_galaxyapps_reply_cb iap_galaxyapps_h reply, iap_galaxyapps_error_e result, void *user_data common result key value type description merrorcode int error code number merrorstring string error message mextrastring string extra result mstartnumber int index of the first item on the list mendnumber int index of the last item on the list mtotalcount int total number of items based on the first and last item index item details key value type description mitemid string item id numberthis is the same as the item id used in the request mitemname string name provided during the item registration in the seller portal mitemprice string item price in a local currency mitempricestring string currency code + pricefor example €7 99 mcurrencyunit string device user currency unit for example $, won, or pound mcurrencycode string currency codefor example eur or gbp mitemdesc string item description provided during the item registration mitemimageurl string item image url provided during the item registration mitemdownloadurl string item download url provided during the item registration mtype string item type 00 consumable01 non-consumable02 non-recurring subscription03 auto-recurring subscription 10 all msubscriptiondurationunit string subscription duration unit, defined as an upper case string month msubscriptiondurationmultiplier string if the item type mtype is 02 or 03, this is the item duration combined with msubscriptiondurationunit, it expresses the subscription duration, for example, 1month mjsonstring string original json string code snippet to handle the request output data, define a structure for it struct output_data { char* merrorcode; char* merrorstring; char* mextrastring; char* mstartnumber; char* mendnumber; char* mtotalcount; char* mitemid; char* mitemname; char* mitemprice; char* mitempricestring; char* mcurrencyunit; char* mcurrencycode; char* mitemdesc; char* mitemimageurl; char* mitemdownloadurl; char* mpaymentid; char* mpurchaseid; char* mpurchasedate; char* mverifyurl; char* mtype; char* msubscriptiondurationunit; char* msubscriptiondurationmultiplier; char* msubscriptionenddate; char* mjsonstring; }; typedef struct output_data_s; request the available items, and retrieve the item details in the reply callback /* request the available item list */ int ret = iap_galaxyapps_get_item_list 1, 10, "10", iap_galaxyapps_commercial_mode, __get_item_list_cb, null ; if ret != iap_galaxyapps_error_none { /* error handling */ return; } static bool __foreach_item iap_galaxyapps_h handle, void *user_data { output_data value = {0,}; /* get item properties */ iap_galaxyapps_get_value handle, "mitemid", &value mitemid ; iap_galaxyapps_get_value handle, "mitemname", &value mitemname ; iap_galaxyapps_get_value handle, "mitempricestring", &value mitempricestring ; iap_galaxyapps_get_value handle, "mitemdesc", &value mitemdesc ; /* handle properties */ return true; } /* callback */ static void __get_item_list_cb iap_galaxyapps_h reply, iap_galaxyapps_error_e result, void *user_data { if result != iap_galaxyapps_error_none { char *merrorstring = null; iap_galaxyapps_get_value reply, "merrorstring", &merrorstring ; /* error handling */ return; } /* retrieve all items contained in the handle */ int ret = iap_galaxyapps_foreach_item_info reply, __foreach_item, null ; if ret != iap_galaxyapps_error_none { /* error handling */ return; } return; } purchase an in-app item to purchase items from galaxy store, use the iap_galaxyapps_start_payment method pass in the index of the item id, service mode, callback function, and user data as parameters when the reply is delivered, the iap_galaxyapps_reply_cb callback is invoked with the iap_galaxyapps_h object that stores the query results to get both the request result and the purchased item details from the iap_galaxyapps_h object, use the iap_galaxyapps_get_value method request for details, see the iap_galaxyapps_start_payment int iap_galaxyapps_start_payment const char *item_id, iap_galaxyapps_mode_e mode, iap_galaxyapps_reply_cb reply_cb, void *user_data response typedef void * iap_galaxyapps_reply_cb iap_galaxyapps_h reply, iap_galaxyapps_error_e result, void *user_data common result key value type description merrorcode int error code number merrorstring string error message mextrastring string extra result purchased item details key value type description mitemid string item id numberthis is the same as the item id used in the request mitemname string name provided during the item registration in the seller office mitemprice double item price in a local currency mitempricestring string currency code + pricefor example €7 99 mcurrencyunit string device user currency unitfor example $, won, or pound mcurrencycode string currency codefor example eur or gbp mitemdesc string item description provided during the item registration mitemimageurl string item image url provided during the item registration mitemdownloadurl string item download url provided during the item registration mpaymentid string id of the payment mpurchaseid string purchase ticket id used to verify the purchase with the store iap server mpurchasedate string date of purchasefor example "2020-11-15 10 31 23" mverifyurl string server's url, which can be used in combination with other parameters to verify the purchase with the iap server mjsonstring string original json string code snippet /* purchase an item */ int ret = iap_galaxyapps_start_payment "item_id", iap_galaxyapps_commercial_mode, __purchase_cb, null ; if ret != iap_galaxyapps_error_none { /* error handling */ return; } /* callback */ static void __purchase_cb iap_galaxyapps_h reply, iap_galaxyapps_error_e result, void *user_data { output_data value = {0,}; if result != iap_galaxyapps_error_none { iap_galaxyapps_get_value reply, "merrorstring", &value merrorstring ; /* error handling */ return; } /* get properties of the purchased item */ iap_galaxyapps_get_value reply, "mitemid", &value mitemid ; iap_galaxyapps_get_value reply, "mitemname", &value mitemname ; iap_galaxyapps_get_value reply, "mitempricestring", &value mitempricestring ; iap_galaxyapps_get_value reply, "mitemdesc", &value mitemdesc ; /* handle properties */ return; } get a list of purchased items to get a list of all items purchased from galaxy store, use the iap_galaxyapps_get_purchased_item_list or iap_galaxyapps_get_purchased_item_list_by_item_ids method for iap_galaxyapps_get_purchased_item_list , pass in the index of the first and last item, the item type, the start and end date, the callback function, and user data as parameters for iap_galaxyapps_get_purchased_item_list_by_item_ids , pass in the item ids separated by comma , , the callback function, and user data as parameters when the reply is delivered, the iap_galaxyapps_reply_cb callback is invoked with the iap_galaxyapps_h object that stores the query results to get the request result from the iap_galaxyapps_h object, use the iap_galaxyapps_get_value method if the request was successful, you can get all the item details from the iap_galaxyapps_h object using the iap_galaxyapps_foreach_item_info method request for details, see the iap_galaxyapps_get_purchased_item_list and iap_galaxyapps_get_purchased_item_list_by_item_ids int iap_galaxyapps_get_purchased_item_list int start_number, int end_number, const char *start_date, const char *end_date, iap_galaxyapps_reply_cb reply_cb, void *user_data int iap_galaxyapps_get_purchased_item_list_by_item_ids const char *item_ids, iap_galaxyapps_reply_cb reply_cb, void *user_data response typedef void * iap_galaxyapps_reply_cb iap_galaxyapps_h reply, iap_galaxyapps_error_e result, void *user_data common result key value type description merrorcode int error code number merrorstring string error message mextrastring string extra result mstartnumber int index of the first item on the list mendnumber int index of the last item on the list mtotalcount int total number of items based on the first and last item index purchased item details key value type description mitemid string item id numberthis is the same as the item id used in the request mitemname string name provided during the item registration in the seller portal mitemprice string item price in a local currency mitempricestring string currency code + price mcurrencyunit string device user currency unit mcurrencycode string currency code mitemdesc string item description provided during the item registration mitemimageurl string item image url provided during the item registration mitemdownloadurl string item download url provided during item registration mtype string item type 00 consumable01 nonconsumable02 nonrecurring subscription03 autorecurring subscription10 all mpaymentid string id of the payment mpurchaseid string id of the purchase mpurchasedate string date of purchasefor example "2020-11-15 10 31 23" msubscriptionenddate string if the item type mtype is 02 or 03, this is the due date mjsonstring string original json string code snippet int ret = iap_galaxyapps_get_purchased_item_list 1, 10, "20200101", "20221231", __get_purchased_item_list_cb, null ; if ret != iap_galaxyapps_error_none { /* error handling */ return; } // item ids can be obtained by seperating the values returned by the iap_galaxyapps_get_item_list with comma , int ret = iap_galaxyapps_get_purchased_item_list_by_item_ids "item1,item2,item3", __get_purchased_item_list_cb, null ; if ret != iap_galaxyapps_error_none { /* error handling */ return; } static bool __foreach_purchased_item iap_galaxyapps_h handle, void *user_data { output_data value = {0,}; /* get properties of the item */ iap_galaxyapps_get_value handle, "mitemid", &value mitemid ; iap_galaxyapps_get_value handle, "mitemname", &value mitemname ; iap_galaxyapps_get_value handle, "mitempricestring", &value mitempricestring ; iap_galaxyapps_get_value handle, "mitemdesc", &value mitemdesc ; /* handle properties */ return true; } /* callback */ static void __get_purchased_item_list_cb iap_galaxyapps_h reply, iap_galaxyapps_error_e result, void *user_data { if result != iap_galaxyapps_error_none { char *merrorstring = null; iap_galaxyapps_get_value reply, "merrorstring", &merrorstring ; /* error handling */ return; } /* retrieve all items contained in the handle */ int ret = iap_galaxyapps_foreach_item_info reply, __foreach_purchased_item, null ; if ret != iap_galaxyapps_error_none { /* error handling */ return; } return; } handling errors 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 iap_galaxyapps_error_e error type in the iap_galaxyapps_reply_cb callback handle all errors appropriately error code error code description iap_galaxyapps_error_none successful iap_galaxyapps_error_payment_is_canceled payment canceled iap_galaxyapps_error_network_not_available network is not available iap_galaxyapps_error_io_error ioexception iap_galaxyapps_error_timed_out timeout exception iap_galaxyapps_error_initialization failure during iap initialization iap_galaxyapps_error_need_app_upgrade samsung iap upgrade is required iap_galaxyapps_error_common error while running iap iap_galaxyapps_error_already_purchased error when a non-consumable product is repurchased or a subscription product is repurchased before the product expiration date iap_galaxyapps_error_request_payment_without_info error when payment is requested without bundle information iap_galaxyapps_error_product_does_not_exist error when the requested item list is not available iap_galaxyapps_error_confirm_inbox the payment result is not received after requesting payment from the server, and the purchased item list is not confirmed iap_galaxyapps_error_not_exist_local_price the item is not for sale in the country iap_galaxyapps_error_not_available_shop iap is not supported in the country iap_galaxyapps_error_invalid_parameter invalid parameter iap_galaxyapps_error_key_not_found specified key is not found iap_galaxyapps_error_not_supported_device the device does not support iap iap_galaxyapps_error_out_of_memory out of memory iap_galaxyapps_error_permission_denied permission denied verify a purchase 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 request https //iap samsungapps com/iap/appsitemverifyiapreceipt as?protocolversion=2 0&purchaseid={purchaseid} the purchaseid is assigned by samsung iap your app receives it in the iap_galaxyapps_h object as response of iap_galaxyapps_start_payment and the key is mpurchaseid response noteresponse 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" } notebesides verifying a purchase, samsung iap server api also obtains service token information and gets detailed information of an autorecurring subscription item purchase submit the app to galaxy store 1 check the operation mode after iap integration, you must check the operation mode before submitting the app if you submit the app with iap_galaxyapps_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_galaxyapps_commercial_mode 2 submit the app 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