use of com.paypal.android.sdk.onetouch.core.exception.WalletSwitchException in project braintree_android by braintree.
the class AppSwitchHelperUnitTest method parseAppSwitchResponse_parsesErrorAndReturnsResult.
@Test
public void parseAppSwitchResponse_parsesErrorAndReturnsResult() {
Request request = mock(AuthorizationRequest.class);
when(request.validateV1V2Response(any(ContextInspector.class), any(Bundle.class))).thenReturn(true);
Intent intent = new Intent().putExtra("error", "there was an error");
Result result = AppSwitchHelper.parseAppSwitchResponse(mContextInspector, request, intent);
verify(request).trackFpti(any(Context.class), eq(TrackingPoint.Return), isNull(Protocol.class));
assertTrue(result.getError() instanceof WalletSwitchException);
assertEquals("there was an error", result.getError().getMessage());
}
use of com.paypal.android.sdk.onetouch.core.exception.WalletSwitchException in project braintree_android by braintree.
the class AppSwitchHelper method processResponseIntent.
private static Result processResponseIntent(Bundle bundle) {
String error = bundle.getString("error");
if (!TextUtils.isEmpty(error)) {
return new Result(new WalletSwitchException(error));
} else {
String environment = bundle.getString("environment");
String bundleResponseType = bundle.getString("response_type").toLowerCase(Locale.US);
ResponseType response_type;
if ("code".equals(bundleResponseType)) {
response_type = ResponseType.authorization_code;
} else {
response_type = ResponseType.web;
}
try {
if (ResponseType.web == response_type) {
String webURL = bundle.getString("webURL");
return new Result(environment, response_type, new JSONObject().put("webURL", webURL), // email not sent back in checkout requests since Hermes doesn't return that info
null);
} else {
String authorization_code = bundle.getString("authorization_code");
String email = bundle.getString("email");
return new Result(environment, response_type, new JSONObject().put("code", authorization_code), email);
}
} catch (JSONException e) {
return new Result(new ResponseParsingException(e));
}
}
}
use of com.paypal.android.sdk.onetouch.core.exception.WalletSwitchException in project braintree_android by braintree.
the class AppSwitchHelperUnitTest method parseAppSwitchResponse_parsesErrorForErrorResponses.
@Test
public void parseAppSwitchResponse_parsesErrorForErrorResponses() {
Request request = mock(AuthorizationRequest.class);
when(request.validateV1V2Response(any(ContextInspector.class), any(Bundle.class))).thenReturn(false);
Intent intent = new Intent().putExtra("error", "there was an error");
Result result = AppSwitchHelper.parseAppSwitchResponse(mContextInspector, request, intent);
verify(request).trackFpti(any(Context.class), eq(TrackingPoint.Error), isNull(Protocol.class));
assertTrue(result.getError() instanceof WalletSwitchException);
assertEquals("there was an error", result.getError().getMessage());
}
Aggregations