verify-google-purchase
This Edge Function verifies Google Play In-App Purchases (IAP) serverside using the Google Play Developer API.
Request Body
{
"productId": "light_monthly",
"purchaseToken": "token_string_from_google_play...",
"type": "subscription"
}
-
productId: The SKU ID of the product/subscription. -
purchaseToken: The purchase token returned by the Google Play Billing Library. -
type: currentlysubscription(consumable support planned).
Logic
-
Authenticate: Uses
GOOGLE_SERVICE_ACCOUNT_JSONsecret to authenticate with Google APIs. -
Verify: Calls
androidpublisher.purchases.subscriptions.get. -
Validate: Checks
expiryTimeMillisto ensure the subscription is active. -
Update DB:
-
Upserts
user_subscriptionstable. -
Sets
statustoactive(orcanceledif expired). -
Sets
providertogoogle. -
Stores
google_purchase_token.
-