/** * Create the parameters necessary for confirming a PaymentIntent while attaching Source data * * @param sourceParams params for the source that will be attached to this payment intent * @param clientSecret client secret from the PaymentIntent that is to be confirmed * @param returnUrl the URL the customer should be redirected to after the authorization * process * @return params that can be use to confirm a PaymentIntent */ @NonNull public static PaymentIntentParams createConfirmPaymentIntentWithSourceDataParams( @Nullable SourceParams sourceParams, @NonNull String clientSecret, @Nullable String returnUrl) { return new PaymentIntentParams() .setSourceParams(sourceParams) .setClientSecret(clientSecret) .setReturnUrl(returnUrl); }
/** * Create the parameters necessary for confirming a PaymentIntent while attaching a source that * already exits. * * @param sourceId the ID of the source that is being attached to the PaymentIntent being * confirmed * @param clientSecret client secret from the PaymentIntent being confirmed * @param returnUrl the URL the customer should be redirected to after the authorization * process * @return params that can be use to confirm a PaymentIntent */ @NonNull public static PaymentIntentParams createConfirmPaymentIntentWithSourceIdParams( @Nullable String sourceId, @NonNull String clientSecret, @Nullable String returnUrl) { return new PaymentIntentParams() .setSourceId(sourceId) .setClientSecret(clientSecret) .setReturnUrl(returnUrl); }
@Test public void createCustomParams_toParamMap_createsExpectedMap() { PaymentIntentParams paymentIntentParams = PaymentIntentParams.createCustomParams(); paymentIntentParams .setReturnUrl(TEST_RETURN_URL) .setClientSecret(TEST_CLIENT_SECRET) .setSourceId(TEST_SOURCE_ID); Map<String, Object> paramMap = paymentIntentParams.toParamMap(); Assert.assertEquals(paramMap.get(PaymentIntentParams.API_PARAM_SOURCE_ID), TEST_SOURCE_ID); Assert.assertEquals( paramMap.get(PaymentIntentParams.API_PARAM_CLIENT_SECRET), TEST_CLIENT_SECRET); Assert.assertEquals( paramMap.get(PaymentIntentParams.API_PARAM_RETURN_URL), TEST_RETURN_URL); }