UNPKG

dop-sdk

Version:

Mini App SDK for JavaScript by VTB

50 lines 2.37 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Purchases = void 0; var event_types_1 = require("../event-types"); var sdkbridge_1 = require("../sdkbridge"); var error_types_1 = require("../types/error-types"); /** @internal */ var Purchases = /** @class */ (function () { function Purchases() { } /** * This will retrieve the list of products details available for In-App Purchases associated with Mini App in the Platform. * @returns List of In-app purchase products * @see {getAllProducts} */ Purchases.prototype.getAllProducts = function () { return (0, sdkbridge_1.getBridge)() .sendToNative(event_types_1.InAppPurchaseEvent.GET_ALL_PRODUCT, null) .then(function (productsList) { return JSON.parse(productsList); }) .catch(function (error) { return (0, error_types_1.parseMiniAppError)(error); }); }; /** * This will request for the In-App Purchase of a product with product id associated with Mini App in the Platform. * @param id Product id of the product to be purchased. * @returns Purchased product details and the transaction details of the purchase. */ Purchases.prototype.purchaseProductWith = function (id) { return (0, sdkbridge_1.getBridge)() .sendToNative(event_types_1.InAppPurchaseEvent.PURCHASE_PRODUCT_WITH, { productId: id }) .then(function (purchasedProduct) { return JSON.parse(purchasedProduct); }) .catch(function (error) { return (0, error_types_1.parseMiniAppError)(error); }); }; /** * This will request to Consume the product that is purchased using consumePurchaseWith API * @param id Product id of the product that is purchased. * @returns */ Purchases.prototype.consumePurchaseWith = function (id, transactionId) { return (0, sdkbridge_1.getBridge)() .sendToNative(event_types_1.InAppPurchaseEvent.CONSUME_PRODUCT_WITH, { productId: id, productTransactionId: transactionId, }) .then(function (consumedInfo) { return JSON.parse(consumedInfo); }) .catch(function (error) { return (0, error_types_1.parseMiniAppError)(error); }); }; return Purchases; }()); exports.Purchases = Purchases; //# sourceMappingURL=in-app-purchase.js.map