Package com.esprit.utils
Enum Class PaymentProcessor
- All Implemented Interfaces:
Serializable
,Comparable<PaymentProcessor>
,Constable
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static com.stripe.model.Charge
chargeCustomer
(String customerId, String tokenId, float amount) private static com.stripe.model.Token
createToken
(String cardNumber, int expMonth, int expYear, String cvc) static boolean
processPayment
(String name, String email, float amount, String cardNumber, int cardExpMonth, int cardExpYear, String cardCvc) Process a payment with Stripeprivate static com.stripe.model.Customer
retrieveOrCreateCustomer
(String name, String email) private static void
validateInputs
(String name, String email, float amount, String cardNumber, int cardExpMonth, int cardExpYear, String cardCvc) static PaymentProcessor
Returns the enum constant of this class with the specified name.static PaymentProcessor[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.
-
Field Details
-
LOGGER
-
CURRENCY
- See Also:
-
CENTS_MULTIPLIER
private static final int CENTS_MULTIPLIER- See Also:
-
-
Constructor Details
-
PaymentProcessor
private PaymentProcessor()
-
-
Method Details
-
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
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 nameNullPointerException
- 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 nameemail
- Customer emailamount
- Amount to charge in the default currencycardNumber
- Credit card numbercardExpMonth
- Card expiration monthcardExpYear
- Card expiration yearcardCvc
- Card CVC code- Returns:
- boolean indicating if the payment was successful
-
validateInputs
-
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
-