Skip to content

Latest commit

 

History

History
384 lines (211 loc) · 8.95 KB

CdvPurchase.Test.Adapter.md

File metadata and controls

384 lines (211 loc) · 8.95 KB

Class: Adapter

CdvPurchase.Test.Adapter

Test Adapter used for local testing with mock products.

This adapter simulates a payment platform that supports both In-App Products and Payment Requests.

The list of supported In-App Products

See

Test.TEST_PRODUCTS

Implements

Table of contents

Constructors

Properties

Accessors

Methods

Constructors

constructor

new Adapter(context)

Parameters

Name Type
context AdapterContext

Properties

id

id: Platform = Platform.TEST

Platform identifier

Implementation of

Adapter.id


name

name: string = 'Test'

Nice name for the adapter

Implementation of

Adapter.name


products

products: Product[] = []

Implementation of

Adapter.products


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


receipts

receipts: Receipt[] = []

Implementation of

Adapter.receipts

Accessors

isSupported

get isSupported(): boolean

Returns true is the adapter is supported on this device.

Returns

boolean

Implementation of

CdvPurchase.Adapter.isSupported

Methods

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


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


receiptValidationBody

receiptValidationBody(receipt): undefined | Body

Prepare for receipt validation

Parameters

Name Type
receipt Receipt

Returns

undefined | Body

Implementation of

Adapter.receiptValidationBody


requestPayment

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

Request a payment from the user

Parameters

Name Type
paymentRequest 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


verify

Static verify(receipt, callback): void

Parameters

Name Type
receipt Receipt
callback Callback<ReceiptResponse>

Returns

void