LOGO.png

We respect your email privacy

// 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 = "sk_test_51UJdML2MVpH9zkLH5X9vHZe7Tn86fKg44gIbVZiWMH6G1VIgdRDZhcTG89ZYy5kdKL7ODKEOoK7IGqkzV6Ke0DS600r3O3PzXR";

SessionCreateParams params =
  SessionCreateParams.builder()
    .setMode(SessionCreateParams.Mode.PAYMENT)
    .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)
    .setNameCollection(
      SessionCreateParams.NameCollection.builder()
        .setIndividual(
          SessionCreateParams.NameCollection.Individual.builder().setEnabled(true).build()
        )
        .build()
    )
    .setPhoneNumberCollection(
      SessionCreateParams.PhoneNumberCollection.builder().setEnabled(true).build()
    )
    .setAllowPromotionCodes(false)
    .setSubmitType(SessionCreateParams.SubmitType.AUTO)
    .setIntegrationIdentifier("hosted_web_0001")
    .setOriginContext(SessionCreateParams.OriginContext.WEB)
    .build();

Session session = Session.create(params);

response.sendRedirect(session.getUrl());