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
- Android
- iOS
- Web
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)
}
}
let products = try await VLPlaySDK.iap.getProducts(
ids: ["gem_100", "gem_500", "gem_1000"]
)
products.forEach { print("\($0.name): \($0.localizedPrice)") }
const products = await VLPlaySDK.iap.getProducts(['gem_100', 'gem_500']);
products.forEach(p => console.log(`${p.name}: ${p.localizedPrice}`));
Purchase Flow
- Android
- iOS
- Web
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)
}
}
let purchase = try await VLPlaySDK.iap.purchase(productId: "gem_100")
if purchase.verified {
givePlayerGems(100)
}
const result = await VLPlaySDK.iap.purchase({ productId: 'gem_100' });
if (result.success) {
givePlayerGems(100);
}