Skip to content

Latest commit

 

History

History
291 lines (164 loc) · 6.23 KB

CdvPurchase.Adapter.md

File metadata and controls

291 lines (164 loc) · 6.23 KB

Interface: Adapter

CdvPurchase.Adapter

Adapter for a payment or in-app purchase platform

Implemented by

Table of contents

Properties

Accessors

Methods

Properties

id

id: Platform

Platform identifier


name

name: string

Nice name for the adapter


ready

ready: boolean

true after the platform has been successfully initialized.

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

Accessors

isSupported

get isSupported(): boolean

Returns true is the adapter is supported on this device.

Returns

boolean


products

get products(): Product[]

List of products managed by the adapter.

Returns

Product[]


receipts

get receipts(): Receipt[]

List of purchase receipts.

Returns

Receipt[]

Methods

checkSupport

checkSupport(functionality): boolean

Returns true if the platform supports the given functionality.

Parameters

Name Type
functionality PlatformFunctionality

Returns

boolean


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>


handleReceiptValidationResponse

handleReceiptValidationResponse(receipt, response): Promise<void>

Handle platform specific fields from receipt validation response.

Parameters

Name Type
receipt Receipt
response Payload

Returns

Promise<void>


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>


load

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

Load product definitions from the platform.

Parameters

Name Type
products IRegisterProduct[]

Returns

Promise<(IError | Product)[]>


manageBilling

manageBilling(): Promise<undefined | IError>

Open the platforms' billing management interface.

Returns

Promise<undefined | IError>


manageSubscriptions

manageSubscriptions(): Promise<undefined | IError>

Open the platforms' subscription management interface.

Returns

Promise<undefined | IError>


order

order(offer, additionalData): Promise<undefined | IError>

Initializes an order.

Parameters

Name Type
offer Offer
additionalData AdditionalData

Returns

Promise<undefined | IError>


receiptValidationBody

receiptValidationBody(receipt): undefined | Body

Prepare for receipt validation

Parameters

Name Type
receipt Receipt

Returns

undefined | Body


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>


restorePurchases

restorePurchases(): Promise<void>

Replay the queue of transactions.

Might ask the user to login.

Returns

Promise<void>