Chuyển tới nội dung chính

In-App Purchase

VLPlay SDK provides a unified purchase API across Google Play Billing, App Store StoreKit 2, and Web payment (via VLPlay WebPay). [PLACEHOLDER] You define your products once in the VLPlay Developer Portal and the SDK handles the platform-specific purchase flow, receipt validation, and delivery confirmation automatically. Your server receives a webhook on successful purchase.

[PLACEHOLDER] All purchases are verified server-to-server by VLPlay before the SDK resolves the purchase result. This prevents client-side fraud and ensures your virtual currency or item delivery is reliable.

Fetch Products

VLPlaySDK.iap.getProducts(
productIds = listOf("gem_100", "gem_500", "gem_1000")
) { result ->
when (result) {
is IAPResult.Products -> result.products.forEach { product ->
Log.d("VLPlay", "${product.name}: ${product.localizedPrice}")
}
is IAPResult.Error -> Log.e("VLPlay", result.message)
}
}

Purchase Flow

VLPlaySDK.iap.purchase(activity, productId = "gem_100") { result ->
when (result) {
is PurchaseResult.Success -> {
// Deliver items — SDK has already verified with server
givePlayerGems(100)
}
is PurchaseResult.Cancelled -> { /* user cancelled */ }
is PurchaseResult.Error -> Log.e("VLPlay", result.message)
}
}