Class PaymentController
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate javafx.scene.layout.Pane
private javafx.scene.control.Button
private org.controlsfx.control.CheckComboBox<String>
private javafx.scene.control.ComboBox<String>
private javafx.scene.control.TextField
private javafx.scene.control.Spinner<Integer>
private javafx.scene.control.TextField
private javafx.scene.control.Label
private static final Logger
private javafx.scene.control.Spinner<Integer>
private MovieSession
private javafx.scene.control.Spinner<Integer>
private javafx.scene.control.TextField
private javafx.scene.control.Button
private javafx.scene.control.TextField
private javafx.scene.control.Label
private double
private javafx.scene.control.Spinner<Integer>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate boolean
check_card_num
(String cardNumber) Checks whether a given credit card number follows a specific format by matching it against a regular expression pattern.private boolean
check_cvc
(int value) Verifies if a given integer value can be represented as a three-digit credit card number (CVC) by checking its length.private boolean
check_expDate
(int value_y, int value_mm) Takes two parameters `value_y` and `value_mm`, checks if the date represented by those parameters is after the current date, and returns `true` if it is, or `false` otherwise.(package private) void
Sets up three SpinnerValueFactories, `MM`, `YY`, and `cvc`, for displaying dates in the format `mm/yyyy/ccvc`.boolean
isValidEmail
(String email) Checks whether a given email address is valid by matching it against a regular expression pattern that matches most standard email addresses.private void
payment
(javafx.event.ActionEvent event) Validates user input and processes a payment using a third-party payment processor.private void
Redirects the user to a "Fail Page" by loading an FXML file, updating the controller with data from the reservation object, and displaying the scene on the stage.private void
Redirects the user to a success page with data loaded from an external resource.private void
redirectToListReservation
(javafx.event.ActionEvent event) Redirects the user to a new scene containing a reservation view client.void
Sets the `MovieSession` object's fields and updates spinner values for the year, month, and cvc based on the `MovieSession` object's `prix` field and sets the text of a text field with the total amount.
-
Field Details
-
LOGGER
-
filmLabel_Payment
private javafx.scene.control.Label filmLabel_Payment -
total
private javafx.scene.control.Label total -
pay_btn
private javafx.scene.control.Button pay_btn -
email
private javafx.scene.control.TextField email -
num_card
private javafx.scene.control.TextField num_card -
MM
-
YY
-
cvc
-
nbrplacepPayment_Spinner
-
total_pay
private double total_pay -
moviesession
-
client_name
private javafx.scene.control.TextField client_name -
back_btn
private javafx.scene.control.Button back_btn -
spinnerTextField
private javafx.scene.control.TextField spinnerTextField -
anchorpane_payment
private javafx.scene.layout.Pane anchorpane_payment -
checkcomboboxmoviesession_res
-
cinemacombox_res
-
-
Constructor Details
-
PaymentController
public PaymentController()
-
-
Method Details
-
initialize
void initialize()Sets up three SpinnerValueFactories, `MM`, `YY`, and `cvc`, for displaying dates in the format `mm/yyyy/ccvc`. It assigns the value factories to the respective Spinners. -
setData
Sets the `MovieSession` object's fields and updates spinner values for the year, month, and cvc based on the `MovieSession` object's `prix` field and sets the text of a text field with the total amount.- Parameters:
s
- MovieSession object passed into the function, which is used to set the values of various fields within the `MovieSession` object.- `moviesession`: represents an object of the MovieSession class, containing information about a moviesession. - `prix`: a float representing the price of the moviesession. - `terrain_id`: an integer representing the terrain ID for display purposes. - `monthValue` and `year`: integers representing the current month and year respectively. - `cvc`: an object of the CVC class, used to display a spinner for the number of seats available in the moviesession.
-
payment
private void payment(javafx.event.ActionEvent event) throws com.stripe.exception.StripeException Validates user input and processes a payment using a third-party payment processor. If the payment is successful, it displays an information alert; otherwise, it displays an error alert.- Parameters:
event
- payment action that triggered the function execution, and it is used to identify the specific payment method being processed.- `LOGGER.info(cvc.getValue());`: This line prints the value of the `CVC` field.
`event` is an instance of the `ActionEvent` class, which represents a user event related to a button press or other action in the JavaFX application. It provides information about the event, such as the source of the event (e.g., a button), the type of event (e.g., "click"), and any additional data related to the event.
- Throws:
com.stripe.exception.StripeException
-
check_cvc
private boolean check_cvc(int value) Verifies if a given integer value can be represented as a three-digit credit card number (CVC) by checking its length. If the length is equal to 3, the function returns `true`, otherwise it returns `false`.- Parameters:
value
- 3-digit credit card number to be checked for length.
-
check_expDate
private boolean check_expDate(int value_y, int value_mm) Takes two parameters `value_y` and `value_mm`, checks if the date represented by those parameters is after the current date, and returns `true` if it is, or `false` otherwise.- Parameters:
value_y
- 4-digit year value in the expiration date.value_mm
- month of the date to be checked, which is used to determine if the date is valid.
-
check_card_num
Checks whether a given credit card number follows a specific format by matching it against a regular expression pattern. It returns `true` if the pattern matches and `false` otherwise.- Parameters:
cardNumber
- 13-19 digit credit card number to be checked against the regular expression pattern for validation.
-
isValidEmail
Checks whether a given email address is valid by matching it against a regular expression pattern that matches most standard email addresses.- Parameters:
email
- email address to be checked for validity.
-
redirect_to_successPage
private void redirect_to_successPage()Redirects the user to a success page with data loaded from an external resource. -
redirect_to_FailPage
private void redirect_to_FailPage()Redirects the user to a "Fail Page" by loading an FXML file, updating the controller with data from the reservation object, and displaying the scene on the stage. -
redirectToListReservation
private void redirectToListReservation(javafx.event.ActionEvent event) Redirects the user to a new scene containing a reservation view client. It loads the reservation view client fxml file, sets the controller data with the client ID, and displays the stage in a new window.- Parameters:
event
- triggering of an action, specifically the click on the "Back" button, which calls the `redirectToListReservation()` method.- `event` is an instance of the `ActionEvent` class.
-