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.

Android IAP
iOS IAP

Admin Setup

  1. 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)

  1. Configure the IAP Settings

Admins can customize the text for various buttons displayed during the checkout process in the WooCommerce IAP Settings section. To access these settings:

  1. Go to your WordPress admin dashboard.

  2. Navigate to Webtonative > WooCommerce IAP Settings (specific section for Webtonative integration).

  3. Configure the IAP Settings:

  1. Configure the IAP Settings: The following options are available to customize the In-App Purchase functionality:

    • Enable In-App Purchase:

      • Check the box labeled "Enable In-App Purchases" to activate in-app purchases for your store.

      • Default: Unchecked (disabled).

    • Enable Test Mode:

      • Check the box labeled "Enable Test Mode" to enable test mode for in-app purchases. This is useful for testing transactions without processing real payments.

      • Default: Unchecked (disabled).

    • App Store Bundle ID:

      • Enter your App Store Bundle ID. This uniquely identifies your app in the Apple App Store

      • Default: Empty.

      • Example: com.example.app

    • App Store Key ID:

      • Enter your App Store Key ID. This is used to authenticate with Apple's servers for in-app purchase validation.

      • Default: Empty.

      • Example: QVI...

    • App Store Issuer ID:

      • Enter your App Store Issuer ID. This is associated with the key issued by Apple for your app.

      • Default: Empty.

      • Example: d1956586-...-73185c2e0d

    • App Store Private Key (.p8):

      • Paste the content of your .p8 private key file here. This key is used for signing and validating in-app purchase transactions with Apple.

      • Default: Empty.

      • Example:

        -----BEGIN PRIVATE KEY-----
        MIG...2DOW...
        cp1c...
        21yu9Sh...
        -----END PRIVATE KEY-----
    • Cart Button Text:

      • Set the text for the cart button that initiates the in-app purchase process.

      • Default: "Buy Now".

    • Processing Button Text:

      • Define the text displayed on the button while the payment is being processed.

      • Default: "Processing...".

    • Failed Button Text:

      • Specify the text shown on the button if the payment fails.

      • Default: "Payment Failed".

    • Payment Completed Button Text:

      • Set the text displayed on the button after a successful payment.

      • Default: "Payment Completed".

  2. Save the Settings:

    • After configuring the options, click the Save Settings button to apply your changes.


Important Notes:

  • Test Mode: Remember to uncheck Is Test and switch to the live environment before launching your store.


Payment Validation

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.

Where In-App Purchase Data is Saved

  1. 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...

  1. Post Meta

  • Metadata Purchase 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.

Last updated

Was this helpful?