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
Was this helpful?
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
Was this helpful?
Custom Fields for Products
When creating or editing WooCommerce products, the following fields are available for configuring in-app purchases:
Google Play Product ID: ID for the product in Google Play
App Store Product ID: ID for the product in the App Store
Product Type: (INAPP for one-time purchases or SUBS for subscriptions)
Is Consumable: (Checkbox indicating if the product is consumable)
Configure Custom Button Text
Admins can customize the text for various buttons displayed during the checkout process in the WooCommerce IAP Settings section. To access these settings:
Go to your WordPress admin dashboard.
Navigate to WooCommerce > IAP Settings (specific section for Webtonative integration).
Configure the following button texts:
Cart Button Text: The default is "Buy Now."
Processing Button Text: Default is "Processing..."
Failed Button Text: The default is "Payment Failed."
Payment Completed Button Text: The default is "Payment Completed."
Save the settings after making changes.
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 validates in-app purchases or subscriptions through the Apple App Store.
You can obtain this key from your Apple Developer Account. To create or retrieve the secret key, navigate to Users and Access > Integrations > Shared Secret.
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 to test 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
It contains a JSON object with transaction details, such as productId, receiptData, platform, and more.