billing api to use samsung product api, <script type="text/javascript" src="$webapis/webapis/webapis js"></script> should be loaded in index html this module defines the billing samsung checkout functionalities provided by the tizen samsung product api since 2 4 product tv privilege level public privilege http //developer samsung com/privilege/billing summary of interfaces and methods interface method billingmanagerobject billingmanager void buyitem domstring appid, tvservertype servertype, domstring paymentdetails, billingbuydatasuccesscallback onsuccess, optional errorcallback? onerror ;void getproductslist domstring appid, domstring countrycode, domstring pagesize, domstring pagenumber, domstring checkvalue, tvservertype servertype, billingproductslistcallback onsuccess, optional errorcallback? onerror ;void applyinvoice domstring appid, domstring customid, domstring invoiceid, domstring countrycode, tvservertype servertype, billingapplyinvoicecallback onsuccess, optional errorcallback? onerror ;void verifyinvoice domstring appid, domstring customid, domstring invoiceid, domstring countrycode, tvservertype servertype, billingverifyinvoicecallback onsuccess, optional errorcallback? onerror ;void getservicecountryavailability domstring appid, domstring[] countrycodes, domstring checkvalue, tvservertype servertype, billinggetservicecountryavailabilitycallback onsuccess, optional errorcallback? onerror ;void getuserpurchaselist domstring appid, domstring customid, domstring countrycode, domstring pagenumber, domstring checkvalue, tvservertype servertype, billinggetuserpurchaselistcallback onsuccess, optional errorcallback? onerror ;void cancelsubscription domstring appid, domstring invoiceid, domstring customid, domstring countrycode, tvservertype servertype, billingcancelsubscriptioncallback onsuccess, optional errorcallback? onerror ;void isserviceavailable tvservertype servertype, billingisserviceavailablecallback onsuccess, optional errorcallback? onerror ;domstring getversion ; billingbuydatasuccesscallback void onsuccess billingbuydata data ; billingbuydata billingproductslistcallback void onsuccess productslistdata data ; billingapplyinvoicecallback void onsuccess applyinvoicedata data ; billingverifyinvoicecallback void onsuccess verifyinvoicedata data ; billinggetuserpurchaselistcallback void onsuccess userpurchasedata data ; billinggetservicecountryavailabilitycallback void onsuccess servicecountryavailabilitydata data ; billingcancelsubscriptioncallback void onsuccess cancelsubscriptiondata data ; billingisserviceavailablecallback void onsuccess serviceavailabledata data ; 1 type definitions 1 1 tvservertype specifies billing server types enum tvservertype { "dev", "prd" }; the following values are supported dev staging server prd operating server 1 2 historytype specifies product types for the purchase history enum historytype { "all", "subscription", "non-subscription" }; the following values are supported all all product types this type is not supported since 2019 product subscription subscription products only non-subscription non-subscription products only 1 3 productslistdata defines a dictionary for product list data returned by the getproductslist api dictionary productslistdata { domstring apiresult; }; the following values are supported apiresult getproductslist api result dictionary in json format this value is json string type data, so please use it by json parsing after you parse this value, you can use it in productslistapiresult format at the below 1 4 productslistapiresult defines a dictionary for the productslistdata dictionary apiresult parameter dictionary productslistapiresult { domstring cpstatus; domstring? cpresult; long totalcount; domstring checkvalue; itemdetails[]? itemdetails; }; the following values are supported cpstatus dpi result code returns "100000" on success and other codes on failure cpresult [optional] optional additional message "eof" last page of the product list "hasnext true" product list has further pages other error message, depending on the dpi result code totalcount total number of invoices checkvalue security check value itemdetails [optional] optional dictionary in json format 1 5 itemdetails defines a dictionary for the productslistapiresult dictionary 'itemdetails' parameter dictionary itemdetails { long seq; domstring itemid; domstring itemtitle; long itemtype; long? period; long price; domstring currencyid; productsubscriptioninfo? subscriptioninfo; }; the following values are supported seq sequence number 1 ~ totalcount itemid product id itemtitle product name itemtype product type "1" consumable "2" non-consumable "3" limited-period "4" subscription period [optional] limited period product duration, in minutes price product price, in "xxxx yy" format currencyid currency code subscriptioninfo [optional] subscription information mandatory for subscription products 1 6 productsubscriptioninfo defines a dictionary for the itemdetails dictionary 'subscriptioninfo' parameter dictionary productsubscriptioninfo { domstring paymentcycleperiod; long paymentcyclefrq; long paymentcycle; }; the following values are supported paymentcycleperiod subscription payment period "d" days "w" weeks "m" months paymentcyclefrq payment cycle frequency paymentcycle number of payment cycles 1 7 applyinvoicedata defines a dictionary for data returned by the applyinvoice api dictionary applyinvoicedata { domstring apiresult; }; the following values are supported apiresult applyinvoice api result dictionary in json format this value is json string type data, so please use it by json parsing after you parse this value, you can use it in applyinvoiceapiresult format at the below 1 8 applyinvoiceapiresult defines a dictionary for the applyinvoicedata dictionary 'apiresult' parameter dictionary applyinvoiceapiresult { domstring cpstatus; domstring? cpresult; domstring appliedtime; }; the following values are supported cpstatus dpi result code returns "100000" on success and other codes on failure cpresult [optional] optional additional message "success" other error message, depending on the dpi result code appliedtime time product applied, in 14-digit utc time 1 9 verifyinvoicedata defines a dictionary for data returned by the verifyinvoice api dictionary verifyinvoicedata { domstring apiresult; }; the following values are supported apiresult verifyinvoice api result dictionary in json format this value is json string type data, so please use it by json parsing after you parse this value, you can use it in verifyinvoiceapiresult format at the below 1 10 verifyinvoiceapiresult defines a dictionary for the verifyinvoicedata dictionary 'apiresult' parameter dictionary verifyinvoiceapiresult { domstring cpstatus; domstring? cpresult; domstring appid; domstring invoiceid; }; the following values are supported cpstatus dpi result code returns "100000" on success and other codes on failure cpresult [optional] optional additional message "success" other error message, depending on the dpi result code appid application id invoiceid invoice id that you want to verify whether a purchase was successful 1 11 userpurchasedata defines a dictionary for data returned by the getuserpurchaselist api dictionary userpurchasedata { domstring apiresult; }; the following values are supported apiresult getuserpurchaselist api result dictionary in json format this value is json string type data, so please use it by json parsing after you parse this value, you can use it in getuserpurchaselistapiresult format at the below 1 12 getuserpurchaselistapiresult defines a dictionary for the userpurchasedata dictionary 'apiresult' parameter dictionary getuserpurchaselistapiresult { domstring cpstatus; domstring? cpresult; long totalcount; domstring checkvalue; invoicedetails[]? invoicedetails; }; the following values are supported cpstatus it returns "100000" in success, [errorcode] in failure refer to dpi error code cpresult [optional] optional additional message "eof" last page of the product list "hasnext true" product list has further pages other error message, depending on the dpi result code totalcount total number of invoices checkvalue security check value invoicedetails [optional] optional dictionary in json format 1 13 invoicedetails defines a dictionary for the getuserpurchaselistapiresult dictionary 'invoicedetails' parameter dictionary invoicedetails { long seq; domstring invoiceid; domstring itemid; domstring itemtitle; long itemtype; domstring ordertime; long? period; long price; domstring ordercurrencyid; boolean cancelstatus; boolean appliedstatus; domstring? appliedtime; domstring? limitendtime; domstring? remaintime; purchasesubscriptioninfo? subscriptioninfo; }; the following values are supported seq sequence number 1 ~ totalcount invoiceid invoice id of this purchase history itemid product id itemtitle product name itemtype product type "1" consumable "2" non-consumable "3" limited-period "4" subscription ordertime payment time, in 14-digit utc time period [optional] limited period product duration, in minutes price product price, in "xxxx yy" format ordercurrencyid currency code cancelstatus cancellation status "true" sale canceled "false" sale ongoing appliedstatus product application status "true" applied "false" not applied appliedtime [optional] time product applied, in 14-digit utc time limitendtime [optional] limited period product end time, in 14-digit utc time remaintime [optional] limited period product time remaining, in seconds subscriptioninfo [optional] subscription information mandatory for subscription products 1 14 purchasesubscriptioninfo defines a dictionary for the invoicedetails dictionary 'subscriptioninfo' parameter dictionary purchasesubscriptioninfo { domstring subscriptionid; domstring subsstarttime; domstring subsendtime; domstring subsstatus; }; the following values are supported subscriptionid id of subscription history subsstarttime subscription start time, in 14-digit utc time subsendtime subscription expiry time, in 14-digit utc time subsstatus subscription status "00" active "01" subscription expired "02" canceled by buyer "03" canceled for payment failure "04" canceled by cp "05" canceled by admin 1 15 servicecountryavailabilitydata defines a dictionary for data returned by the getservicecountryavailability api dictionary servicecountryavailabilitydata { domstring apiresult; }; the following values are supported apiresult getservicecountryavailability api result dictionary in json format this value is json string type data, so please use it by json parsing after you parse this value, you can use it in getuserpurchaselistapiresult format at the below 1 16 getservicecountryavailabilityapiresult defines a dictionary for the servicecountryavailabilitydata dictionary 'apiresult' parameter dictionary getservicecountryavailabilityapiresult { domstring cpstatus; domstring? cpresult; countries[]? countryavailability; }; the following values are supported cpstatus it returns "100000" in success, [errorcode] in failure refer to dpi error code cpresult [optional] returns "success" on success countryavailability [optional] list of countries with information of service availability 1 17 countries defines a dictionary for the getservicecountryavailabilityapiresult dictionary 'countryavailability' parameter dictionary countries { domstring countrycode; boolean isbillingsupported; }; the following values are supported countrycode countrycode to check service availability isbillingsupported status "true" service is available "false" service is not available 1 18 cancelsubscriptiondata defines a dictionary for subscription cancellation data returned by the cancelsubscription api dictionary cancelsubscriptiondata { domstring apiresult; }; the following values are supported apiresult cancelsubscription api result dictionary in json format this value is json string type data, so please use it by json parsing after you parse this value, you can use it in cancelsubscriptionapiresult format at the below 1 19 cancelsubscriptionapiresult defines a dictionary for the cancelsubscriptiondata dictionary apiresult parameter dictionary cancelsubscriptionapiresult { domstring cpstatus; domstring? cpresult; domstring invoiceid; domstring? subscanceltime; domstring? subsstatus; }; the following values are supported cpstatus dpi result code returns "100000" on success and other codes on failure cpresult [optional] optional additional message "success" other error message, depending on the dpi result code invoiceid invoice id of subscription that you want to cancel subscanceltime [optional] optional time subscription canceled, in 14-digit utc time subsstatus [optional] optional subscription status "00" active "01" subscription expired "02" canceled by buyer "03" canceled for payment failure "04" canceled by cp "05" canceled by admin 1 20 showregisterpromotionalcodedata this defines data set that is coming from showregisterpromotionalcode api dictionary showregisterpromotionalcodedata { domstring opendeeplinkresult; domstring opendeeplinkdetail; }; the following values are supported opendeeplinkresult it returns "success" in success, "fail" in failure opendeeplinkdetail it returns the detail information of coupon or gift card it is a dictionary in json format, so you have to parse it to use for more information, please refer to "promotionalcodedetail" at the below 1 21 promotionalcodedetail this defines data set of promotionalcodedetail parameter that contains showregisterpromotionalcodedata dictionary dictionary promotionalcodedetail { domstring appliedcouponcount; domstring[] appliedcouponlist; domstring registedbenefitcount; domstring[] registedbenefitlist; }; the following values are supported appliedcouponcount it returns the number of applied coupon count appliedcouponlist it returns the list of applied coupon registedbenefitcount it returns the number of benefit registedbenefitlist it returns the list of benefit code 1 22 showregistercreditcarddata this defines data set that is coming from showregistercreditcard api dictionary showregistercreditcarddata { domstring opendeeplinkresult; domstring? opendeeplinkdetail; }; the following values are supported opendeeplinkresult it returns "success" in success, "fail" in failure opendeeplinkdetail [optional] it is optional and not used now 1 23 showpurchasehistorydata this defines data set that is coming from showpurchaseshistory api dictionary showpurchasehistorydata { domstring opendeeplinkresult; domstring opendeeplinkdetail; }; the following values are supported opendeeplinkresult it returns "success" in success, "fail" in failure opendeeplinkdetail it returns the detail information of refund or cancel it is a dictionary in json format, so you have to parse it to use for more information, please refer to "purchasehistorydetail" at the below 1 24 purchasehistorydetail this defines data set of purchasehistorydetail parameter that contains showpurchasehistorydata dictionary dictionary purchasehistorydetail { domstring invoicerefundcount; domstring[] invoicerefundlist; domstring subscriptioncancelcount; domstring[] subscriptioncancellist; }; the following values are supported invoicerefundcount it returns the number of product that user make refunded invoicerefundlist it returns array that contains the list of refunded invoice id subscriptioncancelcount it returns the number of subscription product that user make cancelled subscriptioncancellist it returns array that contains the list of cancelled subscription 1 25 serviceavailabledata defines a dictionary for data returned by the isserviceavailable api dictionary serviceavailabledata { domstring apiresult; }; the following values are supported apiresult isserviceavailable api result dictionary in json format this value is json string type data, so please use it by json parsing after you parse this value, you can use it in serviceavailableapiresult format at the below 1 26 serviceavailableapiresult defines a dictionary for the serviceavailabledata dictionary 'apiresult' parameter dictionary serviceavailableapiresult { domstring status; domstring result; domstring serviceyn; }; the following values are supported status returns "100000" on success and other codes on failure result returns "success" on success serviceyn returns "y" if the service is available 2 interfaces 2 1 billingmanagerobject defines a webapi object instance of the tizen samsung product api the webapis billing object enables access to billing api functionality [nointerfaceobject] interface billingmanagerobject { readonly attribute billingmanager billing; }; webapi implements billingmanagerobject; since 2 4 attributes readonly billingmanager billing billing api namespace 2 2 billingmanager provides methods for billing functionalities [nointerfaceobject] interface billingmanager { void buyitem domstring appid, tvservertype servertype, domstring paymentdetails, billingbuydatasuccesscallback onsuccess, optional errorcallback? onerror ; void getproductslist domstring appid, domstring countrycode, domstring pagesize, domstring pagenumber, domstring checkvalue, tvservertype servertype, billingproductslistcallback onsuccess, optional errorcallback? onerror ; void applyinvoice domstring appid, domstring customid, domstring invoiceid, domstring countrycode, tvservertype servertype, billingapplyinvoicecallback onsuccess, optional errorcallback? onerror ; void verifyinvoice domstring appid, domstring customid, domstring invoiceid, domstring countrycode, tvservertype servertype, billingverifyinvoicecallback onsuccess, optional errorcallback? onerror ; void getservicecountryavailability domstring appid, domstring[] countrycodes, domstring checkvalue, tvservertype servertype, billinggetservicecountryavailabilitycallback onsuccess, optional errorcallback? onerror ; void getuserpurchaselist domstring appid, domstring customid, domstring countrycode, domstring pagenumber, domstring checkvalue, tvservertype servertype, billinggetuserpurchaselistcallback onsuccess, optional errorcallback? onerror ; void cancelsubscription domstring appid, domstring invoiceid, domstring customid, domstring countrycode, tvservertype servertype, billingcancelsubscriptioncallback onsuccess, optional errorcallback? onerror ; void isserviceavailable tvservertype servertype, billingisserviceavailablecallback onsuccess, optional errorcallback? onerror ; domstring getversion ; }; methods buyitem enables implementing the samsung checkout client module within the application after authenticating the purchase information through the application, the user can proceed to purchase payment void buyitem domstring appid, tvservertype servertype, domstring paymentdetails, billingbuydatasuccesscallback onsuccess, optional errorcallback? onerror ; product tv privilege level public privilege http //developer samsung com/privilege/billing parameters appid application id servertype billing server type paymentdetails payment parameters orderitemid[mandatory]/ordertitle[mandatory]/ordertotal[mandatory]/ordercurrencyid[mandatory]/orderid[optional]/ordercustomid[mandatory] onsuccess returns "payresult" and "paydetail" if there is no internal error occurs until client to server data communication payresult, can still contains error when billing server confirms that the given parameters does not have expected value or have problem while processing it paydetail, can have additional data when it's returned, such as invoiceid please refer to the development guide of "buyitem" for details onerror [optional][nullable] optional callback method to invoke if an internal error occurs before the client to server data communication securityerror, if the application does not have the privilege to call this method unknownerror, if other error occur, such as internal error or "billing client already running" error exceptions webapiexception with error type typemismatcherror, if any of input parameter is not compatible with its expected type with error type invalidvalueserror, if servertype contains an invalid value since 2 4 code example var strappid = ""; var struid = webapis sso getloginuid ; var paymentdetails = new object ; paymentdetails orderitemid="pid_2_consum_cupn"; paymentdetails ordertitle="hello consum us coupon"; paymentdetails ordertotal="2"; paymentdetails ordercurrencyid="usd"; paymentdetails ordercustomid=struid; var stringifyresult = json stringify paymentdetails ; var onsuccess = function data {}; var onerror = function error {}; webapis billing buyitem strappid, "dev", stringifyresult, onsuccess, onerror ; getproductslist retrieves the list of products registered on the billing dpi server void getproductslist domstring appid, domstring countrycode, domstring pagesize, domstring pagenumber, domstring checkvalue, tvservertype servertype, billingproductslistcallback onsuccess, optional errorcallback? onerror ; product tv privilege level public privilege http //developer samsung com/privilege/billing parameters appid application id countrycode tv country code pagesize number of products retrieved per page maximum 100 pagenumber requested page number 1 ~ n checkvalue security check value required parameters = "appid" + "countrycode" the check value is used by the dpi service to verify api requests it is a base64 hash generated by applying the hmac sha256 algorithm on a concatenated string of parameters using the dpi security key you can see the example how to generate checkvalue from the following code example you can use any open library to generate the hmac sha256 hash the following example uses the cryptojs library servertype billing server type onsuccess returns the product list if there is no internal error occurs until client to server data communication apiresult, can still contains error when billing server confirms that the given parameters does not have expected value or have problem while processing it when cpstatus value from apiresult is "100000", it means server communication is done properly and other values are valid in returns onerror [optional][nullable] optional callback method to invoke if an internal error occurs before the client to server data communication securityerror, if the application does not have the privilege to call this method unknownerror, if any other error occurs exceptions webapiexception with error type typemismatcherror, if any of input parameter is not compatible with its expected type with error type invalidvalueserror, if servertype contains an invalid value since 4 0 code example var strsecuritykey = ""; // the dpi security key is issued at the dpi portal var strappid = ""; var strcountrycode = webapis productinfo getsystemconfig webapis productinfo productinfoconfigkey config_key_service_country ; var reqparams = strappid + strcountrycode; var hash = cryptojs hmacsha256 reqparams, strsecuritykey ; var strcheckvalue = cryptojs enc base64 stringify hash ; var onsuccess = function data {}; var onerror = function error {}; webapis billing getproductslist strappid, strcountrycode, "100", "1", strcheckvalue, "dev", onsuccess, onerror ; applyinvoice updates the apply status of purchase item to dpi server void applyinvoice domstring appid, domstring customid, domstring invoiceid, domstring countrycode, tvservertype servertype, billingapplyinvoicecallback onsuccess, optional errorcallback? onerror ; product tv privilege level public privilege http //developer samsung com/privilege/billing parameters appid application id customid same value as "ordercustomid" parameter for the buyitem api samsung account uid invoiceid invoice id of purchased item that you want to update apply status countrycode tv country code servertype billing server type onsuccess returns purchase apply status if there is no internal error occurs until client to server data communication apiresult, can still contains error when billing server confirms that the given parameters does not have expected value or have problem while processing it when cpstatus value from apiresult is "100000", it means server communication is done properly and other values are valid in returns onerror [optional][nullable] optional callback method to invoke if an internal error occurs before the client to server data communication securityerror, if the application does not have the privilege to call this method unknownerror, if any other error occurs exceptions webapiexception with error type typemismatcherror, if any of input parameter is not compatible with its expected type with error type invalidvalueserror, if servertype contains an invalid value since 4 0 code example var strappid = ""; var struid = webapis sso getloginuid ; var invoiceid = ""; // issued by getproductslist var strcountrycode = webapis productinfo getsystemconfig webapis productinfo productinfoconfigkey config_key_service_country ; var onsuccess = function data {}; var onerror = function error {}; webapis billing applyinvoice strappid, struid, invoiceid, strcountrycode, "dev", onsuccess, onerror ; verifyinvoice checks whether a purchase, corresponding to a specific "invoiceid", was successful void verifyinvoice domstring appid, domstring customid, domstring invoiceid, domstring countrycode, tvservertype servertype, billingverifyinvoicecallback onsuccess, optional errorcallback? onerror ; product tv privilege level public privilege http //developer samsung com/privilege/billing parameters appid application id customid same value as "ordercustomid" parameter for the buyitem api samsung account uid invoiceid invoice id that you want to verify whether a purchase was successful countrycode tv country code servertype billing server type onsuccess returns the payment status if there is no internal error occurs until client to server data communication apiresult, can still contains error when billing server confirms that the given parameters does not have expected value or have problem while processing it when cpstatus value from apiresult is "100000", it means server communication is done properly and other values are valid in returns onerror [optional][nullable] optional callback method to invoke if an internal error occurs before the client to server data communication securityerror, if the application does not have the privilege to call this method unknownerror, if any other error occurs exceptions webapiexception with error type typemismatcherror, if any of input parameter is not compatible with its expected type with error type invalidvalueserror, if servertype contains an invalid value since 4 0 code example var strappid = ""; var struid = webapis sso getloginuid ; var invoiceid = ""; // issued by getproductslist var strcountrycode = webapis productinfo getsystemconfig webapis productinfo productinfoconfigkey config_key_service_country ; var onsuccess = function data {}; var onerror = function error {}; webapis billing verifyinvoice strappid, struid, invoiceid, strcountrycode, "dev", onsuccess, onerror ; getservicecountryavailability get service country availability for samsung checkout void getservicecountryavailability domstring appid, domstring[] countrycodes, domstring checkvalue, tvservertype servertype, billinggetservicecountryavailabilitycallback onsuccess, optional errorcallback? onerror ; product tv privilege level public privilege http //developer samsung com/privilege/billing parameters appid application id countrycodes to check multiple countrycodes available add as array, only uppercase allowed ex countrycodes=["de","us","kr"] checkvalue security check value required parameters = "appid" + "countrycodes" the check value is used by the dpi service to verify api requests it is a base64 hash generated by applying the hmac sha256 algorithm on a concatenated string of parameters using the dpi security key you can see the example how to generate checkvalue from the following code example you can use any open library to generate the hmac sha256 hash the following example uses the cryptojs library servertype billing server type onsuccess returns the service availability status of each country if there is no internal error occurs until client to server data communication apiresult, can still contains error when billing server confirms that the given parameters does not have expected value or have problem while processing it when cpstatus value from apiresult is "100000", it means server communication is done properly and other values are valid in returns onerror [optional][nullable] optional callback method to invoke if an internal error occurs before the client to server data communication securityerror, if the application does not have the privilege to call this method unknownerror, if any other error occurs exceptions webapiexception with error type typemismatcherror, if any of input parameter is not compatible with its expected type with error type invalidvalueserror, if servertype contains an invalid value since 5 5 code example var strsecuritykey = ""; // the dpi security key is issued at the dpi portal var strappid = ""; var countrycodes = ["de","us","kr"]; var reqparams = strappid + "deuskr"; var hash = cryptojs hmacsha256 reqparams, strsecuritykey ; var strcheckvalue = cryptojs enc base64 stringify hash ; var onsuccess = function data {}; var onerror = function error {}; webapis billing getservicecountryavailability strappid, countrycodes, strcheckvalue, "dev", onsuccess, onerror ; getuserpurchaselist retrieves the user's purchase list void getuserpurchaselist domstring appid, domstring customid, domstring countrycode, domstring pagenumber, domstring checkvalue, tvservertype servertype, billinggetuserpurchaselistcallback onsuccess, optional errorcallback? onerror ; product tv privilege level public privilege http //developer samsung com/privilege/billing parameters appid application id customid same value as "ordercustomid" parameter for the buyitem api samsung account uid countrycode tv country code pagenumber requested page number 1 ~ n checkvalue security check value required parameters = "appid" + "customid" + "countrycode" + "itemtype" + "pagenumber" itemtype, must use 2 as value "all items" the check value is used by the dpi service to verify api requests it is a base64 hash generated by applying the hmac sha256 algorithm on a concatenated string of parameters using the dpi security key you can see the example how to generate checkvalue from the following code example you can use any open library to generate the hmac sha256 hash the following example uses the cryptojs library servertype billing server type onsuccess returns the purchase list if there is no internal error occurs until client to server data communication apiresult, can still contains error when billing server confirms that the given parameters does not have expected value or have problem while processing it when cpstatus value from apiresult is "100000", it means server communication is done properly and other values are valid in returns onerror [optional][nullable] optional callback method to invoke if an internal error occurs before the client to server data communication securityerror, if the application does not have the privilege to call this method unknownerror, if any other error occurs exceptions webapiexception with error type typemismatcherror, if any of input parameter is not compatible with its expected type with error type invalidvalueserror, if servertype contains an invalid value since 4 0 code example var strsecuritykey = ""; // the dpi security key is issued at the dpi portal var strappid = ""; var struid = webapis sso getloginuid ; var strcountrycode = webapis productinfo getsystemconfig webapis productinfo productinfoconfigkey config_key_service_country ; var strpagenumber = "1"; var reqparams = strappid + struid + strcountrycode + "2" + strpagenumber; var hash = cryptojs hmacsha256 reqparams, strsecuritykey ; var strcheckvalue = cryptojs enc base64 stringify hash ; var onsuccess = function data {}; var onerror = function error {}; webapis billing getuserpurchaselist strappid, struid, strcountrycode, strpagenumber, strcheckvalue, "dev", onsuccess, onerror ; cancelsubscription cancels a subscription product void cancelsubscription domstring appid, domstring invoiceid, domstring customid, domstring countrycode, tvservertype servertype, billingcancelsubscriptioncallback onsuccess, optional errorcallback? onerror ; product tv privilege level public privilege http //developer samsung com/privilege/billing parameters appid application id invoiceid invoice id of subscription that you want to cancel customid same value as "ordercustomid" parameter for the buyitem api samsung account uid countrycode tv country code servertype billing server type onsuccess returns the subscription cancellation status if there is no internal error occurs until client to server data communication apiresult, can still contains error when billing server confirms that the given parameters does not have expected value or have problem while processing it when cpstatus value from apiresult is "100000", it means server communication is done properly and other values are valid in returns onerror [optional][nullable] optional callback method to invoke if an error occurs before the client to server data communication securityerror, if the application does not have the privilege to call this method unknownerror, if any other error occurs exceptions webapiexception with error type typemismatcherror, if any of input parameter is not compatible with its expected type with error type invalidvalueserror, if servertype contains an invalid value since 4 0 code example var strappid = ""; var struid = webapis sso getloginuid ; var invoiceid = ""; // issued by getproductslist var strcountrycode = webapis productinfo getsystemconfig webapis productinfo productinfoconfigkey config_key_service_country ; var onsuccess = function data {}; var onerror = function error {}; webapis billing cancelsubscription strappid, invoiceid, struid , strcountrycode , "dev", onsuccess, onerror ; isserviceavailable checks whether the billing server is available however, this api will be replaced by getservicecountryavailability after deprecation void isserviceavailable tvservertype servertype, billingisserviceavailablecallback onsuccess, optional errorcallback? onerror ; product tv privilege level public privilege http //developer samsung com/privilege/billing parameters servertype billing server onsuccess returns the server availability onerror [optional][nullable] optional callback method to invoke if an internal error occurs before the client to server data communication securityerror, if the application does not have the privilege to call this method unknownerror, if any other error occurs exceptions webapiexception with error type typemismatcherror, if any of input parameter is not compatible with its expected type with error type invalidvalueserror, if any input parameter contains an invalid value since 4 0 deprecated 5 5 code example var onsuccess = function data {}; var onerror = function error {}; webapis billing isserviceavailable "dev", onsuccess, onerror getversion retrieves the billing api version domstring getversion ; product tv privilege level public privilege http //developer samsung com/privilege/billing return value domstring billing api version exceptions webapiexception with error type securityerror, if the application does not have the privilege to call this method with error type unknownerror, for any other error since 4 0 code example var version = webapis billing getversion ; 2 3 billingbuydatasuccesscallback defines the payment success callback [callback = functiononly, nointerfaceobject] interface billingbuydatasuccesscallback { void onsuccess billingbuydata data ; }; methods onsuccess callback method returning the payment status void onsuccess billingbuydata data ; privilege level public privilege http //developer samsung com/privilege/billing parameters data payment status code example void onsuccess data { if data payresult == 'success' { // implement success logic } else { // implement cancel or fail logic } } 2 4 billingbuydata defines the payment result and information [nointerfaceobject] interface billingbuydata { attribute domstring payresult; attribute domstring paydetail; }; attributes domstring payresult payment result domstring paydetail payment information it is same with paymentdetails param of buyitem 2 5 billingproductslistcallback defines the product list success callback [callback = functiononly, nointerfaceobject] interface billingproductslistcallback { void onsuccess productslistdata data ; }; methods onsuccess callback method returning the product list request status void onsuccess productslistdata data ; privilege level public privilege http //developer samsung com/privilege/billing parameters data it includes getproductlist api result but you can't use it as it is you have to parse it as json format data code example void onsuccess data { var resproductslist = json parse data apiresult ; if resproductslist cpstatus == "100000" { // implement success logic } else { // implement cancel or fail logic } } 2 6 billingapplyinvoicecallback defines the apply invoice success callback [callback = functiononly, nointerfaceobject] interface billingapplyinvoicecallback { void onsuccess applyinvoicedata data ; }; methods onsuccess callback method returning the apply invoice request status void onsuccess applyinvoicedata data ; privilege level public privilege http //developer samsung com/privilege/billing parameters data it includes applyinvoice api result but you can't use it as it is you have to parse it as json format data code example void onsuccess data { resapplyproduct = json parse data apiresult ; if resapplyproduct cpstatus == "100000" { // implement success logic } else { // implement cancel or fail logic } } 2 7 billingverifyinvoicecallback defines the payment verification success callback [callback = functiononly, nointerfaceobject] interface billingverifyinvoicecallback { void onsuccess verifyinvoicedata data ; }; methods onsuccess callback method returning the payment verification request status void onsuccess verifyinvoicedata data ; privilege level public privilege http //developer samsung com/privilege/billing parameters data it includes verifyinvoice api result but you can't use it as it is you have to parse it as json format data code example void onsuccess data { resverifypurchase = json parse data apiresult ; if resverifypurchase cpstatus == "100000" { // implement success logic } else { // implement cancel or fail logic } } 2 8 billinggetuserpurchaselistcallback defines the purchase history success callback [callback = functiononly, nointerfaceobject] interface billinggetuserpurchaselistcallback { void onsuccess userpurchasedata data ; }; methods onsuccess callback method returning the purchase history request status void onsuccess userpurchasedata data ; privilege level public privilege http //developer samsung com/privilege/billing parameters data it includes getuserpurchaselist api result but you can't use it as it is you have to parse it as json format data code example void onsuccess data { respurchaseslist = json parse data apiresult ; if respurchaseslist cpstatus == "100000" { // implement success logic } else { // implement cancel or fail logic } } 2 9 billinggetservicecountryavailabilitycallback defines the get service country availability callback [callback = functiononly, nointerfaceobject] interface billinggetservicecountryavailabilitycallback { void onsuccess servicecountryavailabilitydata data ; }; methods onsuccess callback method returning availability of country list status void onsuccess servicecountryavailabilitydata data ; privilege level public privilege http //developer samsung com/privilege/billing parameters data it includes getservicecountryavailability api result but you can't use it as it is you have to parse it as json format data code example void onsuccess data { resservicecountryavailability = json parse data apiresult ; if resservicecountryavailability cpstatus == "100000" { // implement success logic } else { // implement cancel or fail logic } } 2 10 billingcancelsubscriptioncallback defines the subscription cancel success callback [callback = functiononly, nointerfaceobject] interface billingcancelsubscriptioncallback { void onsuccess cancelsubscriptiondata data ; }; methods onsuccess callback method returning the subscription cancel request status void onsuccess cancelsubscriptiondata data ; privilege level public privilege http //developer samsung com/privilege/billing parameters data it includes cancelsubscription api result but you can't use it as it is you have to parse it as json format data code example void onsuccess data { rescancelsubscription = json parse data apiresult ; if rescancelsubscription cpstatus == "100000" { // implement success logic } else { // implement cancel or fail logic } } 2 11 billingisserviceavailablecallback defines the service availability check success callback [callback = functiononly, nointerfaceobject] interface billingisserviceavailablecallback { void onsuccess serviceavailabledata data ; }; deprecated 5 5 methods onsuccess callback method returning the service availability check status void onsuccess serviceavailabledata data ; privilege level public privilege http //developer samsung com/privilege/billing parameters data it includes isserviceavailable api result but you can't use it as it is you have to parse it as json format data code example void onsuccess data { resjson = json parse data apiresult if resjson serviceyn == "y" { // implement success logic } else { // implement cancel or fail logic } } 3 full webidl module billing { enum tvservertype { "dev", "prd" }; enum historytype { "all", "subscription", "non-subscription" }; dictionary productslistdata { domstring apiresult; }; dictionary productslistapiresult { domstring cpstatus; domstring? cpresult; long totalcount; domstring checkvalue; itemdetails[]? itemdetails; }; dictionary itemdetails { long seq; domstring itemid; domstring itemtitle; long itemtype; long? period; long price; domstring currencyid; productsubscriptioninfo? subscriptioninfo; }; dictionary productsubscriptioninfo { domstring paymentcycleperiod; long paymentcyclefrq; long paymentcycle; }; dictionary applyinvoicedata { domstring apiresult; }; dictionary applyinvoiceapiresult { domstring cpstatus; domstring? cpresult; domstring appliedtime; }; dictionary verifyinvoicedata { domstring apiresult; }; dictionary verifyinvoiceapiresult { domstring cpstatus; domstring? cpresult; domstring appid; domstring invoiceid; }; dictionary userpurchasedata { domstring apiresult; }; dictionary getuserpurchaselistapiresult { domstring cpstatus; domstring? cpresult; long totalcount; domstring checkvalue; invoicedetails[]? invoicedetails; }; dictionary invoicedetails { long seq; domstring invoiceid; domstring itemid; domstring itemtitle; long itemtype; domstring ordertime; long? period; long price; domstring ordercurrencyid; boolean cancelstatus; boolean appliedstatus; domstring? appliedtime; domstring? limitendtime; domstring? remaintime; purchasesubscriptioninfo? subscriptioninfo; }; dictionary purchasesubscriptioninfo { domstring subscriptionid; domstring subsstarttime; domstring subsendtime; domstring subsstatus; }; dictionary servicecountryavailabilitydata { domstring apiresult; }; dictionary getservicecountryavailabilityapiresult { domstring cpstatus; domstring? cpresult; countries[]? countryavailability; }; dictionary countries { domstring countrycode; boolean isbillingsupported; }; dictionary cancelsubscriptiondata { domstring apiresult; }; dictionary cancelsubscriptionapiresult { domstring cpstatus; domstring? cpresult; domstring invoiceid; domstring? subscanceltime; domstring? subsstatus; }; dictionary showregisterpromotionalcodedata { domstring opendeeplinkresult; domstring opendeeplinkdetail; }; dictionary promotionalcodedetail { domstring appliedcouponcount; domstring[] appliedcouponlist; domstring registedbenefitcount; domstring[] registedbenefitlist; }; dictionary showregistercreditcarddata { domstring opendeeplinkresult; domstring? opendeeplinkdetail; }; dictionary showpurchasehistorydata { domstring opendeeplinkresult; domstring opendeeplinkdetail; }; dictionary purchasehistorydetail { domstring invoicerefundcount; domstring[] invoicerefundlist; domstring subscriptioncancelcount; domstring[] subscriptioncancellist; }; dictionary serviceavailabledata { domstring apiresult; }; dictionary serviceavailableapiresult { domstring status; domstring result; domstring serviceyn; }; [nointerfaceobject] interface billingmanagerobject { readonly attribute billingmanager billing; }; webapi implements billingmanagerobject; [nointerfaceobject] interface billingmanager { void buyitem domstring appid, tvservertype servertype, domstring paymentdetails, billingbuydatasuccesscallback onsuccess, optional errorcallback? onerror ; void getproductslist domstring appid, domstring countrycode, domstring pagesize, domstring pagenumber, domstring checkvalue, tvservertype servertype, billingproductslistcallback onsuccess, optional errorcallback? onerror ; void applyinvoice domstring appid, domstring customid, domstring invoiceid, domstring countrycode, tvservertype servertype, billingapplyinvoicecallback onsuccess, optional errorcallback? onerror ; void verifyinvoice domstring appid, domstring customid, domstring invoiceid, domstring countrycode, tvservertype servertype, billingverifyinvoicecallback onsuccess, optional errorcallback? onerror ; void getservicecountryavailability domstring appid, domstring[] countrycodes, domstring checkvalue, tvservertype servertype, billinggetservicecountryavailabilitycallback onsuccess, optional errorcallback? onerror ; void getuserpurchaselist domstring appid, domstring customid, domstring countrycode, domstring pagenumber, domstring checkvalue, tvservertype servertype, billinggetuserpurchaselistcallback onsuccess, optional errorcallback? onerror ; void cancelsubscription domstring appid, domstring invoiceid, domstring customid, domstring countrycode, tvservertype servertype, billingcancelsubscriptioncallback onsuccess, optional errorcallback? onerror ; void isserviceavailable tvservertype servertype, billingisserviceavailablecallback onsuccess, optional errorcallback? onerror ; domstring getversion ; }; [callback = functiononly, nointerfaceobject] interface billingbuydatasuccesscallback { void onsuccess billingbuydata data ; }; [nointerfaceobject] interface billingbuydata { attribute domstring payresult; attribute domstring paydetail; }; [callback = functiononly, nointerfaceobject] interface billingproductslistcallback { void onsuccess productslistdata data ; }; [callback = functiononly, nointerfaceobject] interface billingapplyinvoicecallback { void onsuccess applyinvoicedata data ; }; [callback = functiononly, nointerfaceobject] interface billingverifyinvoicecallback { void onsuccess verifyinvoicedata data ; }; [callback = functiononly, nointerfaceobject] interface billinggetuserpurchaselistcallback { void onsuccess userpurchasedata data ; }; [callback = functiononly, nointerfaceobject] interface billinggetservicecountryavailabilitycallback { void onsuccess servicecountryavailabilitydata data ; }; [callback = functiononly, nointerfaceobject] interface billingcancelsubscriptioncallback { void onsuccess cancelsubscriptiondata data ; }; [callback = functiononly, nointerfaceobject] interface billingisserviceavailablecallback { void onsuccess serviceavailabledata data ; }; };