Skip to content

v13 reference: Test Adapter

Jean-Christophe Hoelt edited this page Feb 25, 2025 · 5 revisions

I'll help you update the wiki documentation to mention the new custom test products feature introduced in version 13.12.2. Here's an updated version of the documentation that includes this information:

Introduction

The Test Adapter provides a mock payment platform so you can test your implementation without interacting with any specific platform.

It provides some test products that you can register and buy using store.order().

It also process (fake) payment requests, using store.requestPayment().

Using the Test Adapter

  • At initialization, add Platform.TEST
  • At registration, register one of the test products.
  • Use the test products as a regular product.

Custom Test Products (v13.12.2+)

Starting with version 13.12.2, you can define custom test products directly using the store.register() method. This allows you to create test products with specific attributes for your development and testing needs.

// Register a custom test product
store.register([{
  id: 'my-custom-product',
  type: CdvPurchase.ProductType.CONSUMABLE,
  platform: CdvPurchase.Platform.TEST,
  title: 'My Custom Product',
  description: 'A custom test consumable product',
  pricing: {
    price: '$2.99', 
    currency: 'USD',
    priceMicros: 2990000
  }
}]);

You can customize various aspects of the test product including:

  • Title and description
  • Price, currency, and price in micros
  • For subscriptions, you can define custom pricing phases with trial periods

These custom test products work alongside the built-in test products and provide more flexibility for testing different scenarios.

Next

Those tutorials make use of the test adapter:

API documentation: