In-App Purchase (WooCommerce)
The In-App Purchase (IAP) integration enables seamless payment handling via the Google Play Store (Android) and Apple App Store (iOS) within WooCommerce.
Last updated
The In-App Purchase (IAP) integration enables seamless payment handling via the Google Play Store (Android) and Apple App Store (iOS) within WooCommerce.
Last updated
Custom Fields for Products
When creating or editing WooCommerce products, the following fields are available for configuring in-app purchases:
Google Play Product ID: _wtn_google_play_product_id
App Store Product ID:
Product Type: _wtn_product_type (INAPP for one-time purchases or SUBS for subscriptions)
Is Consumable: _wtn_is_consumable (Checkbox indicating if the product is consumable)
Here’s a guide to setting up the App Store Secret Key and configuring the Is Test mode for the Webtonative Payment Gateway in WooCommerce
Step 1: Access WooCommerce Payment Settings
Go to your WordPress admin dashboard.
Navigate to WooCommerce > Settings.
Click on the Payments tab.
Step 2: Enable webtonative Payment Gateway
Locate the Webtonative Payment Gateway in the list of payment methods.
Toggle the switch to enable the gateway.
Click the Manage button to access the gateway settings.
Step 3: Configure the App Store Secret Key
In the Webtonative Payment Gateway Settings:
Enable/Disable: Check the box to enable the payment gateway.
App Store Secret: Enter your App Store secret key. This key is used to validate in-app purchases or subscriptions through the Apple App Store.
Obtain this key from your Apple Developer Account. Navigate to App Store Connect > Users and Access > Keys to create or retrieve the secret key.
Save the secret key securely in the provided field.
Step 4: Enable Test Mode
Check the Is Test option to enable the test mode.
When enabled, the gateway will use the sandbox environment for testing purchases instead of the live environment.
Use this option during development or testing to avoid real charges.
Step 5: Save Changes
Click the Save Changes button at the bottom of the settings page.
Verify that the changes are saved successfully.
App Store Secret Key: Ensure the secret key is up-to-date and matches the credentials in your Apple Developer account.
Test Mode: Remember to uncheck Is Test and switch to the live environment before launching your store.
1. Get a Native Product ID
Endpoint: POST /webtonative/iap/product
Request Parameters:
productId (string): WooCommerce Product ID
platform (string): ANDROID or IOS
Response: Returns native product details like Product ID, Type, and Consumable status.
2. Create WooCommerce Order
Endpoint: POST /webtonative/iap/order
Request Parameters:
productId (string): WooCommerce Product ID
platform (string): ANDROID or IOS
Additional purchase data specific to the platform.
Response: Create an order in WooCommerce with payment details from Google Play or Apple App Store.
Android Payment Validation
Data validated includes orderId, purchaseToken, purchaseState, and other parameters received from Google Play.
A wooCommerce order is created if the purchase is verified successfully.
iOS Payment Validation
Receipt data is validated using the App Store's API (sandbox or production).
If validated successfully, a WooCommerce order is created and marked as completed.
WooCommerce Order Notes
Each order created via IAP includes a detailed note with purchase data.
Example note: Webtonative Payment Data:
- Product ID: <product_id>
- Order ID: <order_id>
- Platform: <ANDROID/IOS>
- Other purchase details...
Post Meta
metadataPurchase details are saved as metadata in WooCommerce orders.
Meta Key: _wtn_payment_data
Contains a JSON object with transaction details, such as productId, receiptData, platform, and more.
From the WooCommerce Dashboard
Navigate to WooCommerce > Orders.
Select the relevant order created via IAP.
View the order notes and custom meta fields.
Via REST API
Fetch orders through WooCommerce's REST API.
Retrieve the _wtn_payment_data meta field for transaction details.