To use Samsung Product API, <script type="text/javascript" src="$WEBAPIS/webapis/webapis.js"></script> Should be loaded in index.html
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
Specifies billing server types.
enum TVServerType { "DEV", "PRD" };
The following values are supported
Specifies product types for the purchase history.
enum HistoryType { "ALL", "SUBSCRIPTION", "NON-SUBSCRIPTION" };
Defines a dictionary for product list data returned by the getProductsList API.
dictionary ProductsListData { DOMString apiResult; };
Defines a dictionary for the ProductsListData dictionary apiResult parameter.
dictionary ProductsListAPIResult { DOMString CPStatus; DOMString? CPResult; long TotalCount; DOMString CheckValue; ItemDetails[]? 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; };
Defines a dictionary for the ItemDetails dictionary 'SubscriptionInfo' parameter.
dictionary ProductSubscriptionInfo { DOMString PaymentCyclePeriod; long PaymentCycleFrq; long PaymentCycle; };
Defines a dictionary for data returned by the applyInvoice API.
dictionary ApplyInvoiceData { DOMString apiResult; };
Defines a dictionary for the ApplyInvoiceData dictionary 'apiResult' parameter.
dictionary ApplyInvoiceAPIResult { DOMString CPStatus; DOMString? CPResult; DOMString AppliedTime; };
Defines a dictionary for data returned by the verifyInvoice API.
dictionary VerifyInvoiceData { DOMString apiResult; };
Defines a dictionary for the VerifyInvoiceData dictionary 'apiResult' parameter.
dictionary VerifyInvoiceAPIResult { DOMString CPStatus; DOMString? CPResult; DOMString AppID; DOMString InvoiceID; };
Defines a dictionary for data returned by the getUserPurchaseList API.
dictionary UserPurchaseData { DOMString apiResult; };
Defines a dictionary for the UserPurchaseData dictionary 'apiResult' parameter.
dictionary GetUserPurchaseListAPIResult { DOMString CPStatus; DOMString? CPResult; long TotalCount; DOMString CheckValue; InvoiceDetails[]? 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; };
Defines a dictionary for the InvoiceDetails dictionary 'SubscriptionInfo' parameter.
dictionary PurchaseSubscriptionInfo { DOMString SubscriptionId; DOMString SubsStartTime; DOMString SubsEndTime; DOMString SubsStatus; };
Defines a dictionary for data returned by the getServiceCountryAvailability API.
dictionary ServiceCountryAvailabilityData { DOMString apiResult; };
Defines a dictionary for the ServiceCountryAvailabilityData dictionary 'apiResult' parameter.
dictionary GetServiceCountryAvailabilityAPIResult { DOMString CPStatus; DOMString? CPResult; Countries[]? CountryAvailability; };
Defines a dictionary for the GetServiceCountryAvailabilityAPIResult dictionary 'CountryAvailability' parameter.
dictionary Countries { DOMString CountryCode; boolean IsBillingSupported; };
Defines a dictionary for subscription cancellation data returned by the cancelSubscription API.
dictionary CancelSubscriptionData { DOMString apiResult; };
Defines a dictionary for the CancelSubscriptionData dictionary apiResult parameter.
dictionary CancelSubscriptionAPIResult { DOMString CPStatus; DOMString? CPResult; DOMString InvoiceID; DOMString? SubsCancelTime; DOMString? SubsStatus; };
This defines data set that is coming from showRegisterPromotionalCode API.
dictionary ShowRegisterPromotionalCodeData { DOMString openDeepLinkResult; DOMString openDeepLinkDetail; };
This defines data set of PromotionalCodeDetail parameter that contains ShowRegisterPromotionalCodeData dictionary.
dictionary PromotionalCodeDetail { DOMString AppliedCouponCount; DOMString[] AppliedCouponList; DOMString RegistedBenefitCount; DOMString[] RegistedBenefitList; };
This defines data set that is coming from ShowRegisterCreditCard API.
dictionary ShowRegisterCreditCardData { DOMString openDeepLinkResult; DOMString? openDeepLinkDetail; };
This defines data set that is coming from ShowPurchasesHistory API.
dictionary ShowPurchaseHistoryData { DOMString openDeepLinkResult; DOMString openDeepLinkDetail; };
This defines data set of PurchaseHistoryDetail parameter that contains ShowPurchaseHistoryData dictionary.
dictionary PurchaseHistoryDetail { DOMString InvoiceRefundCount; DOMString[] InvoiceRefundList; DOMString SubscriptionCancelCount; DOMString[] SubscriptionCancelList; };
Defines a dictionary for data returned by the IsServiceAvailable API.
dictionary ServiceAvailableData { DOMString apiResult; };
Defines a dictionary for the ServiceAvailableData dictionary 'apiResult' parameter.
dictionary ServiceAvailableAPIResult { DOMString status; DOMString result; DOMString serviceYn; };
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;
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(); };
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);
Parameters :
Exceptions :
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);
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);
Since : 4.0
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);
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);
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);
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);
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);
Get Service Country availability for Samsung Checkout
void getServiceCountryAvailability(DOMString appId, DOMString[] countryCodes, DOMString checkValue, TVServerType serverType, BillingGetServiceCountryAvailabilityCallback onsuccess, optional ErrorCallback? onerror);
Since : 5.5
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);
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);
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);
Cancels a subscription product.
void cancelSubscription(DOMString appId, DOMString invoiceId, DOMString customId, DOMString countryCode, TVServerType serverType, BillingCancelSubscriptionCallback onsuccess, optional ErrorCallback? onerror);
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);
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);
Deprecated : 5.5
var onsuccess = function(data) {}; var onerror = function(error) {}; webapis.billing.isServiceAvailable("DEV", onsuccess, onerror)
Retrieves the Billing API version.
DOMString getVersion();
Return Value :
var version = webapis.billing.getVersion();
Defines the payment success callback.
[Callback = FunctionOnly, NoInterfaceObject] interface BillingBuyDataSuccessCallback { void onsuccess(BillingBuyData data); };
Callback method returning the payment status.
void onsuccess(BillingBuyData data);
void onsuccess(data) { if(data.payResult == 'SUCCESS') { // Implement success logic } else { // Implement cancel or fail logic } }
Defines the payment result and information.
[NoInterfaceObject] interface BillingBuyData { attribute DOMString payResult; attribute DOMString payDetail; };
Defines the product list success callback.
[Callback = FunctionOnly, NoInterfaceObject] interface BillingProductsListCallback { void onsuccess(ProductsListData data); };
Callback method returning the product list request status.
void onsuccess(ProductsListData data);
void onsuccess(data) { var resProductsList = JSON.parse(data.apiResult); if(resProductsList.CPStatus == "100000") { // Implement success logic } else { // Implement cancel or fail logic } }
Defines the apply invoice success callback.
[Callback = FunctionOnly, NoInterfaceObject] interface BillingApplyInvoiceCallback { void onsuccess(ApplyInvoiceData data); };
Callback method returning the apply invoice request status.
void onsuccess(ApplyInvoiceData data);
void onsuccess(data) { resApplyProduct = JSON.parse(data.apiResult); if(resApplyProduct.CPStatus == "100000") { // Implement success logic } else { // Implement cancel or fail logic } }
Defines the payment verification success callback.
[Callback = FunctionOnly, NoInterfaceObject] interface BillingVerifyInvoiceCallback { void onsuccess(VerifyInvoiceData data); };
Callback method returning the payment verification request status.
void onsuccess(VerifyInvoiceData data);
void onsuccess(data) { resVerifyPurchase = JSON.parse(data.apiResult); if(resVerifyPurchase.CPStatus == "100000") { // Implement success logic } else { // Implement cancel or fail logic } }
Defines the purchase history success callback.
[Callback = FunctionOnly, NoInterfaceObject] interface BillingGetUserPurchaseListCallback { void onsuccess(UserPurchaseData data); };
Callback method returning the purchase history request status.
void onsuccess(UserPurchaseData data);
void onsuccess(data) { resPurchasesList = JSON.parse(data.apiResult); if(resPurchasesList.CPStatus == "100000") { // Implement success logic } else { // Implement cancel or fail logic } }
Defines the Get Service Country Availability callback.
[Callback = FunctionOnly, NoInterfaceObject] interface BillingGetServiceCountryAvailabilityCallback { void onsuccess(ServiceCountryAvailabilityData data); };
Callback method returning availability of country list status.
void onsuccess(ServiceCountryAvailabilityData data);
void onsuccess(data) { resServiceCountryAvailability = JSON.parse(data.apiResult); if(resServiceCountryAvailability.CPStatus == "100000") { // Implement success logic } else { // Implement cancel or fail logic } }
Defines the subscription cancel success callback.
[Callback = FunctionOnly, NoInterfaceObject] interface BillingCancelSubscriptionCallback { void onsuccess(CancelSubscriptionData data); };
Callback method returning the subscription cancel request status.
void onsuccess(CancelSubscriptionData data);
void onsuccess(data) { resCancelSubscription = JSON.parse(data.apiResult); if(resCancelSubscription.CPStatus == "100000") { // Implement success logic } else { // Implement cancel or fail logic } }
Defines the service availability check success callback.
[Callback = FunctionOnly, NoInterfaceObject] interface BillingIsServiceAvailableCallback { void onsuccess(ServiceAvailableData data); };
Callback method returning the service availability check status.
void onsuccess(ServiceAvailableData data);
void onsuccess(data) { resJson = JSON.parse(data.apiResult) if(resJson.serviceYn == "Y") { // Implement success logic } else { // Implement cancel or fail logic } }
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); }; };