@Test public void testHandle3DSecureResultCallsCompleteIfResultOK() { int validRequestCode = Gateway.REQUEST_3D_SECURE; int resultCode = Activity.RESULT_OK; Intent data = mock(Intent.class); String acsResultJson = "{\"foo\":\"bar\"}"; Gateway3DSecureCallback callback = spy(new Gateway3DSecureCallback() { @Override public void on3DSecureComplete(GatewayMap response) { assertNotNull(response); assertTrue(response.containsKey("foo")); assertEquals("bar", response.get("foo")); } @Override public void on3DSecureCancel() { fail("Should never have called cancel"); } }); doReturn(acsResultJson).when(data).getStringExtra(Gateway3DSecureActivity.EXTRA_ACS_RESULT); boolean result = Gateway.handle3DSecureResult(validRequestCode, resultCode, data, callback); assertTrue(result); verify(callback).on3DSecureComplete(any()); }
public static boolean handle3DSecureResult(int requestCode, int resultCode, Intent data, Gateway3DSecureCallback callback) { if (callback == null) { return false; } if (requestCode == REQUEST_3D_SECURE) { if (resultCode == Activity.RESULT_OK) { String acsResultJson = data.getStringExtra(Gateway3DSecureActivity.EXTRA_ACS_RESULT); GatewayMap acsResult = new GatewayMap(acsResultJson); callback.on3DSecureComplete(acsResult); } else { callback.on3DSecureCancel(); } return true; } return false; }
Gateway { public static boolean handle3DSecureResult(int requestCode, int resultCode, Intent data, Gateway3DSecureCallback callback) { if (callback == null) { return false; } if (requestCode == REQUEST_3D_SECURE) { if (resultCode == Activity.RESULT_OK) { String acsResultJson = data.getStringExtra(Gateway3DSecureActivity.EXTRA_ACS_RESULT); GatewayMap acsResult = new GatewayMap(acsResultJson); callback.on3DSecureComplete(acsResult); } else { callback.on3DSecureCancel(); } return true; } return false; } }
Gateway { public static boolean handle3DSecureResult(int requestCode, int resultCode, Intent data, Gateway3DSecureCallback callback) { if (callback == null) { return false; } if (requestCode == REQUEST_3D_SECURE) { if (resultCode == Activity.RESULT_OK) { String acsResultJson = data.getStringExtra(Gateway3DSecureActivity.EXTRA_ACS_RESULT); GatewayMap acsResult = new GatewayMap(acsResultJson); callback.on3DSecureComplete(acsResult); } else { callback.on3DSecureCancel(); } return true; } return false; } Gateway(); }
Gateway { public static boolean handle3DSecureResult(int requestCode, int resultCode, Intent data, Gateway3DSecureCallback callback) { if (callback == null) { return false; } if (requestCode == REQUEST_3D_SECURE) { if (resultCode == Activity.RESULT_OK) { String acsResultJson = data.getStringExtra(Gateway3DSecureActivity.EXTRA_ACS_RESULT); GatewayMap acsResult = new GatewayMap(acsResultJson); callback.on3DSecureComplete(acsResult); } else { callback.on3DSecureCancel(); } return true; } return false; } Gateway(); String getMerchantId(); Gateway setMerchantId(String merchantId); Region getRegion(); Gateway setRegion(Region region); void updateSession(String sessionId, String apiVersion, GatewayMap payload, GatewayCallback callback); Single<GatewayMap> updateSession(String sessionId, String apiVersion, GatewayMap payload); static void start3DSecureActivity(Activity activity, String html); static void start3DSecureActivity(Activity activity, String html, String title); static boolean handle3DSecureResult(int requestCode, int resultCode, Intent data, Gateway3DSecureCallback callback); static void requestGooglePayData(PaymentsClient paymentsClient, PaymentDataRequest request, Activity activity); static boolean handleGooglePayResult(int requestCode, int resultCode, Intent data, GatewayGooglePayCallback callback); }
Gateway { public static boolean handle3DSecureResult(int requestCode, int resultCode, Intent data, Gateway3DSecureCallback callback) { if (callback == null) { return false; } if (requestCode == REQUEST_3D_SECURE) { if (resultCode == Activity.RESULT_OK) { String acsResultJson = data.getStringExtra(Gateway3DSecureActivity.EXTRA_ACS_RESULT); GatewayMap acsResult = new GatewayMap(acsResultJson); callback.on3DSecureComplete(acsResult); } else { callback.on3DSecureCancel(); } return true; } return false; } Gateway(); String getMerchantId(); Gateway setMerchantId(String merchantId); Region getRegion(); Gateway setRegion(Region region); void updateSession(String sessionId, String apiVersion, GatewayMap payload, GatewayCallback callback); Single<GatewayMap> updateSession(String sessionId, String apiVersion, GatewayMap payload); static void start3DSecureActivity(Activity activity, String html); static void start3DSecureActivity(Activity activity, String html, String title); static boolean handle3DSecureResult(int requestCode, int resultCode, Intent data, Gateway3DSecureCallback callback); static void requestGooglePayData(PaymentsClient paymentsClient, PaymentDataRequest request, Activity activity); static boolean handleGooglePayResult(int requestCode, int resultCode, Intent data, GatewayGooglePayCallback callback);  }