diff --git a/CHANGELOG.md b/CHANGELOG.md index b917fcef065a0ffb471620f652e2b0e9978693dd..7fc6e900c513aaeb3a73c010c836244ca01b8755 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ The format is based on [keep a changelog](http://keepachangelog.com) and this pr ### Changed - Do not use absolute path for `tini` executable in default container entrypoint. - Faster validation of JSON object input payloads. +- Update IAP validation example for Android Publisher v3 API. ### Fixed - Correctly read pagination cursor in notification listings. diff --git a/data/modules/iap_verifier.lua b/data/modules/iap_verifier.lua index 4e38bacca919f134c56888c87c14d0d128013fe5..8bc256c2557b978dd64c1b689a4f673c7877044f 100644 --- a/data/modules/iap_verifier.lua +++ b/data/modules/iap_verifier.lua @@ -85,7 +85,6 @@ function M.google_obtain_access_token(client_email, private_key) local iat = nk.time() / 1000 local exp = iat + 3600 -- current time + 1hr added in seconds - local algo_type = "RS256" local jwt_claimset = { @@ -132,10 +131,10 @@ Request object match the following format: } For Products, this function will return a Lua table that represents the data in this page: -https://developers.google.com/android-publisher/api-ref/purchases/products#resource +https://developers.google.com/android-publisher/api-ref/#Purchases.products For Subscritions, this function will return a Lua table that represents the data in this page: -https://developers.google.com/android-publisher/api-ref/purchases/subscriptions +https://developers.google.com/android-publisher/api-ref/#Purchases.subscriptions This function can also raise an error in case of bad network, bad authentication or invalid receipt data. --]] @@ -147,13 +146,13 @@ function M.verify_payment_google(request) error(access_token) end - local url_template = "https://www.googleapis.com/androidpublisher/v2/applications/%s/purchases/subscriptions/%s/tokens/%s?access_token=%s" + local url = "https://www.googleapis.com/androidpublisher/v3/applications/%s/purchases/subscriptions/%s/tokens/%s?access_token=%s" if (not request.is_subscription) then - url_template = "https://www.googleapis.com/androidpublisher/v2/applications/%s/purchases/products/%s/tokens/%s?access_token=%s" + url = "https://www.googleapis.com/androidpublisher/v3/applications/%s/purchases/products/%s/tokens/%s?access_token=%s" end - local url = url_template:format(request.package_name, request.product_id, request.purchase_token, access_token) - + url = url:format(request.package_name, request.product_id, request.purchase_token, access_token) + local http_headers = { ["Content-Type"] = "application/json", ["Accept"] = "application/json" diff --git a/data/modules/iap_verifier_rpc.lua b/data/modules/iap_verifier_rpc.lua index 577f05d16fee9a8ac1018b2b4bd5e3ce0725c9c5..217c04df98013f3bcd96d8e7596eba5bc6d26f67 100644 --- a/data/modules/iap_verifier_rpc.lua +++ b/data/modules/iap_verifier_rpc.lua @@ -72,7 +72,6 @@ local function apple_verify_payment(context, payload) ["result"] = result }) end - end nk.register_rpc(apple_verify_payment, "iap.apple_verify_payment")