UNPKG

react-native-qonversion

Version:

Qonversion provides full in-app purchases infrastructure, so you do not need to build your own server for receipt validation. Implement in-app subscriptions, validate user receipts, check subscription status, and provide access to your app features and co

111 lines 3.79 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const PurchaseOptions_1 = __importDefault(require("./PurchaseOptions")); class PurchaseOptionsBuilder { offerId = null; applyOffer = true; oldProduct = null; updatePolicy = null; contextKeys = null; quantity = 1; promoOffer = null; /** * iOS only. * Set quantity of product purchasing. Use for consumable in-app products. * @param quantity of product purchasing. * @return builder instance for chain calls. */ setQuantity(quantity) { this.quantity = quantity; return this; } /** * Android only. * Set offer for the purchase. * If offer is not specified, then the default offer will be applied. To know how we choose * the default offer, see {@link ProductStoreDetails.defaultSubscriptionOfferDetails}. * @param offer concrete offer which you'd like to purchase. * @return builder instance for chain calls. */ setOffer(offer) { this.offerId = offer.offerId; return this; } /** * Android only. * Set the offer Id to the purchase. * If {@link offerId} is not specified, then the default offer will be applied. To know how we choose * the default offer, see {@link ProductStoreDetails.defaultSubscriptionOfferDetails}. * @param offerId concrete offer Id which you'd like to purchase. * @return builder instance for chain calls. */ setOfferId(offerId) { this.offerId = offerId; return this; } /** * Android only. * Call this function to remove any intro/trial offer from the purchase (use only a bare base plan). * @return builder instance for chain calls. */ removeOffer() { this.applyOffer = false; return this; } /** * Android only. * Set Qonversion product from which the upgrade/downgrade will be initialized. * * @param oldProduct Qonversion product from which the upgrade/downgrade * will be initialized. * @return builder instance for chain calls. */ setOldProduct(oldProduct) { this.oldProduct = oldProduct; return this; } /** * Android only. * Set the update policy for the purchase. * If the {@link updatePolicy} is not provided, then default one * will be selected - {@link PurchaseUpdatePolicy.WITH_TIME_PRORATION}. * @param updatePolicy update policy for the purchase. * @return builder instance for chain calls. */ setUpdatePolicy(updatePolicy) { this.updatePolicy = updatePolicy; return this; } /** * Set the context keys associated with a purchase. * * @param contextKeys context keys for the purchase. * @return builder instance for chain calls. */ setContextKeys(contextKeys) { this.contextKeys = contextKeys; return this; } /** * Set the promotional offer details. * * @param promoOffer promotional offer details. * @return builder instance for chain calls. */ setPromotionalOffer(promoOffer) { this.promoOffer = promoOffer; return this; } /** * Generate {@link PurchaseOptions} instance with all the provided options. * @return the complete {@link PurchaseOptions} instance. */ build() { return new PurchaseOptions_1.default(this.offerId, this.applyOffer, this.oldProduct, this.updatePolicy, this.contextKeys, this.quantity, this.promoOffer); } } exports.default = PurchaseOptionsBuilder; //# sourceMappingURL=PurchaseOptionsBuilder.js.map