Enum Class PaymentProcessor

java.lang.Object
java.lang.Enum<PaymentProcessor>
com.esprit.utils.PaymentProcessor
All Implemented Interfaces:
Serializable, Comparable<PaymentProcessor>, Constable

public enum PaymentProcessor extends Enum<PaymentProcessor>
  • Field Details

  • Constructor Details

    • PaymentProcessor

      private PaymentProcessor()
  • Method Details

    • values

      public static PaymentProcessor[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static PaymentProcessor valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • processPayment

      public static boolean processPayment(String name, String email, float amount, String cardNumber, int cardExpMonth, int cardExpYear, String cardCvc)
      Process a payment with Stripe
      Parameters:
      name - Customer name
      email - Customer email
      amount - Amount to charge in the default currency
      cardNumber - Credit card number
      cardExpMonth - Card expiration month
      cardExpYear - Card expiration year
      cardCvc - Card CVC code
      Returns:
      boolean indicating if the payment was successful
    • validateInputs

      private static void validateInputs(String name, String email, float amount, String cardNumber, int cardExpMonth, int cardExpYear, String cardCvc)
    • retrieveOrCreateCustomer

      private static com.stripe.model.Customer retrieveOrCreateCustomer(String name, String email) throws com.stripe.exception.StripeException
      Throws:
      com.stripe.exception.StripeException
    • createToken

      private static com.stripe.model.Token createToken(String cardNumber, int expMonth, int expYear, String cvc) throws com.stripe.exception.StripeException
      Throws:
      com.stripe.exception.StripeException
    • chargeCustomer

      private static com.stripe.model.Charge chargeCustomer(String customerId, String tokenId, float amount) throws com.stripe.exception.StripeException
      Throws:
      com.stripe.exception.StripeException