Commit c5aaecc3 authored by Grant Arundell's avatar Grant Arundell Committed by Chris Molozian
Browse files

updates to iap verification modules

Coordinated work with mo debugging the Google IAP receipt validation.
parent a0cfd2ba
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -85,19 +85,22 @@ function M.google_obtain_access_token(client_email, private_key)

  local algo_type = "RS256"

  local jwt_claimset = nk.base64url_encode(nk.json_encode({
  local jwt_claimset = {
    ["iss"] = client_email,
    ["scope"] = scope,
    ["aud"] = auth_url,
    ["exp"] = exp,
    ["iat"] = iat
  }))
  }

  local jwt_token = nk.jwt_generate(algo_type, private_key, jwt_claimset)

  local grant_type = "urn%3ietf%3params%3oauth%3grant-type%3jwt-bearer"
  local form_data = "grant_type=" .. grant_type .. "&assertion=" .. jwt_token
  local http_headers = {["Content-Type"] = "application/x-www-form-urlencoded"}
  local http_headers = {
  ["Content-Type"] = "application/x-www-form-urlencoded",
  ["Accept"] = "application/json"
  }

  local success, code, _, body = pcall(nk.http_request, auth_url, "POST", http_headers, form_data)
  if (not success) then
+1 −1
Original line number Diff line number Diff line
@@ -109,7 +109,7 @@ https://developers.google.com/android-publisher/api-ref/purchases/subscriptions

local function google_verify_payment(context, payload)
  -- Google API Service Account JSON key file in base64.
  local service_account = nk.base64_decode(context.env["iap_google_service_account"])
  local service_account = nk.json_decode(nk.base64_decode(context.env["iap_google_service_account"]))

  local json_payload = nk.json_decode(payload)
  local product_id = json_payload.product_id