UNPKG

@qonversion/capacitor-plugin

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

311 lines (310 loc) 13 kB
import { ActionType, EntitlementGrantType, EntitlementSource, ExperimentGroupType, IntroEligibilityStatus, NoCodesErrorCode, OfferingTag, PricingPhaseRecurrenceMode, PricingPhaseType, ProductType, PurchaseResultSource, PurchaseResultStatus, QonversionErrorCode, RemoteConfigurationAssignmentType, RemoteConfigurationSourceType, SKPeriodUnit, SKProductDiscountPaymentMode, SKProductDiscountType, SubscriptionPeriodUnit, TransactionEnvironment, TransactionOwnershipType, TransactionType, UserPropertyKey } from "../dto/enums"; import { IntroEligibility } from "../dto/IntroEligibility"; import { Offering } from "../dto/Offering"; import { Offerings } from "../dto/Offerings"; import { Entitlement } from "../dto/Entitlement"; import { Product } from "../dto/Product"; import { SKProduct } from "../dto/storeProducts/SKProduct"; import { SKProductDiscount } from "../dto/storeProducts/SKProductDiscount"; import { SKSubscriptionPeriod } from "../dto/storeProducts/SKSubscriptionPeriod"; import { QonversionError } from "../dto/QonversionError"; import { User } from '../dto/User'; import { SubscriptionPeriod } from "../dto/SubscriptionPeriod"; import { RemoteConfig } from "../dto/RemoteConfig"; import { RemoteConfigList } from '../dto/RemoteConfigList'; import { UserProperties } from '../dto/UserProperties'; import { Transaction } from "../dto/Transaction"; import { PurchaseResult } from "../dto/PurchaseResult"; import { StoreTransaction } from "../dto/StoreTransaction"; import { ProductStoreDetails } from "../dto/storeProducts/ProductStoreDetails"; import { ProductOfferDetails } from "../dto/storeProducts/ProductOfferDetails"; import { ProductInAppDetails } from "../dto/storeProducts/ProductInAppDetails"; import { ProductPrice } from "../dto/storeProducts/ProductPrice"; import { ProductPricingPhase } from "../dto/storeProducts/ProductPricingPhase"; import { ProductInstallmentPlanDetails } from '../dto/storeProducts/ProductInstallmentPlanDetails'; import { PromotionalOffer } from '../dto/PromotionalOffer'; import { SKPaymentDiscount } from '../dto/storeProducts/SKPaymentDiscount'; import { NoCodesAction } from '../dto/NoCodesAction'; import { NoCodesError } from '../dto/NoCodesError'; import { ScreenPresentationConfig } from '../dto/ScreenPresentationConfig'; export type QProduct = { id: string; storeId: string; basePlanId?: string | null; type: string; subscriptionPeriod?: QSubscriptionPeriod | null; trialPeriod?: QSubscriptionPeriod | null; storeDetails?: QProductStoreDetails; skProduct?: QSKProduct | null; prettyPrice?: string | null; offeringId?: string | null; }; type QProductStoreDetails = { basePlanId?: string | null; productId: string; name: string; title: string; description: string; subscriptionOfferDetails?: QProductOfferDetails[] | null; defaultSubscriptionOfferDetails?: QProductOfferDetails | null; basePlanSubscriptionOfferDetails?: QProductOfferDetails | null; inAppOfferDetails?: QProductInAppDetails | null; hasTrialOffer: boolean; hasIntroOffer: boolean; hasTrialOrIntroOffer: boolean; productType: string; isInApp: boolean; isSubscription: boolean; isPrepaid: boolean; isInstallment: boolean; }; type QSubscriptionPeriod = { unitCount: number; unit: string; iso: string; }; type QProductPricingPhase = { price: QProductPrice; billingPeriod: QSubscriptionPeriod; billingCycleCount: number; recurrenceMode: string; type: string; isTrial: boolean; isIntro: boolean; isBasePlan: boolean; }; type QProductInstallmentPlanDetails = { commitmentPaymentsCount: number; subsequentCommitmentPaymentsCount: number; }; export type QPromotionalOffer = { productDiscount: QProductDiscount; paymentDiscount: QPaymentDiscount; }; type QProductOfferDetails = { basePlanId: string; offerId?: string | null; offerToken: string; tags: string[]; pricingPhases: QProductPricingPhase[]; basePlan?: QProductPricingPhase | null; installmentPlanDetails?: QProductInstallmentPlanDetails | null; trialPhase?: QProductPricingPhase | null; introPhase: QProductPricingPhase | null; hasTrial: boolean; hasIntro: boolean; hasTrialOrIntro: boolean; }; type QProductPrice = { priceAmountMicros: number; priceCurrencyCode: string; formattedPrice: string; isFree: boolean; currencySymbol: string; }; type QProductInAppDetails = { price: QProductPrice; }; type QSKProduct = { subscriptionPeriod: null | QSKSubscriptionPeriod; introductoryPrice: QProductDiscount | null; discounts: Array<QProductDiscount> | null; localizedDescription: string | undefined; localizedTitle: string | undefined; price: string; priceLocale: QLocale; productIdentifier: string | undefined; isDownloadable: boolean | undefined; downloadContentVersion: string | undefined; downloadContentLengths: number[] | undefined; productDiscount: SKProductDiscount | undefined; subscriptionGroupIdentifier: string | undefined; isFamilyShareable: boolean | undefined; }; type QSKSubscriptionPeriod = { numberOfUnits: number; unit: keyof typeof SKPeriodUnit; }; type QProductDiscount = { subscriptionPeriod: null | QSKSubscriptionPeriod; price: string; numberOfPeriods: number; paymentMode: keyof typeof SKProductDiscountPaymentMode; identifier?: string; type: keyof typeof SKProductDiscountType; priceLocale: QLocale; }; type QPaymentDiscount = { identifier: string; keyIdentifier: string; nonce: string; signature: string; timestamp: number; }; type QLocale = { currencySymbol: string | null; currencyCode: string | null; localeIdentifier: string; }; export type QTrialIntroEligibility = Record<string, { status: "non_intro_or_trial_product" | "intro_or_trial_eligible" | "intro_or_trial_ineligible"; }>; export type QNoCodeAction = { type: ActionType; parameters: Map<string, string | undefined>; error: QNoCodesError | undefined; }; type QQonversionError = { code?: string; description?: string | null; additionalMessage?: string | null; domain?: string | null; }; export type QNoCodesError = QQonversionError & { qonversionError?: QQonversionError | null; }; export type QNoCodeScreenInfo = { screenId: string; }; export type QEntitlement = { id: string; productId: string; active: boolean; renewState: string; source: string; startedTimestamp: number; expirationTimestamp: number; renewsCount: number; trialStartTimestamp: number; firstPurchaseTimestamp: number; lastPurchaseTimestamp: number; lastActivatedOfferCode: string; grantType: string; autoRenewDisableTimestamp: number; transactions?: Array<QTransaction>; }; type QTransaction = { originalTransactionId: string; transactionId: string; offerCode: string; transactionTimestamp: number; expirationTimestamp: number; transactionRevocationTimestamp: number; environment: string; ownershipType: string; type: string; promoOfferId: string; }; export type QOfferings = { availableOfferings?: Array<QOffering>; main: QOffering; }; type QOffering = { id: string; tag: keyof typeof OfferingTag; products: Array<QProduct>; }; export type QUser = { qonversionId: string; identityId?: string | null; }; export type QRemoteConfig = { payload: Record<string, Object>; experiment?: QExperiment | null; source: QRemoteConfigurationSource; }; export type QRemoteConfigList = { remoteConfigs: Array<QRemoteConfig>; }; type QRemoteConfigurationSource = { id: string; name: string; type: string; assignmentType: string; contextKey: string | null | undefined; }; type QExperiment = { id: string; name: string; group: QExperimentGroup; }; type QExperimentGroup = { id: string; name: string; type: string; }; type QUserProperty = { key: string; value: string; }; export type QUserProperties = { properties: QUserProperty[]; }; export type QPurchaseResult = { status: string; entitlements?: Record<string, QEntitlement> | null; error?: Record<string, unknown> | null; isFallbackGenerated?: boolean; source: string; storeTransaction?: QStoreTransaction | null; }; export type QStoreTransaction = { transactionId?: string | null; originalTransactionId?: string | null; transactionTimestamp?: number | null; productId?: string | null; quantity?: number | null; promoOfferId?: string | null; purchaseToken?: string | null; }; declare class Mapper { static convertPromoOffer(promoOffer: QPromotionalOffer | null | undefined): PromotionalOffer | null; static convertEntitlements(entitlements: Record<string, QEntitlement> | null | undefined): Map<string, Entitlement>; static convertTransaction(transaction: QTransaction): Transaction; static convertTransactionType(typeKey: string): TransactionType; static convertTransactionOwnershipType(ownershipTypeKey: string): TransactionOwnershipType; static convertTransactionEnvironment(envKey: string): TransactionEnvironment; static convertEntitlementSource(sourceKey: string): EntitlementSource; static convertEntitlementGrantType(typeKey: string): EntitlementGrantType; static convertDefinedUserPropertyKey(sourceKey: string): UserPropertyKey; static convertUserProperties(properties: QUserProperties): UserProperties; static convertProducts(products: Record<string, QProduct> | null | undefined): Map<string, Product>; static convertProduct(product: QProduct): Product; static convertOfferings(offerings: QOfferings | null | undefined): Offerings | null; static convertOffering(offering: QOffering): Offering; static convertProductType(productType: string): ProductType; static convertSubscriptionPeriod(productPeriod: QSubscriptionPeriod | null | undefined): SubscriptionPeriod | null; static convertSubscriptionPeriodUnit(unit: string): SubscriptionPeriodUnit; static convertProductPricingPhase(pricingPhase: QProductPricingPhase | null | undefined): ProductPricingPhase | null; static convertPrisingPhaseRecurrenceMode(recurrenceMode: string): PricingPhaseRecurrenceMode; static convertPrisingPhaseType(type: string): PricingPhaseType; static convertProductInstallmentPlanDetails(installmentPlanDetails: QProductInstallmentPlanDetails | null | undefined): ProductInstallmentPlanDetails | null; static convertProductOfferDetails(offerDetails: QProductOfferDetails): ProductOfferDetails; static convertInAppOfferDetails(inAppOfferDetails: QProductInAppDetails): ProductInAppDetails; static convertProductPrice(productPrice: QProductPrice): ProductPrice; static convertProductStoreDetails(productStoreDetails: QProductStoreDetails): ProductStoreDetails; static convertSKProduct(skProduct: QSKProduct): SKProduct; static convertSKSubscriptionPeriod(subscriptionPeriod: QSKSubscriptionPeriod): SKSubscriptionPeriod; static convertPaymentDiscount(discount: QPaymentDiscount): SKPaymentDiscount; static convertProductDiscount(discount: QProductDiscount): SKProductDiscount; static convertDiscounts(discounts: Array<QProductDiscount>): SKProductDiscount[]; static convertEligibility(eligibilityMap: QTrialIntroEligibility | null | undefined): Map<string, IntroEligibility>; static convertEligibilityStatus(status: string): IntroEligibilityStatus; static convertQonversionError(payload: Record<string, string> | undefined): QonversionError | undefined; static convertUserInfo(user: QUser): User; static convertRemoteConfig(remoteConfig: QRemoteConfig): RemoteConfig; static convertRemoteConfigList(remoteConfigList: QRemoteConfigList): RemoteConfigList; static convertRemoteConfigurationSourceType(type: String): RemoteConfigurationSourceType; static convertRemoteConfigurationAssignmentType(type: String): RemoteConfigurationAssignmentType; static convertGroupType(type: String): ExperimentGroupType; static convertErrorCode(code: string): QonversionErrorCode; static convertAction(payload: QNoCodeAction): NoCodesAction; static convertNoCodesError(payload: QNoCodesError | undefined): NoCodesError | undefined; static convertNoCodesErrorCode(code: string | undefined): NoCodesErrorCode; static convertScreenPresentationConfig(config: ScreenPresentationConfig): Record<string, unknown>; static convertPurchaseResult(purchaseResult: QPurchaseResult | null | undefined): PurchaseResult | null; static convertPurchaseResultStatus(status: string | null | undefined): PurchaseResultStatus; static convertPurchaseResultSource(source: string | null | undefined): PurchaseResultSource; static convertStoreTransaction(storeTransaction: QStoreTransaction | null | undefined): StoreTransaction | null; } export default Mapper;