use of com.paypal.android.sdk.onetouch.core.exception.ResponseParsingException in project braintree_android by braintree.
the class AuthorizationRequestUnitTest method parseBrowserSwitchResponse_returnsErrorForMissingPayloadInSuccessResponse.
@Test
public void parseBrowserSwitchResponse_returnsErrorForMissingPayloadInSuccessResponse() {
Uri uri = Uri.parse("com.braintreepayments.demo.braintree://onetouch/v1/success");
Result result = mRequest.parseBrowserResponse(mContextInspector, uri);
assertEquals(ResultType.Error, result.getResultType());
assertTrue(result.getError() instanceof ResponseParsingException);
assertEquals("Response incomplete", result.getError().getMessage());
}
use of com.paypal.android.sdk.onetouch.core.exception.ResponseParsingException in project braintree_android by braintree.
the class AuthorizationRequestUnitTest method parseBrowserResponse_returnsErrorForUnrecongnizedUri.
@Test
public void parseBrowserResponse_returnsErrorForUnrecongnizedUri() {
Uri uri = Uri.parse("com.braintreepayments.demo.braintree://onetouch/v1/abort?payload=eyJ0ZXN0IjoidGVzdCJ9");
Result result = mRequest.parseBrowserResponse(mContextInspector, uri);
assertEquals(ResultType.Error, result.getResultType());
assertTrue(result.getError() instanceof ResponseParsingException);
assertEquals("Response uri invalid", result.getError().getMessage());
}
use of com.paypal.android.sdk.onetouch.core.exception.ResponseParsingException in project braintree_android by braintree.
the class CheckoutRequest method parseBrowserResponse.
@Override
public Result parseBrowserResponse(ContextInspector contextInspector, Uri uri) {
String status = uri.getLastPathSegment();
if (!Uri.parse(getSuccessUrl()).getLastPathSegment().equals(status)) {
// return cancel result
return new Result();
}
String requestXoToken = Uri.parse(mApprovalUrl).getQueryParameter(mTokenQueryParamKey);
String responseXoToken = uri.getQueryParameter(mTokenQueryParamKey);
if (responseXoToken != null && TextUtils.equals(requestXoToken, responseXoToken)) {
try {
JSONObject response = new JSONObject();
response.put("webURL", uri.toString());
return new Result(null, /*don't know the environment here*/
ResponseType.web, response, null);
} catch (JSONException e) {
return new Result(new ResponseParsingException(e));
}
} else {
return new Result(new BrowserSwitchException("The response contained inconsistent data."));
}
}
use of com.paypal.android.sdk.onetouch.core.exception.ResponseParsingException in project braintree_android by braintree.
the class AppSwitchHelperUnitTest method parseAppSwitchResponse_returnsErrorWhenResponseCouldNotBeParsed.
@Test
public void parseAppSwitchResponse_returnsErrorWhenResponseCouldNotBeParsed() {
Request request = mock(AuthorizationRequest.class);
when(request.validateV1V2Response(any(ContextInspector.class), any(Bundle.class))).thenReturn(false);
Intent intent = new Intent().putExtra("braintree", "nonce");
Result result = AppSwitchHelper.parseAppSwitchResponse(mContextInspector, request, intent);
verify(request).trackFpti(any(Context.class), eq(TrackingPoint.Error), isNull(Protocol.class));
assertTrue(result.getError() instanceof ResponseParsingException);
assertEquals("invalid wallet response", result.getError().getMessage());
}
Aggregations