@Test public void getAuthorizationUrl_whenProvidedBadUrl_doesNotCrash() { PaymentIntent paymentIntent = PaymentIntent.fromString( EXAMPLE_PAYMENT_INTENT_SOURCE_WITH_BAD_AUTH_URL); Uri authUrl = paymentIntent.getAuthorizationUrl(); assertEquals(BAD_URL, authUrl.getEncodedPath()); }
@Nullable public static PaymentIntent fromString(@Nullable String jsonString) { try { return fromJson(new JSONObject(jsonString)); } catch (JSONException ignored) { return null; } }
final RequestOptions loggingOptions = RequestOptions.builder(publishableKey).build(); logApiCall(loggingParams, loggingOptions, loggingResponseListener); final String paymentIntentId = PaymentIntent.parseIdFromClientSecret( paymentIntentParams.getClientSecret()); final StripeResponse response = requestData(GET, retrievePaymentIntentUrl(paymentIntentId), paramMap, options); return PaymentIntent.fromString(response.getResponseBody()); } catch (CardException unexpected) {
@Before public void setup() { mPaymentIntent = PaymentIntent.fromString(EXAMPLE_PAYMENT_INTENT_SOURCE); assertNotNull(mPaymentIntent); }
@Test public void parseIdFromClientSecret_parsesCorrectly() { String clientSecret = "pi_1CkiBMLENEVhOs7YMtUehLau_secret_s4O8SDh7s6spSmHDw1VaYPGZA"; String id = PaymentIntent.parseIdFromClientSecret(clientSecret); assertEquals("pi_1CkiBMLENEVhOs7YMtUehLau", id); }
@Test public void fromJsonString_toMap_createsExpectedMap() { Map<String, Object> paymentIntentMap = mPaymentIntent.toMap(); assertMapEquals(paymentIntentMap, EXAMPLE_PAYMENT_INTENT_MAP); }
String source = optString(jsonObject, FIELD_SOURCE); return new PaymentIntent( id, objectType,
@Test public void fromJsonString_backToJson_createsIdenticalElement() { try { JSONObject rawConversion = new JSONObject(EXAMPLE_PAYMENT_INTENT_SOURCE); JSONObject actualObject = mPaymentIntent.toJson(); assertJsonEqualsExcludingNulls(rawConversion, actualObject); } catch (JSONException jsonException) { fail("Test Data failure: " + jsonException.getLocalizedMessage()); } }
RequestOptions loggingOptions = RequestOptions.builder(publishableKey).build(); logApiCall(loggingParams, loggingOptions, loggingResponseListener); final String paymentIntentId = PaymentIntent.parseIdFromClientSecret( paymentIntentParams.getClientSecret()); final StripeResponse response = requestData( POST, confirmPaymentIntentUrl(paymentIntentId), paramMap, options); return PaymentIntent.fromString(response.getResponseBody()); } catch (CardException unexpected) {