@Override public PaymentIntent call() throws Exception { PaymentIntentParams paymentIntentParams = PaymentIntentParams.createConfirmPaymentIntentWithSourceDataParams( sourceParams, clientSecret, RETURN_URL); return mStripe.confirmPaymentIntentSynchronous( paymentIntentParams, PaymentConfiguration.getInstance().getPublishableKey()); } });
@Test public void createConfirmPaymentIntentWithSourceDataParams_withAllFields_hasExpectedFields() { SourceParams sourceParams = SourceParams.createCardParams(FULL_FIELDS_VISA_CARD); PaymentIntentParams params = PaymentIntentParams.createConfirmPaymentIntentWithSourceDataParams( sourceParams, TEST_CLIENT_SECRET, TEST_RETURN_URL); Assert.assertEquals(TEST_CLIENT_SECRET, params.getClientSecret()); Assert.assertEquals(TEST_RETURN_URL, params.getReturnUrl()); Assert.assertEquals(sourceParams, params.getSourceParams()); }
@Ignore public void disabled_confirmPaymentIntent_withSourceData_canSuccessfulConfirm() { String clientSecret = "temporarily put a private key here simulate the backend"; String publicKey = "put a public key that matches the private key here"; try { Card card = new Card("4242424242424242", 1, 2050, "123"); PaymentIntentParams paymentIntentParams = PaymentIntentParams.createConfirmPaymentIntentWithSourceDataParams( SourceParams.createCardParams(card), clientSecret, null ); PaymentIntent paymentIntent = StripeApiHandler.confirmPaymentIntent( null, 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()); } }