Skip to main content

godot-iap

IAPKit - In-App Purchase Solution
Version

This documentation is for godot-iap v1.0 which includes StoreKit 2 for iOS and Google Play Billing v8+ for Android. Native code is powered by openiap.

A comprehensive in-app purchase plugin for Godot 4.x that conforms to the Open IAP specification.

Godot IAP Logo

What is godot-iap?

This is an In App Purchase plugin for Godot Engine. This project has been inspired by expo-iap, flutter_inapp_purchase and react-native-iap. We are trying to share the same experience of in-app-purchase in Godot Engine as in other cross-platform frameworks.

We will keep working on it as time goes by just like we did in expo-iap, flutter_inapp_purchase, kmp-iap and react-native-iap.

Key Features

  • Cross-Platform: Unified GDScript API for both iOS and Android
  • StoreKit 2 Support: Full StoreKit 2 support for iOS 15.0+
  • Billing Client v8+: Latest Android Google Play Billing features
  • Type-safe: Complete type safety with GDScript's static typing
  • Signal-based: Event-driven architecture with Godot signals
  • OpenIAP Compliant: Follows the standardized OpenIAP specification

What this library does

  • Product Management: Fetch and manage consumable and non-consumable products
  • Purchase Flow: Handle complete purchase workflows with proper error handling
  • Subscription Support: Full subscription lifecycle management
  • Receipt Validation: Validate purchases on both platforms
  • Store Communication: Direct communication with App Store and Google Play
  • Error Recovery: Comprehensive error handling and recovery mechanisms

Platform Support

FeatureiOSAndroid
Products & Subscriptions
Purchase Flow
Receipt Validation
Subscription Management
Promotional OffersN/A
StoreKit 2N/A
Billing Client v8+N/A

Version Information

  • Current Version: 1.0
  • Godot Compatibility: Godot 4.3+
  • iOS Requirements: iOS 15.0+, Xcode 16+ (Swift 6.0+) (via openiap)
  • Android Requirements: API level 24+ (via openiap)

Quick Start

Get started with godot-iap in minutes:

extends Node

const Types = preload("res://addons/godot-iap/types.gd")

@onready var iap = $GodotIapWrapper # Add GodotIapWrapper as child node

func _ready():
_setup_signals()
iap.init_connection()

func _setup_signals():
iap.purchase_updated.connect(_on_purchase_updated)
iap.purchase_error.connect(_on_purchase_error)
iap.connected.connect(_on_connected)

Fetch Products

func _on_connected():
# Create a typed request
var request = Types.ProductRequest.new()
var skus: Array[String] = ["your.product.id", "your.subscription.id"]
request.skus = skus
request.type = Types.ProductQueryType.ALL # or IN_APP, SUBS

# Returns Array of typed ProductAndroid or ProductIOS
var products = iap.fetch_products(request)
for product in products:
print("Product: ", product.title, " - ", product.display_price)

Handle Purchases

func purchase_product(product_id: String):
var props = Types.RequestPurchaseProps.new()
props.type = Types.ProductQueryType.IN_APP
props.request = Types.RequestPurchasePropsByPlatforms.new()
props.request.google = Types.RequestPurchaseAndroidProps.new()
var skus: Array[String] = [product_id]
props.request.google.skus = skus
props.request.apple = Types.RequestPurchaseIOSProps.new()
props.request.apple.sku = product_id

var purchase = iap.request_purchase(props)
if purchase:
print("Purchase initiated: ", purchase.product_id)

func _on_purchase_updated(purchase_dict: Dictionary):
var product_id = purchase_dict.get("productId", "")

# Finish the transaction (use finish_transaction_dict for Dictionary input)
var result = iap.finish_transaction_dict(purchase_dict, true) # true = consumable
print("Transaction finished: ", result.success)

func _on_purchase_error(error_dict: Dictionary):
print("Error: ", error_dict.get("code"), " - ", error_dict.get("message"))

Start Building Today

Community & Support

This project is maintained by hyochan.


Ready to implement in-app purchases in your Godot game? Let's get started!