// Don’t put any keys in code. See https://docs.stripe.com/keys-best-practices. // Find your keys at https://dashboard.stripe.com/apikeys. Stripe.apiKey = “{{TEST_SECRET_KEY}}”; SessionCreateParams params = SessionCreateParams.builder() .setMode(SessionCreateParams.Mode.SUBSCRIPTION) .setUiMode(SessionCreateParams.UiMode.HOSTED_PAGE) .setSuccessUrl(“{{SUCCESS_URL}}”) .setCancelUrl(“{{CANCEL_URL}}”) .addLineItem( SessionCreateParams.LineItem.builder() .setPrice(“{{PRICE_ID}}”) .setQuantity(1L) .build() ) .setBillingAddressCollection(SessionCreateParams.BillingAddressCollection.AUTO) .setPaymentMethodCollection(SessionCreateParams.PaymentMethodCollection.ALWAYS) .setAllowPromotionCodes(false) .setSubmitType(SessionCreateParams.SubmitType.AUTO) .setIntegrationIdentifier(“hosted_web_0002”) .setOriginContext(SessionCreateParams.OriginContext.WEB) .build(); Session session = Session.create(params); response.sendRedirect(session.getUrl());
// Don't put any keys in code. See https://docs.stripe.com/keys-best-practices.
// Find your keys at https://dashboard.stripe.com/apikeys.
Stripe.apiKey = "{{TEST_SECRET_KEY}}";
SessionCreateParams params =
SessionCreateParams.builder()
.setMode(SessionCreateParams.Mode.SUBSCRIPTION)
.setUiMode(SessionCreateParams.UiMode.HOSTED_PAGE)
.setSuccessUrl("{{SUCCESS_URL}}")
.setCancelUrl("{{CANCEL_URL}}")
.addLineItem(
SessionCreateParams.LineItem.builder()
.setPrice("{{PRICE_ID}}")
.setQuantity(1L)
.build()
)
.setBillingAddressCollection(SessionCreateParams.BillingAddressCollection.AUTO)
.setPaymentMethodCollection(SessionCreateParams.PaymentMethodCollection.ALWAYS)
.setAllowPromotionCodes(false)
.setSubmitType(SessionCreateParams.SubmitType.AUTO)
.setIntegrationIdentifier("hosted_web_0002")
.setOriginContext(SessionCreateParams.OriginContext.WEB)
.build();
Session session = Session.create(params);
response.sendRedirect(session.getUrl());
//
