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
- checkSupport
- finish
- handleReceiptValidationResponse
- initialize
- load
- manageBilling
- manageSubscriptions
- order
- receiptValidationBody
- requestPayment
- restorePurchases
- verify
• new Adapter(context
)
Name | Type |
---|---|
context |
AdapterContext |
• id: Platform
= Platform.TEST
Platform identifier
• name: string
= 'Test'
Nice name for the adapter
• products: Product
[] = []
• 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).
• receipts: Receipt
[] = []
• get
isSupported(): boolean
Returns true is the adapter is supported on this device.
boolean
CdvPurchase.Adapter.isSupported
▸ checkSupport(functionality
): boolean
Returns true if the platform supports the given functionality.
Name | Type |
---|---|
functionality |
PlatformFunctionality |
boolean
▸ 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.
Name | Type |
---|---|
transaction |
Transaction |
Promise
<undefined
| IError
>
▸ handleReceiptValidationResponse(receipt
, response
): Promise
<void
>
Handle platform specific fields from receipt validation response.
Name | Type |
---|---|
receipt |
Receipt |
response |
Payload |
Promise
<void
>
Adapter.handleReceiptValidationResponse
▸ 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.
Promise
<undefined
| IError
>
▸ load(products
): Promise
<(IError
| Product
)[]>
Load product definitions from the platform.
Name | Type |
---|---|
products |
IRegisterProduct [] |
▸ manageBilling(): Promise
<undefined
| IError
>
Open the platforms' billing management interface.
Promise
<undefined
| IError
>
▸ manageSubscriptions(): Promise
<undefined
| IError
>
Open the platforms' subscription management interface.
Promise
<undefined
| IError
>
▸ order(offer
): Promise
<undefined
| IError
>
Initializes an order.
Name | Type |
---|---|
offer |
Offer |
Promise
<undefined
| IError
>
▸ receiptValidationBody(receipt
): undefined
| Body
Prepare for receipt validation
Name | Type |
---|---|
receipt |
Receipt |
undefined
| Body
▸ requestPayment(paymentRequest
, additionalData?
): Promise
<undefined
| IError
| Transaction
>
Request a payment from the user
Name | Type |
---|---|
paymentRequest |
PaymentRequest |
additionalData? |
AdditionalData |
Promise
<undefined
| IError
| Transaction
>
▸ restorePurchases(): Promise
<void
>
Replay the queue of transactions.
Might ask the user to login.
Promise
<void
>
▸ Static
verify(receipt
, callback
): void
Name | Type |
---|---|
receipt |
Receipt |
callback |
Callback <ReceiptResponse > |
void