@@ -49,7 +49,7 @@ async function getBookingComplete(req, res, next) {
49
49
if ( req . session . bookingToken !== bookingToken ) {
50
50
const error_comment = "Booking token mismatch, invalid or expired." ;
51
51
console . error ( error_comment ) ;
52
- next ( new Error ( "Booking token mismatch, invalid or expired." ) ) ;
52
+ next ( new Error ( error_comment ) ) ;
53
53
}
54
54
// get show details
55
55
model . getES_E_V ( showID , async ( err , result ) => {
@@ -93,7 +93,6 @@ async function getBookingComplete(req, res, next) {
93
93
discountCategoryName = ticket . discountCategory . split ( ',' ) [ 0 ] ;
94
94
}
95
95
const discountCategory = await model . getDiscountFromType ( discountCategoryName ) ;
96
- console . log ( "Discount Category" , discountCategory )
97
96
const discountID = discountCategory [ 0 ] . discountID ;
98
97
99
98
// get the categoryID from the seating category
@@ -104,13 +103,10 @@ async function getBookingComplete(req, res, next) {
104
103
const date_booked = new Date ( ) . toISOString ( ) . slice ( 0 , 19 ) . replace ( 'T' , ' ' ) ;
105
104
// console.log("discountID", discountID, "categoryID", categoryID, "showID", showID, "date_booked", date_booked, "userID", req.session.loggedUserId);
106
105
107
- if ( req . session . bookingToken ) {
108
- const lastInsertedTicketID = await model . insertTicket ( ticket . ticketNumber , 'BOOKED' , categoryID , req . session . loggedUserId , date_booked , discountID , showID ) ;
109
- // destroy the booking token
110
- req . session . bookingToken = null ;
111
- ticket . ticketID = lastInsertedTicketID ;
112
- console . log ( "Ticket stored in the database" , ticket . ticketID ) ;
113
- }
106
+ const lastInsertedTicketID = await model . insertTicket ( ticket . ticketNumber , 'BOOKED' , categoryID , req . session . loggedUserId , date_booked , discountID , showID ) ;
107
+ // destroy the booking token
108
+ ticket . ticketID = lastInsertedTicketID ;
109
+ console . log ( "Ticket stored in the database" , ticket . ticketID ) ;
114
110
} catch ( err ) {
115
111
const error_comment = "Failed to store ticket in the database" ;
116
112
console . error ( error_comment ) ;
@@ -159,15 +155,14 @@ async function getBookingComplete(req, res, next) {
159
155
ticket . discountCategory = ticket . discountCategory . replace ( '%25' , '%' ) ;
160
156
}
161
157
} ) ;
162
- // console.log("Booking Info",bookingInfo);
163
158
}
164
159
let error_comment ;
165
160
let error_message ;
166
161
if ( ! success ) {
167
162
error_comment = "Network error while processing payment." ; // generic dummy comment
168
163
error_message = "Payment processing failed. Please try again." ; // generic dummy message
169
164
}
170
-
165
+ req . session . bookingToken = "Token used" ;
171
166
res . render ( 'booking_complete' , { success : bookingInfo [ 0 ] . success , eventInfo : eventShowInfo , tickets : bookingInfo , totalAmount, error_comment, error_message} ) ;
172
167
}
173
168
} ) ;
0 commit comments