Loading data/modules/iap_verifier.lua +6 −6 Original line number Diff line number Diff line Loading @@ -58,7 +58,7 @@ function M.verify_payment_apple(request) local success, code, _, body = pcall(nk.http_request, url_production, "POST", http_headers, http_body) if (not success) then nk.logger_warn(("Network error occurred: %q"):format(code)) nk.logger_warn(string.format("Network error occurred: %q", code)) error(code) else if (code == 200) then Loading @@ -68,7 +68,7 @@ function M.verify_payment_apple(request) elseif (response.status == 21007) then -- was supposed to be sent to sandbox local success, code, _, body = pcall(nk.http_request, url_sandbox, "POST", http_headers, http_body) if (not success) then nk.logger_warn(("Network error occurred: %q"):format(code)) nk.logger_warn(string.format("Network error occurred: %q", code)) error(code) elseif (code == 200) then return nk.json_decode(body) Loading Loading @@ -106,7 +106,7 @@ function M.google_obtain_access_token(client_email, private_key) local success, code, _, body = pcall(nk.http_request, auth_url, "POST", http_headers, form_data) if (not success) then nk.logger_warn(("Network error occurred: %q"):format(code)) nk.logger_warn(string.format("Network error occurred: %q", code)) error(code) elseif (code == 200) then return nk.json_decode(body)["access_token"] Loading Loading @@ -142,7 +142,7 @@ This function can also raise an error in case of bad network, bad authentication function M.verify_payment_google(request) local success, access_token = pcall(M.google_obtain_access_token, request.client_email, request.private_key) if (not success) then nk.logger_warn(("Failed to obtain access token: %q"):format(access_token)) nk.logger_warn(string.format("Failed to obtain access token: %q", access_token)) error(access_token) end Loading @@ -151,7 +151,7 @@ function M.verify_payment_google(request) url = "https://www.googleapis.com/androidpublisher/v3/applications/%s/purchases/products/%s/tokens/%s?access_token=%s" end url = url:format(request.package_name, request.product_id, request.purchase_token, access_token) url = string.format(url, request.package_name, request.product_id, request.purchase_token, access_token) local http_headers = { ["Content-Type"] = "application/json", Loading @@ -159,7 +159,7 @@ function M.verify_payment_google(request) } local success, code, _, body = pcall(nk.http_request, url, "GET", http_headers, nil) if (not success) then nk.logger_warn(("Network error occurred: %q"):format(code)) nk.logger_warn(string.format("Network error occurred: %q", code)) error(code) elseif (code == 200) then return nk.json_decode(body) Loading data/modules/iap_verifier_rpc.lua +4 −4 Original line number Diff line number Diff line Loading @@ -60,13 +60,13 @@ local function apple_verify_payment(context, payload) }) if (not success) then nk.logger_warn(("Apple IAP verification failed - request: %q - response: %q"):format(payload, result)) nk.logger_warn(string.format("Apple IAP verification failed - request: %q - response: %q", payload, result)) return nk.json_encode({ ["success"] = false, ["error"] = result }) else nk.logger_info(("Apple IAP verification completed - request: %q - response: %q"):format(payload, result)) nk.logger_info(string.format("Apple IAP verification completed - request: %q - response: %q", payload, result)) return nk.json_encode({ ["success"] = true, ["result"] = result Loading Loading @@ -126,13 +126,13 @@ local function google_verify_payment(context, payload) }) if (not success) then nk.logger_warn(("Google IAP verification failed - request: %q - response: %q"):format(payload, result)) nk.logger_warn(string.format("Google IAP verification failed - request: %q - response: %q", payload, result)) return nk.json_encode({ ["success"] = false, ["error"] = result }) else nk.logger_info(("Google IAP verification completed - request: %q - response: %q"):format(payload, result)) nk.logger_info(string.format("Google IAP verification completed - request: %q - response: %q", payload, result)) return nk.json_encode({ ["success"] = true, ["result"] = result Loading Loading
data/modules/iap_verifier.lua +6 −6 Original line number Diff line number Diff line Loading @@ -58,7 +58,7 @@ function M.verify_payment_apple(request) local success, code, _, body = pcall(nk.http_request, url_production, "POST", http_headers, http_body) if (not success) then nk.logger_warn(("Network error occurred: %q"):format(code)) nk.logger_warn(string.format("Network error occurred: %q", code)) error(code) else if (code == 200) then Loading @@ -68,7 +68,7 @@ function M.verify_payment_apple(request) elseif (response.status == 21007) then -- was supposed to be sent to sandbox local success, code, _, body = pcall(nk.http_request, url_sandbox, "POST", http_headers, http_body) if (not success) then nk.logger_warn(("Network error occurred: %q"):format(code)) nk.logger_warn(string.format("Network error occurred: %q", code)) error(code) elseif (code == 200) then return nk.json_decode(body) Loading Loading @@ -106,7 +106,7 @@ function M.google_obtain_access_token(client_email, private_key) local success, code, _, body = pcall(nk.http_request, auth_url, "POST", http_headers, form_data) if (not success) then nk.logger_warn(("Network error occurred: %q"):format(code)) nk.logger_warn(string.format("Network error occurred: %q", code)) error(code) elseif (code == 200) then return nk.json_decode(body)["access_token"] Loading Loading @@ -142,7 +142,7 @@ This function can also raise an error in case of bad network, bad authentication function M.verify_payment_google(request) local success, access_token = pcall(M.google_obtain_access_token, request.client_email, request.private_key) if (not success) then nk.logger_warn(("Failed to obtain access token: %q"):format(access_token)) nk.logger_warn(string.format("Failed to obtain access token: %q", access_token)) error(access_token) end Loading @@ -151,7 +151,7 @@ function M.verify_payment_google(request) url = "https://www.googleapis.com/androidpublisher/v3/applications/%s/purchases/products/%s/tokens/%s?access_token=%s" end url = url:format(request.package_name, request.product_id, request.purchase_token, access_token) url = string.format(url, request.package_name, request.product_id, request.purchase_token, access_token) local http_headers = { ["Content-Type"] = "application/json", Loading @@ -159,7 +159,7 @@ function M.verify_payment_google(request) } local success, code, _, body = pcall(nk.http_request, url, "GET", http_headers, nil) if (not success) then nk.logger_warn(("Network error occurred: %q"):format(code)) nk.logger_warn(string.format("Network error occurred: %q", code)) error(code) elseif (code == 200) then return nk.json_decode(body) Loading
data/modules/iap_verifier_rpc.lua +4 −4 Original line number Diff line number Diff line Loading @@ -60,13 +60,13 @@ local function apple_verify_payment(context, payload) }) if (not success) then nk.logger_warn(("Apple IAP verification failed - request: %q - response: %q"):format(payload, result)) nk.logger_warn(string.format("Apple IAP verification failed - request: %q - response: %q", payload, result)) return nk.json_encode({ ["success"] = false, ["error"] = result }) else nk.logger_info(("Apple IAP verification completed - request: %q - response: %q"):format(payload, result)) nk.logger_info(string.format("Apple IAP verification completed - request: %q - response: %q", payload, result)) return nk.json_encode({ ["success"] = true, ["result"] = result Loading Loading @@ -126,13 +126,13 @@ local function google_verify_payment(context, payload) }) if (not success) then nk.logger_warn(("Google IAP verification failed - request: %q - response: %q"):format(payload, result)) nk.logger_warn(string.format("Google IAP verification failed - request: %q - response: %q", payload, result)) return nk.json_encode({ ["success"] = false, ["error"] = result }) else nk.logger_info(("Google IAP verification completed - request: %q - response: %q"):format(payload, result)) nk.logger_info(string.format("Google IAP verification completed - request: %q - response: %q", payload, result)) return nk.json_encode({ ["success"] = true, ["result"] = result Loading