@Override public PaymentIntent call() throws Exception { PaymentIntentParams paymentIntentParams = PaymentIntentParams.createRetrievePaymentIntentParams(clientSecret); return mStripe.retrievePaymentIntentSynchronous( paymentIntentParams, PaymentConfiguration.getInstance().getPublishableKey()); } });
@Test public void toParamMap_whenExtraParamsProvided_createsExpectedMap() { PaymentIntentParams paymentIntentParams = PaymentIntentParams.createRetrievePaymentIntentParams( TEST_CLIENT_SECRET); Map<String, Object> extraParams = new HashMap<>(); String extraParamKey1 = "extra_param_key_1"; String extraParamKey2 = "extra_param_key_2"; String extraParamValue1 = "extra_param_value_1"; String extraParamValue2 = "extra_param_value_2"; extraParams.put(extraParamKey1, extraParamValue1); extraParams.put(extraParamKey2, extraParamValue2); paymentIntentParams.setExtraParams(extraParams); Map<String, Object> paramMap = paymentIntentParams.toParamMap(); Assert.assertEquals( paramMap.get(PaymentIntentParams.API_PARAM_CLIENT_SECRET), TEST_CLIENT_SECRET); Assert.assertEquals( paramMap.get(extraParamKey1), extraParamValue1); Assert.assertEquals( paramMap.get(extraParamKey2), extraParamValue2); }
@Ignore public void disabled_confirmRetrieve_withSourceId_canSuccessfulRetrieve() { String clientSecret = "temporarily put a private key here simulate the backend"; String publicKey = "put a public key that matches the private key here"; try { PaymentIntentParams paymentIntentParams = PaymentIntentParams.createRetrievePaymentIntentParams( clientSecret ); PaymentIntent paymentIntent = StripeApiHandler.retrievePaymentIntent( ApplicationProvider.getApplicationContext(), paymentIntentParams, publicKey, null, null); assertNotNull(paymentIntent); } catch (AuthenticationException authEx) { fail("Unexpected error: " + authEx.getLocalizedMessage()); } catch (StripeException stripeEx) { fail("Unexpected error when connecting to Stripe API: " + stripeEx.getLocalizedMessage()); } }
@Test public void createRetrievePaymentIntentWithSourceIdParams_hasExpectedFields() { PaymentIntentParams params = PaymentIntentParams.createRetrievePaymentIntentParams( TEST_CLIENT_SECRET); Assert.assertEquals(TEST_CLIENT_SECRET, params.getClientSecret()); Assert.assertNull(params.getReturnUrl()); Assert.assertNull(params.getExtraParams()); Assert.assertNull(params.getSourceId()); Assert.assertNull(params.getSourceParams()); }