public static RequeryStatus.Requery CheckPaymentPAID(PaymentOrder record, int bookingId, int superPNRId, string superPNRNo) { decimal amt = Alphareds.Module.Common.Core.IsForStaging ? 1.00m : record.PaymentAmount; string _payStatus = record.PaymentStatusCode.ToUpper(); var _requeryResult = new RequeryStatus.Requery { SuperPNRID = superPNRId, SuperPNRNo = superPNRNo, OrderID = record?.OrderID ?? -1, Status = false, }; var result = PaymentServiceController.iPay88.RequeryPaymentStatus(record.Ipay88RefNo, record.CurrencyCode, amt.ToString("n2")); _requeryResult.Desc = result?.Desc; if (string.IsNullOrWhiteSpace(record.Ipay88TransactionID) && !string.IsNullOrWhiteSpace(result.TransId)) { record.Ipay88TransactionID = result.TransId; } if (result.Desc == "Record not found" || result.Status == "Record not found") { string attempRefNo = bookingId.ToString() + " - " + superPNRNo; attempRefNo = attempRefNo != record.Ipay88RefNo ? attempRefNo : superPNRId.ToString() + " - " + superPNRNo; result = PaymentServiceController.iPay88.RequeryPaymentStatus(attempRefNo, record.CurrencyCode, amt.ToString("n2")); } else if (result.Desc == "Invalid parameters" || result.Desc == "Incorrect amount") { throw new Exception("iPay88 requery result stated - " + result.Desc); } else if (result.Desc == "Payment Fail") // iPay FPX only { record.PaymentStatusCode = "FAIL"; return(_requeryResult); } else if (result.Desc == "Voided") { record.PaymentStatusCode = "VOID"; return(_requeryResult); } bool paymentAccept = result.Status == "1" && (result.Desc == "Authorised" || result.Desc == "Captured" || result.Desc == string.Empty); if (paymentAccept && (_payStatus != "PAID" && _payStatus != "CAPT" && _payStatus != "FAIL" && _payStatus != "VOID")) { if (record.SuperPNROrder.BookingStatusCode == "PPA") { record.SuperPNROrder.BookingStatusCode = "RHI"; } if (result.Desc == "Authorised") { record.PaymentStatusCode = "AUTH"; } else if (result.Desc == "Captured") { record.PaymentStatusCode = "CAPT"; } else if (result.Desc == string.Empty) { record.PaymentStatusCode = "PAID"; } } if (paymentAccept) { _requeryResult.Status = true; } return(_requeryResult); }
private List <ItemCheck> PaymentStatusRequeryHandler(IQueryable <PaymentOrder> paymentOrders, RequeryStatus.Requery item, bool chkFlight, bool chkHotel, bool chkAddOnBook, string superPNRNo = null) { var itemBookStatus = new List <ItemCheck>(); if (item.Status && item.Desc != "Voided") { var _newItemCheck = new ItemCheck(item.SuperPNRID, MayFlowerDB, true, chkFlight, chkHotel, chkAddOnBook); itemBookStatus.Add(_newItemCheck); } else if (!item.Status && item.Desc == "Limited by per day maximum number of requery") { foreach (var payment in paymentOrders.Where(x => x.SuperPNROrder.OrderID == item.OrderID)) { InformationCaution = InformationCaution ?? new List <string>(); InformationCaution.Add(string.Format("PaymentOrders PaymentID {0} :- {1}", payment.PaymentID, item.Desc)); payment.RequeryStatusCode = "ERR"; } } else if (!item.Status) { /* Functions: * For handle payment failed record, update all related components to failed. * -- For iPay close browser at payment gateway will return 'Record not found'. */ var ordersList = paymentOrders.Where(x => x.SuperPNROrder.OrderID == item.OrderID); foreach (var payment in ordersList) { if (payment.PaymentStatusCode == "PAID" || payment.PaymentStatusCode == "CAPTURED") { InformationCaution = InformationCaution ?? new List <string>(); InformationCaution.Add(string.Format("PaymentOrders PaymentID {0} :- {1}", payment.PaymentID, item.Desc)); payment.RequeryStatusCode = "ERR"; } else if (item.Desc == "Record not found") { InformationCaution = InformationCaution ?? new List <string>(); InformationCaution.Add(string.Format("SuperPNR {0} - {1}: Requery result as '{2}'.", item.SuperPNRID, item.SuperPNRNo, item.Desc)); payment.RequeryStatusCode = "FAIL"; payment.PaymentStatusCode = "FAIL"; } else if (item.Desc == "Voided") { payment.RequeryStatusCode = "FAIL"; payment.PaymentStatusCode = "VOID"; } else { payment.RequeryStatusCode = "FAIL"; payment.PaymentStatusCode = "FAIL"; } if (payment.RequeryStatusCode != "ERR") { string _payMethod = payment.PaymentMethodCode?.ToLower(); if (_payMethod == "tw") { // Remove holded travel wallet new PaymentServiceController().TempCashCreditRedeemDelete(payment.OrderID, payment.CreatedByID, payment.CurrencyCode, payment.PaymentAmount, MaySqlCommand); } else if (_payMethod == "sc") { // Remove holded travel wallet new PaymentServiceController().TempCreditRedeemDelete(payment.OrderID, payment.CreatedByID, payment.CurrencyCode, payment.PaymentAmount, MaySqlCommand); } } } foreach (var order in ordersList.Select(x => x.SuperPNROrder)) { bool anyError = false; #region Flight foreach (var flight in order.SuperPNR.Bookings) { if (flight.BookingStatusCode == "CON" || flight.BookingStatusCode == "TKI" || flight.BookingStatusCode == "QPL") { InformationCaution = InformationCaution ?? new List <string>(); InformationCaution.Add(string.Format("SuperPNR {0} - {1}: Payment Failed but Flight Booking Placed.", item.SuperPNRID, item.SuperPNRNo)); anyError = true; break; } else { flight.BookingStatusCode = "EXP"; } } #endregion #region Insurance if (!anyError) { foreach (var insurance in order.SuperPNR.BookingInsurances) { if (insurance.BookingStatusCode == "CON") { InformationCaution = InformationCaution ?? new List <string>(); InformationCaution.Add(string.Format("SuperPNR {0} - {1}: Payment Failed but Insurance Booking Placed.", item.SuperPNRID, item.SuperPNRNo)); anyError = true; break; } else { insurance.BookingStatusCode = "EXP"; } } } #endregion #region Hotel if (!anyError) { foreach (var hotel in order.SuperPNR.BookingHotels) { if (hotel.BookingStatusCode == "CON") { InformationCaution = InformationCaution ?? new List <string>(); InformationCaution.Add(string.Format("SuperPNR {0} - {1}: Payment Failed but Hotel Booking Placed.", item.SuperPNRID, item.SuperPNRNo)); anyError = true; break; } else { hotel.BookingStatusCode = "EXP"; } } } #endregion #region Add On if (!anyError) { foreach (var addOn in order.SuperPNR.EventBookings) { if (addOn.BookingStatusCode == "CON") { InformationCaution = InformationCaution ?? new List <string>(); InformationCaution.Add(string.Format("SuperPNR {0} - {1}: Payment Failed but AddOn Item Confirmed.", item.SuperPNRID, item.SuperPNRNo)); anyError = true; break; } else { if (addOn.CreatedDate >= new DateTime(2017, 12, 06)) { Alphareds.Module.HotelController.HotelServiceController.UpdateEventBooking(addOn.SuperPNR, "EXP"); } addOn.BookingStatusCode = "EXP"; } } } #endregion // Check all component first only proceed to modify SuperPNROrder status. if (!anyError) { if (order.BookingStatusCode == "CON" || order.BookingStatusCode == "TKI" || order.BookingStatusCode == "QPL") { InformationCaution = InformationCaution ?? new List <string>(); InformationCaution.Add(string.Format("SuperPNR {0} - {1}: Payment Failed but SuperPNR Order status is [CON].", item.SuperPNRID, item.SuperPNRNo)); } else { order.BookingStatusCode = "EXP"; } } } } try { if (CommandInitInside && MaySqlCommand?.Transaction != null) { MaySqlCommand.Transaction.Commit(); } } catch (Exception ex) { InformationCaution.Add("Error when commit transaction for travel credit & travel wallet." + Environment.NewLine + Environment.NewLine + ex.GetBaseException().Message + Environment.NewLine + Environment.NewLine + ex.StackTrace); } return(itemBookStatus); }
public static RequeryStatus.Requery CheckPaymentPAID(PaymentOrder record, int bookingId, int superPNRId, string superPNRNo) { decimal amt = Alphareds.Module.Common.Core.IsForStaging ? 500 : record.PaymentAmount; string _payStatus = record.PaymentStatusCode.ToUpper(); var _requeryResult = new RequeryStatus.Requery { SuperPNRID = superPNRId, SuperPNRNo = superPNRNo, OrderID = record?.OrderID ?? -1, Status = false, }; var result = PaymentServiceController.Adyen.RequeryPaymentStatus(record.Ipay88RefNo, record.Ipay88TransactionID, record.CurrencyCode, amt.ToString("n2")); _requeryResult.Desc = result?.Desc; if (string.IsNullOrWhiteSpace(record.Ipay88TransactionID) && !string.IsNullOrWhiteSpace(result.PspReference)) { record.Ipay88TransactionID = result.PspReference; } /* * Adyen PayStatus Reference (Based on Adyen Web Service Document 1.1.0) * "P" – Pending * "AS" – Authorize Success * "AF" – Authorize Fail * "CS" – Capture Success * "CF" – Capture Fail * "XS" – Cancel Success * "XF" – Cancel Fail */ if (result.Desc == "Record not found" || result.PayStatus == "Record not found") { string attempRefNo = bookingId.ToString() + " - " + superPNRNo; attempRefNo = attempRefNo != record.Ipay88RefNo ? attempRefNo : superPNRId.ToString() + " - " + superPNRNo; result = PaymentServiceController.Adyen.RequeryPaymentStatus(attempRefNo, record.Ipay88TransactionID, record.CurrencyCode, amt.ToString("n2")); } else if (result.Desc == "Invalid parameters" || result.Desc == "Incorrect amount") { throw new Exception("Adyen requery result stated - " + result.Desc); } else if (result.Desc == "Payment Fail" || result.Desc == "AF") { result.Desc = "Payment Fail"; // Assign For BookingList Usage record.PaymentStatusCode = "FAIL"; return(_requeryResult); } else if (result.Desc == "Voided" || result.Desc == "XS") { result.Desc = "Voided"; // Assign For BookingList Usage record.PaymentStatusCode = "VOID"; return(_requeryResult); } else if (result.PayStatus == "AS") // Assign For BookingList Usage { result.Desc = "Authorised"; } else if (result.PayStatus == "CS") // Assign For BookingList Usage { result.Desc = "Captured"; } else if (result.PayStatus == "CF" || result.PayStatus == "XF") { record.RequeryStatusCode = "MAN"; return(_requeryResult); } bool paymentAccept = (result.PayStatus == "AS" || result.PayStatus == "CS") && (result.Desc == "Authorised" || result.Desc == "Captured" || result.Desc == string.Empty); if (paymentAccept && (_payStatus != "PAID" && _payStatus != "CAPT" && _payStatus != "FAIL" && _payStatus != "VOID")) { if (record.SuperPNROrder.BookingStatusCode == "PPA") { record.SuperPNROrder.BookingStatusCode = "RHI"; } if (result.PayStatus == "AS") { record.PaymentStatusCode = "AUTH"; } else if (result.PayStatus == "CS") { record.PaymentStatusCode = "CAPT"; } else if (result.Desc == string.Empty) { record.PaymentStatusCode = "PAID"; } } if (paymentAccept) { _requeryResult.Status = true; } return(_requeryResult); }