Commit 2b926c6a authored by Mo Firouz's avatar Mo Firouz
Browse files

Better handling of Apple sandbox IAP receipts.

parent 472dabf0
Loading
Loading
Loading
Loading
+13 −11
Original line number Diff line number Diff line
@@ -60,11 +60,12 @@ function M.verify_payment_apple(request)
  if (not success) then
    nk.logger_warn(("Network error occurred: %q"):format(code))
    error(code)
  elseif (code == 200) then
    return nk.json_decode(body)
  elseif (code == 400) then
  else
    if (code == 200) then
      local response = nk.json_decode(body)
    if (response.status == 21007) then  -- was supposed to be sent to sandbox
      if (response.status == 0) then
        return response
      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))
@@ -74,6 +75,7 @@ function M.verify_payment_apple(request)
        end
      end
    end
  end
  error(body)
end