Skip to content

Latest commit

 

History

History
476 lines (263 loc) · 11.1 KB

CdvPurchase.AppleAppStore.Adapter.md

File metadata and controls

476 lines (263 loc) · 11.1 KB

Class: Adapter

CdvPurchase.AppleAppStore.Adapter

Adapter for Apple AppStore using StoreKit version 1

Implements

Table of contents

Constructors

Properties

Accessors

Methods

Constructors

constructor

new Adapter(context, options)

Parameters

Name Type
context AdapterContext
options AdapterOptions

Properties

_products

_products: SKProduct[] = []

List of products loaded from AppStore


_receipt

Optional _receipt: SKApplicationReceipt

The application receipt, contains all transactions


bridge

bridge: Bridge


context

context: AdapterContext


discountEligibilityDeterminer

Optional discountEligibilityDeterminer: DiscountEligibilityDeterminer

Component that determine eligibility to a given discount offer


id

id: Platform = Platform.APPLE_APPSTORE

Platform identifier

Implementation of

Adapter.id


log

log: Logger


name

name: string = 'AppStore'

Nice name for the adapter

Implementation of

Adapter.name


needAppReceipt

needAppReceipt: boolean

True when we need to validate the application receipt


ready

ready: boolean = false

true after the platform has been successfully initialized.

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

Implementation of

Adapter.ready

Accessors

isSupported

get isSupported(): boolean

Returns true on Android, the only platform supported by this adapter

Returns

boolean

Implementation of

CdvPurchase.Adapter.isSupported


products

get products(): Product[]

List of products managed by the adapter.

Returns

Product[]

Implementation of

CdvPurchase.Adapter.products


receipts

get receipts(): Receipt[]

List of purchase receipts.

Returns

Receipt[]

Implementation of

CdvPurchase.Adapter.receipts

Methods

addValidProducts

addValidProducts(registerProducts, validProducts): void

Parameters

Name Type
registerProducts IRegisterProduct[]
validProducts ValidProduct[]

Returns

void


checkSupport

checkSupport(functionality): boolean

Returns true if the platform supports the given functionality.

Parameters

Name Type
functionality PlatformFunctionality

Returns

boolean

Implementation of

Adapter.checkSupport


finish

finish(transaction): Promise<undefined | IError>

Finish a transaction.

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

Parameters

Name Type
transaction Transaction

Returns

Promise<undefined | IError>

Implementation of

Adapter.finish


getProduct

getProduct(id): undefined | SKProduct

Find a given product from ID

Parameters

Name Type
id string

Returns

undefined | SKProduct


handleReceiptValidationResponse

handleReceiptValidationResponse(_receipt, response): Promise<void>

Handle platform specific fields from receipt validation response.

Parameters

Name Type
_receipt Receipt
response Payload

Returns

Promise<void>

Implementation of

Adapter.handleReceiptValidationResponse


initialize

initialize(): Promise<undefined | IError>

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>

Implementation of

Adapter.initialize


load

load(products): Promise<(IError | Product)[]>

Load product definitions from the platform.

Parameters

Name Type
products IRegisterProduct[]

Returns

Promise<(IError | Product)[]>

Implementation of

Adapter.load


manageBilling

manageBilling(): Promise<undefined | IError>

Open the platforms' billing management interface.

Returns

Promise<undefined | IError>

Implementation of

Adapter.manageBilling


manageSubscriptions

manageSubscriptions(): Promise<undefined | IError>

Open the platforms' subscription management interface.

Returns

Promise<undefined | IError>

Implementation of

Adapter.manageSubscriptions


order

order(offer): Promise<undefined | IError>

Initializes an order.

Parameters

Name Type
offer Offer

Returns

Promise<undefined | IError>

Implementation of

Adapter.order


presentCodeRedemptionSheet

presentCodeRedemptionSheet(): Promise<void>

Returns

Promise<void>


receiptValidationBody

receiptValidationBody(receipt): undefined | Body

Prepare for receipt validation

Parameters

Name Type
receipt Receipt

Returns

undefined | Body

Implementation of

Adapter.receiptValidationBody


requestPayment

requestPayment(payment, additionalData?): Promise<undefined | IError | Transaction>

Request a payment from the user

Parameters

Name Type
payment PaymentRequest
additionalData? AdditionalData

Returns

Promise<undefined | IError | Transaction>

Implementation of

Adapter.requestPayment


restorePurchases

restorePurchases(): Promise<void>

Replay the queue of transactions.

Might ask the user to login.

Returns

Promise<void>

Implementation of

Adapter.restorePurchases