public static Result parseBrowserSwitchResponse(ContextInspector contextInspector, Request request, Uri uri) { Result result = request.parseBrowserResponse(contextInspector, uri); switch (result.getResultType()) { case Error: request.trackFpti(contextInspector.getContext(), TrackingPoint.Error, null); break; case Cancel: request.trackFpti(contextInspector.getContext(), TrackingPoint.Cancel, null); break; case Success: request.trackFpti(contextInspector.getContext(), TrackingPoint.Return, null); break; } return result; } }
public static Intent getBrowserSwitchIntent(ContextInspector contextInspector, ConfigManager configManager, Request request) { OtcConfiguration configuration = configManager.getConfig(); try { String url = request.getBrowserSwitchUrl(contextInspector.getContext(), configuration); Recipe<?> recipe = request.getBrowserSwitchRecipe(configuration); for (String allowedBrowserPackage : recipe.getTargetPackagesInReversePriorityOrder()) { boolean canIntentBeResolved = Recipe.isValidBrowserTarget(contextInspector.getContext(), url, allowedBrowserPackage); if (canIntentBeResolved) { request.trackFpti(contextInspector.getContext(), TrackingPoint.SwitchToBrowser, recipe.getProtocol()); return Recipe.getBrowserIntent(contextInspector.getContext(), url, allowedBrowserPackage); } } } catch (CertificateException | UnsupportedEncodingException | NoSuchPaddingException | NoSuchAlgorithmException | IllegalBlockSizeException | JSONException | BadPaddingException | InvalidEncryptionDataException | InvalidKeyException ignored) {} return null; }
public static Result parseAppSwitchResponse(ContextInspector contextInspector, Request request, Intent data) { Bundle bundle = data.getExtras(); if (request.validateV1V2Response(contextInspector, bundle)) { request.trackFpti(contextInspector.getContext(), TrackingPoint.Return, null); return processResponseIntent(bundle); } else { if (bundle.containsKey("error")) { request.trackFpti(contextInspector.getContext(), TrackingPoint.Error, null); return new Result(new WalletSwitchException(bundle.getString("error"))); } else { request.trackFpti(contextInspector.getContext(), TrackingPoint.Error, null); return new Result(new ResponseParsingException("invalid wallet response")); } } }
public static Intent getAppSwitchIntent(ContextInspector contextInspector, ConfigManager configManager, Request request, Recipe recipe) { Intent intent = createBaseIntent(recipe.getTargetIntentAction(), WALLET_APP_PACKAGE) .putExtra("version", recipe.getProtocol().getVersion()) .putExtra("app_guid", InstallationIdentifier.getInstallationGUID(contextInspector.getContext())) .putExtra("client_metadata_id", request.getClientMetadataId()) .putExtra("client_id", request.getClientId()) .putExtra("app_name", DeviceInspector.getApplicationInfoName(contextInspector.getContext())) .putExtra("environment", request.getEnvironment()) .putExtra("environment_url", EnvironmentManager.getEnvironmentUrl(request.getEnvironment())); if (request instanceof AuthorizationRequest) { AuthorizationRequest authorizationRequest = (AuthorizationRequest) request; intent.putExtra("scope", authorizationRequest.getScopeString()) .putExtra("response_type", "code") .putExtra("privacy_url", authorizationRequest.getPrivacyUrl()) .putExtra("agreement_url", authorizationRequest.getUserAgreementUrl()); } else { CheckoutRequest checkoutRequest = (CheckoutRequest) request; String webURL = checkoutRequest.getBrowserSwitchUrl(contextInspector.getContext(), configManager.getConfig()); intent.putExtra("response_type", "web") .putExtra("webURL", webURL); } return intent; }
String deviceId = URLEncoderHelper.encode(InstallationIdentifier.getInstallationGUID(mContextInspector.getContext())); String abcde = "mobile:otc:" + point.getCd() + ":" + (null != protocol ? protocol.name() : ""); // also known as 'pagename' String xyz = "Android:" + environmentName + ":"; params.put("apid", DeviceInspector.getApplicationInfoName(mContextInspector.getContext()) + "|" + BuildConfig.VERSION_NAME + "|" + mContextInspector.getContext().getPackageName()); params.put("bchn", "otc"); params.put("bzsr", "mobile"); params.put("lgin", "out"); params.put("mapv", BuildConfig.VERSION_NAME); params.put("mcar", DeviceInspector.getSimOperatorName(mContextInspector.getContext())); params.put("mdvs", DeviceInspector.getDeviceName()); params.put("mosv", DeviceInspector.getOs());
when(contextInspector.getContext()).thenReturn(context);