Class PaymentUserController
- All Implemented Interfaces:
javafx.fxml.Initializable
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate javafx.scene.layout.AnchorPane
private javafx.scene.control.TextField
private javafx.scene.layout.AnchorPane
private static final Pattern
private javafx.scene.control.TextField
private org.controlsfx.control.CheckComboBox<String>
private javafx.scene.control.ComboBox<String>
(package private) Client
private javafx.scene.control.TextField
private static final Pattern
private javafx.scene.control.Label
private javafx.scene.control.Button
private static final Logger
private javafx.scene.control.TextField
private MovieSession
private javafx.scene.control.Spinner<Integer>
private javafx.scene.control.Label
private javafx.scene.control.Button
private javafx.scene.control.Label
private static final ConcurrentHashMap<String,
PaymentUserController.PaymentValidationResult> private javafx.scene.control.Button
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
createReceiptPDF
(String filename, Ticket ticket) Creates a PDF receipt for a ticket purchase by adding text and graphics to a blank page using a PDPageContentStream, then saving the document with a specified filename.static int
doubleToInt
(double value) Converts a `float` argument into an `int` value by calling the `int` casting operator `(int)`.void
init
(MovieSession p, Client client) Sets the values of class variables `client` and `moviesession`, and updates the text of a label `total`.void
initialize
(URL url, ResourceBundle rb) Reads the film and cinema data, creates a combobox for selecting cinemas and initializes the payment panel with disabled options.void
initWithSeats
(MovieSession moviesession, Client client, List<Seat> selectedSeats) Performs initWithSeats operation.static boolean
Checks if a given string is a numerical value by matching it against a regular expression pattern of one or more digits.private boolean
Validates input fields for a Visa card number, month and year of expiration, and CVC code.private boolean
isValidVisaCardNo
(String text) Takes a string as input and checks if it matches the valid Visa card number format, which is a 13-digit number consisting of four digits followed by a hyphen and then another four digits.void
Opens a PDF file using the desktop application.private void
Pay
(javafx.event.ActionEvent event) Processes a payment for a ticket purchase by first checking if the input is valid, then calculating and charging the correct amount based on the ticket's price and quantity, and finally saving the order to the database.void
Sets the `client` field and displays the film name on a label.private void
Creates an Alert object with an error title and message, displays it using the `showAndWait()` method.void
switchtfillmmaa
(javafx.event.ActionEvent event) Loads and displays a FXML file named "/ui/films/filmuser.fxml" using Java's `FXMLLoader` class, creating a new stage and scene to display the content.private boolean
validateCardNumber
(String cardNumber) private boolean
validatePaymentWithCache
(String cardNumber)
-
Field Details
-
LOGGER
-
client
Client client -
moviesession
-
selectedSeats
-
total
private javafx.scene.control.Label total -
filmLabel_Payment
private javafx.scene.control.Label filmLabel_Payment -
Pay
private javafx.scene.control.Button Pay -
anchorpane_payment
private javafx.scene.layout.AnchorPane anchorpane_payment -
anneeExp
private javafx.scene.control.TextField anneeExp -
bord
private javafx.scene.layout.AnchorPane bord -
carte
private javafx.scene.control.TextField carte -
checkcomboboxmoviesession_res
-
cinemacombox_res
-
cvc
private javafx.scene.control.TextField cvc -
filmm
private javafx.scene.control.Button filmm -
moisExp
private javafx.scene.control.TextField moisExp -
nbrplacepPayment_Spinner
-
nomPrenom
private javafx.scene.control.Label nomPrenom -
viewPDF
private javafx.scene.control.Button viewPDF -
validationCache
private static final ConcurrentHashMap<String,PaymentUserController.PaymentValidationResult> validationCache -
CARD_NUMBER_PATTERN
-
CVC_PATTERN
-
-
Constructor Details
-
PaymentUserController
public PaymentUserController()
-
-
Method Details
-
validatePaymentWithCache
-
validateCardNumber
-
isNum
Checks if a given string is a numerical value by matching it against a regular expression pattern of one or more digits.- Parameters:
str
- String to be checked for matching the regular expression `\d+`.
-
doubleToInt
public static int doubleToInt(double value) Converts a `float` argument into an `int` value by calling the `int` casting operator `(int)`.- Parameters:
value
- floating-point number to be converted to an integer.
-
setData
Sets the `client` field and displays the film name on a label. It also prints the value of `client` to the console.- Parameters:
client
- Client object that provides the payment details for the film name set by the `filmName` parameter.filmName
- name of a film that is being associated with the `Client` object passed as an argument to the `setData()` method.
-
initialize
Reads the film and cinema data, creates a combobox for selecting cinemas and initializes the payment panel with disabled options. When the user selects a cinema, it calls the `readLoujain` method to retrieve the moviesession list for that cinema, which is then displayed in a spinner.- Specified by:
initialize
in interfacejavafx.fxml.Initializable
- Parameters:
url
- URL of a resource bundle that provides localization keys for the function's output, such as film and cinema names.- `url`: The URL provided by the user, which contains information about the film and cinema. - `rb`: A `ResourceBundle` object containing key-value pairs of localized messages and resource keys.
rb
- ResourceBundle object, which provides localized messages and values for the Java application.- `rb`: A `ResourceBundle` object containing key-value pairs for resource string messages.
The main properties of `rb` are:
- Key-value pairs: Contains key-value pairs in the form of `(key, value)`, where `key` is a unique identifier for a message, and `value` is the corresponding message text. - Messages: `rb` provides a collection of messages that can be used to localize user interface elements, such as labels, buttons, and menus. - Culture-specific messages: `rb` allows developers to create culture-specific messages by providing separate key-value pairs for each culture.
-
Pay
private void Pay(javafx.event.ActionEvent event) throws com.stripe.exception.StripeException Processes a payment for a ticket purchase by first checking if the input is valid, then calculating and charging the correct amount based on the ticket's price and quantity, and finally saving the order to the database.- Parameters:
event
- Pay action event, which triggers the execution of the function and enables the processing of the payment request.- `event` is an ActionEvent that represents a user's action on the Pay button.
- Throws:
com.stripe.exception.StripeException
-
isValidInput
private boolean isValidInput()Validates input fields for a Visa card number, month and year of expiration, and CVC code. It returns `true` if all inputs are valid, otherwise it displays an error message and returns `false`. -
isValidVisaCardNo
Takes a string as input and checks if it matches the valid Visa card number format, which is a 13-digit number consisting of four digits followed by a hyphen and then another four digits.- Parameters:
text
- 13-digit credit card number to be validated.
-
showError
Creates an Alert object with an error title and message, displays it using the `showAndWait()` method.- Parameters:
title
- title of an error message that is displayed in the alert box when the `showError()` method is called.message
- message to be displayed as the content of an error alert when the function is called.
-
init
Sets the values of class variables `client` and `moviesession`, and updates the text of a label `total`.- Parameters:
p
- MovieSession object, which is assigned to the class instance variable `moviesession`.client
- Client object that is associated with the MovieSession object being initialized.
-
initWithSeats
Performs initWithSeats operation. -
switchtfillmmaa
public void switchtfillmmaa(javafx.event.ActionEvent event) Loads and displays a FXML file named "/ui/films/filmuser.fxml" using Java's `FXMLLoader` class, creating a new stage and scene to display the content.- Parameters:
event
- ActionEvent object that triggered the method execution, providing the necessary information about the action that was performed.Event: An ActionEvent object representing a user event.
-
createReceiptPDF
Creates a PDF receipt for a ticket purchase by adding text and graphics to a blank page using a PDPageContentStream, then saving the document with a specified filename.- Parameters:
filename
- name of the output PDF file that the `createReceiptPDF` method will save.ticket
- ticket for which a receipt is to be generated, and its contents are used to populate the receipt document.- Ticket is an instance of the `Ticket` class. - It contains information about the ticket purchase, such as the date and time of purchase, the amount paid, and any other relevant details.
- Throws:
IOException
-
openPDF
Opens a PDF file using the desktop application.- Parameters:
filename
- name of the PDF file to be opened.- Throws:
IOException
-