/// <summary> /// Creates the payment gateway. /// </summary> /// <param name="paymentGateway">The payment gateway.</param> /// <returns> /// The payment gateway. /// </returns> /// <exception cref="NotSupportedException">The payment gateway {paymentGateway} is not supported.</exception> public IPaymentGateway CreatePaymentGateway(PaymentGatewayType paymentGateway) { switch (paymentGateway) { case PaymentGatewayType.FirstData: return(new FirstData()); case PaymentGatewayType.PayPal: return(new PayPal()); default: throw new NotSupportedException($"The payment gateway {paymentGateway} is not supported."); } }
/// <summary> /// Initializes a new instance of the <see cref="Gateway"/> class. /// </summary> /// <param name="gatewayType">Type of the gateway.</param> /// <param name="username">The username.</param> /// <param name="password">The password.</param> /// <param name="isTestMode">if set to <c>true</c> [is test mode].</param> public Gateway(PaymentGatewayType gatewayType, string username, string password, bool isTestMode) { GatewayType = gatewayType; Username = username; Password = password; IsTestMode = isTestMode; switch (gatewayType) { case PaymentGatewayType.AuthorizeDotNet: Request = new AuthorizeDotNetRequest(username, password, isTestMode); break; case PaymentGatewayType.Durango: Request = new DurangoRequest(username, password, isTestMode); break; case PaymentGatewayType.Paypal: Request = new PayPalRequest(username, password, isTestMode); break; case PaymentGatewayType.Charge1: Request = new Charge1Request(username, password, isTestMode); break; } }
private ConvertServiceResponse DoPaymentGatewayDetailViewRouting(ConvertServiceRequest request) { var entityId = request.Parameters[CommonParameters.EntityId]; var paymentGatewayType = new PaymentGatewayType(); if (entityId.ToUpperInvariant().Contains(RecordActions.New.ToUpperInvariant())) { //new configuration paymentGatewayType = GetPaymentGatewayType(entityId); request.Parameters[CommonParameters.Entity2Id] = RecordActions.New; } else { //existing configuration var configurationId = 0; if (int.TryParse(entityId, out configurationId)) { int paymentGatewayConfigurationId = 0; SetPaymentConfigVariablesForExistingConfigurations(configurationId, out paymentGatewayConfigurationId, out paymentGatewayType); request.Parameters[CommonParameters.Entity2Id] = paymentGatewayConfigurationId.ToString(); } } switch (paymentGatewayType) { case PaymentGatewayType.AuthorizeDotNet: return new AuthorizeDotNetAdminDetailView(RequestProcessor).ProcessServiceRequest(request); case PaymentGatewayType.PayPal: break; case PaymentGatewayType.PayflowPro: return new PayflowProAdminDetailView(RequestProcessor).ProcessServiceRequest(request); } return null; }
private static string[] GetAcceptedCardTypes(PaymentGatewayType enumPaymentGatewayType, string strHotelCode) { string[] AcceptedCardTypes = new string[0]; string strPaymentGatewayHotelPaymentCardInfo = ConfigurationManager.AppSettings["PaymentGatewayPaymentCard_" + strHotelCode]; if (strPaymentGatewayHotelPaymentCardInfo != null && strPaymentGatewayHotelPaymentCardInfo != "") { AcceptedCardTypes = strPaymentGatewayHotelPaymentCardInfo.Split(new char[] { ';' }); } else { int intNumPaymentGatewayPaymentCardInfos = 0; if (ConfigurationManager.AppSettings["PaymentGatewayPaymentCardCount"] != null && ConfigurationManager.AppSettings["PaymentGatewayPaymentCardCount"] != "") { try { intNumPaymentGatewayPaymentCardInfos = Convert.ToInt32(ConfigurationManager.AppSettings["PaymentGatewayPaymentCardCount"]); } catch { intNumPaymentGatewayPaymentCardInfos = 0; } } for (int i = 0; i < intNumPaymentGatewayPaymentCardInfos; i++) { string strPaymentGatewayPaymentCardInfo = ConfigurationManager.AppSettings["PaymentGatewayPaymentCard" + ((int)(i + 1)).ToString()]; if (strPaymentGatewayPaymentCardInfo != null && strPaymentGatewayPaymentCardInfo != "") { string[] saPaymentGatewayPaymentCardInfo = strPaymentGatewayPaymentCardInfo.Split(new char[] { ';' }); if (saPaymentGatewayPaymentCardInfo.Length < 2) continue; if (!(saPaymentGatewayPaymentCardInfo[0] == "cba" && enumPaymentGatewayType == PaymentGatewayType.CBA || saPaymentGatewayPaymentCardInfo[0] == "ogone" && enumPaymentGatewayType == PaymentGatewayType.Ogone || saPaymentGatewayPaymentCardInfo[0] == "bnz" && enumPaymentGatewayType == PaymentGatewayType.BNZ || saPaymentGatewayPaymentCardInfo[0] == "dibs" && enumPaymentGatewayType == PaymentGatewayType.DIBS || saPaymentGatewayPaymentCardInfo[0] == "migs3p" && enumPaymentGatewayType == PaymentGatewayType.MIGS3P || saPaymentGatewayPaymentCardInfo[0] == "hdfc" && enumPaymentGatewayType == PaymentGatewayType.HDFC)) continue; AcceptedCardTypes = new string[saPaymentGatewayPaymentCardInfo.Length - 1]; for (int j = 0; j < AcceptedCardTypes.Length; j++) AcceptedCardTypes[j] = saPaymentGatewayPaymentCardInfo[j + 1]; break; } } } return AcceptedCardTypes; }
/// <summary> /// Initializes a new instance of the <see cref="Gateway"/> class. /// </summary> /// <param name="gatewayType">Type of the gateway.</param> /// <param name="username">The username.</param> /// <param name="password">The password.</param> public Gateway(PaymentGatewayType gatewayType, string username, string password) : this(gatewayType, username, password, true) { }
public PaymentGateway(PaymentGatewayType type, string apiConfiguration, IEnumerable <PaymentMethod> paymentMethods) { Type = type; ApiConfiguration = apiConfiguration; PaymentMethodSet = new List <PaymentMethod>(paymentMethods); }
private void SetPaymentConfigVariablesForExistingConfigurations(int configurationId, out int paymentGatewayConfigurationId, out PaymentGatewayType paymentGatewayType) { var request = new ReadPaymentGatewayConfigurationSettingsRequest { ConfigurationId = configurationId }; var response = ProcessRequest<ReadPaymentGatewayConfigurationSettingsResponse>(request); paymentGatewayType = response.PaymentGatewayType; if (response.PayflowProSettings != null) paymentGatewayConfigurationId = response.PayflowProSettings.Id; else if (response.AuthorizeDotNetSettings != null) paymentGatewayConfigurationId = response.AuthorizeDotNetSettings.Id; else paymentGatewayConfigurationId = -1; }