Adapter for a payment or in-app purchase platform

interface Adapter {
    id: Platform;
    isSupported: boolean;
    name: string;
    products: Product[];
    ready: boolean;
    receipts: CdvPurchase.Receipt[];
    supportsParallelLoading: boolean;
    checkSupport(functionality): boolean;
    finish(transaction): Promise<undefined | IError>;
    handleReceiptValidationResponse(receipt, response): Promise<void>;
    initialize(): Promise<undefined | IError>;
    loadProducts(products): Promise<(IError | Product)[]>;
    loadReceipts(): Promise<CdvPurchase.Receipt[]>;
    manageBilling(): Promise<undefined | IError>;
    manageSubscriptions(): Promise<undefined | IError>;
    order(offer, additionalData): Promise<undefined | IError>;
    receiptValidationBody(receipt): Promise<undefined | Body>;
    requestPayment(payment, additionalData?): Promise<undefined | IError | CdvPurchase.Transaction>;
    restorePurchases(): Promise<undefined | IError>;
}

Implemented by

Properties

Platform identifier

isSupported: boolean

Returns true is the adapter is supported on this device.

name: string

Nice name for the adapter

products: Product[]

List of products managed by the adapter.

ready: boolean

true after the platform has been successfully initialized.

The value is set by the "Adapters" class (which is responsible for initializing adapters).

receipts: CdvPurchase.Receipt[]

List of purchase receipts.

supportsParallelLoading: boolean

Set to true if receipts and products can be loaded in parallel

Methods

  • Returns true if the platform supports the given functionality.

    Parameters

    Returns boolean

  • Finish a transaction.

    For non-consumables, this will acknowledge the purchase. For consumable, this will acknowledge and consume the purchase.

    Parameters

    Returns Promise<undefined | IError>

  • Handle platform specific fields from receipt validation response.

    Parameters

    Returns Promise<void>

  • Initializes a platform adapter.

    Will resolve when initialization is complete.

    Will fail with an IError in case of an unrecoverable error.

    In other case of a potentially recoverable error, the adapter will keep retrying to initialize forever.

    Returns Promise<undefined | IError>

  • Open the platforms' billing management interface.

    Returns Promise<undefined | IError>

  • Open the platforms' subscription management interface.

    Returns Promise<undefined | IError>

  • Prepare for receipt validation

    Parameters

    Returns Promise<undefined | Body>

  • Replay the queue of transactions.

    Might ask the user to login.

    Returns Promise<undefined | IError>