Billing Validation
Class Index com.ikame.android.sdk.billing.IKBilling
Verify Google Play Services for In-App Purchases
This function determines if the Google Play Billing (In-App Billing) service is available on the device. It is essential for ensuring that the device can handle in-app purchases before attempting any IAP operations.
fun isIabServiceAvailable(context: Context?): Boolean
Example
Verify Previous User Purchases
Used in cases where the user changes phones or has made a purchase before.
fun reCheckIAP(
listener: IKBillingListener?,
hasDelay: Boolean = false
)
Parameters:
-
listener
: TheIKBillingListener
interface is designed to handle the billing process callbacks within an application. It provides methods for responding to the outcomes of billing actions.-
onBillingSuccess()
: Called when the billing process completes successfully. -
onBillingFail()
: Called when the billing process fails.
-
-
hasDelay
: This optional parameter determines whether the re-check process should be delayed. If set to true, the function will wait a specified time before starting the re-check (useful in some UI or background task scenarios). The default value is false, meaning no delay.
Example
Verify User’s In-App and Subscription Purchases
fun isUserIAPAvailableAsync(): Boolean
Example
Verify User’s Purchase of a Specific Package
To check if the user has purchased a specific in-app purchase or subscription package, use the isProductIAPAsync()
method, which takes a product (of type SdkIapPackageDto
) as an argument.
fun isProductIAPAsync(product: SdkIapPackageDto): Boolean