use of com.braintreepayments.api.internal.BraintreeHttpClient in project braintree_android by braintree.
the class UnionPayUnitTest method tokenize_sendsPayloadToEndpoint.
@Test
public void tokenize_sendsPayloadToEndpoint() throws JSONException {
UnionPayCardBuilder unionPayCardBuilder = new UnionPayCardBuilder().cardNumber("someCardNumber").expirationMonth("expirationMonth").expirationYear("expirationYear").cvv("cvv").enrollmentId("enrollmentId").smsCode("smsCode").validate(true);
BraintreeHttpClient httpClient = mock(BraintreeHttpClient.class);
doNothing().when(httpClient).get(anyString(), any(HttpResponseCallback.class));
when(mBraintreeFragment.getHttpClient()).thenReturn(httpClient);
ArgumentCaptor<String> argumentCaptor = ArgumentCaptor.forClass(String.class);
UnionPay.tokenize(mBraintreeFragment, unionPayCardBuilder);
verify(httpClient).post(eq("/v1/payment_methods/credit_cards"), argumentCaptor.capture(), any(HttpResponseCallback.class));
JSONObject tokenizePayload = new JSONObject(argumentCaptor.getValue());
JSONObject creditCardPayload = tokenizePayload.getJSONObject("creditCard");
JSONObject optionsPayload = creditCardPayload.getJSONObject("options");
JSONObject unionPayEnrollmentPayload = optionsPayload.getJSONObject("unionPayEnrollment");
assertEquals("someCardNumber", creditCardPayload.getString("number"));
assertEquals("expirationMonth", creditCardPayload.getString("expirationMonth"));
assertEquals("expirationYear", creditCardPayload.getString("expirationYear"));
assertEquals("cvv", creditCardPayload.getString("cvv"));
assertFalse(optionsPayload.has("validate"));
assertEquals("enrollmentId", unionPayEnrollmentPayload.getString("id"));
assertEquals("smsCode", unionPayEnrollmentPayload.getString("smsCode"));
}
use of com.braintreepayments.api.internal.BraintreeHttpClient in project braintree_android by braintree.
the class UnionPayUnitTest method fetchCapabilities_sendsPayloadToEndpoint.
@Test
public void fetchCapabilities_sendsPayloadToEndpoint() {
BraintreeFragment fragment = new MockFragmentBuilder().configuration(mConfigurationWithUnionPay).build();
BraintreeHttpClient httpClient = mock(BraintreeHttpClient.class);
doNothing().when(httpClient).get(anyString(), any(HttpResponseCallback.class));
when(fragment.getHttpClient()).thenReturn(httpClient);
UnionPay.fetchCapabilities(fragment, UNIONPAY_CREDIT);
String expectedUrl = Uri.parse("/v1/payment_methods/credit_cards/capabilities").buildUpon().appendQueryParameter("creditCard[number]", UNIONPAY_CREDIT).build().toString();
verify(httpClient).get(eq(expectedUrl), any(HttpResponseCallback.class));
}
Aggregations