internal override void Validate() { base.Validate(); if (string.IsNullOrEmpty(MerchantId)) { throw new ConfigurationException("MerchantId is required for this configuration."); } else if (string.IsNullOrEmpty(SharedSecret)) { throw new ConfigurationException("SharedSecret is required for this configuration."); } // secure 3d if (Secure3dVersion != null) { // ensure we have the fields we need if (Secure3dVersion.Equals(Entities.Secure3dVersion.Two) || Secure3dVersion.Equals(Entities.Secure3dVersion.Any)) { if (string.IsNullOrEmpty(ChallengeNotificationUrl)) { throw new ConfigurationException("The challenge notification URL is required for 3DS v2 processing."); } if (string.IsNullOrEmpty(MethodNotificationUrl)) { throw new ConfigurationException("The method notification URL is required for 3DS v2 processing."); } } } }
internal ISecure3dProvider GetSecure3DProvider(Secure3dVersion version) { if (_secure3dProviders.ContainsKey(version)) { return(_secure3dProviders[version]); } else if (version.Equals(Secure3dVersion.Any)) { var provider = _secure3dProviders[Secure3dVersion.Two]; if (provider == null) { provider = _secure3dProviders[Secure3dVersion.One]; } return(provider); } return(null); }
public ThreeDSecure Execute(Secure3dVersion version, string configName = "default") { Validations.Validate(this); // setup return object ThreeDSecure rvalue = ThreeDSecure; if (rvalue == null) { rvalue = new ThreeDSecure(); rvalue.Version = version; } // working version if (rvalue.Version != null) { version = rvalue.Version.Value; } // get the provider ISecure3dProvider provider = ServicesContainer.Instance.GetSecure3d(configName, version); if (provider != null) { bool canDowngrade = false; if (provider.Version.Equals(Secure3dVersion.Two) && version.Equals(Secure3dVersion.Any)) { try { var oneProvider = ServicesContainer.Instance.GetSecure3d(configName, Secure3dVersion.One); canDowngrade = (oneProvider != null); } catch (ConfigurationException) { /* NOT CONFIGURED */ } } /* process the request, capture any exceptions which might have been thrown */ Transaction response = null; try { response = provider.ProcessSecure3d(this); if (response == null && canDowngrade) { return(Execute(Secure3dVersion.One, configName)); } } catch (GatewayException exc) { // check for not enrolled if ("110".Equals(exc.ResponseCode) && provider.Version.Equals(Secure3dVersion.One)) { return(rvalue); } // check if we can downgrade else if (canDowngrade && TransactionType.Equals(TransactionType.VerifyEnrolled)) { return(Execute(Secure3dVersion.One, configName)); } // throw exception else { throw exc; } } // check the response if (response != null) { switch (TransactionType) { case TransactionType.VerifyEnrolled: { if (response.ThreeDSecure != null) { rvalue = response.ThreeDSecure; if (new List <string>() { "True", "Y" }.Contains(rvalue.Enrolled)) { rvalue.Amount = Amount; rvalue.Currency = Currency; rvalue.OrderId = response.OrderId; rvalue.Version = provider.Version; } else if (canDowngrade) { return(Execute(Secure3dVersion.One, configName)); } } else if (canDowngrade) { return(Execute(Secure3dVersion.One, configName)); } } break; case TransactionType.InitiateAuthentication: case TransactionType.VerifySignature: { rvalue.Merge(response.ThreeDSecure); } break; } } } return(rvalue); }
internal override void ConfigureContainer(ConfiguredServices services) { base.ConfigureContainer(services); if (string.IsNullOrEmpty(ServiceUrl)) { if (Environment.Equals(Entities.Environment.TEST)) { ServiceUrl = ServiceEndpoints.GLOBAL_ECOM_TEST; } else { ServiceUrl = ServiceEndpoints.GLOBAL_ECOM_PRODUCTION; } } var gateway = new GpEcomConnector { AccountId = AccountId, Channel = Channel, MerchantId = MerchantId, RebatePassword = RebatePassword, RefundPassword = RefundPassword, SharedSecret = SharedSecret, ShaHashType = ShaHashType, Timeout = Timeout, ServiceUrl = ServiceUrl, HostedPaymentConfig = HostedPaymentConfig, RequestLogger = RequestLogger, WebProxy = WebProxy }; services.GatewayConnector = gateway; services.RecurringConnector = gateway; // set reporting gateway if (!UseDataReportingService) { services.ReportingService = gateway; } // set default if (Secure3dVersion == null) { Secure3dVersion = Entities.Secure3dVersion.One; } // secure 3d v1 if (Secure3dVersion.Equals(Entities.Secure3dVersion.One) || Secure3dVersion.Equals(Entities.Secure3dVersion.Any)) { services.SetSecure3dProvider(Entities.Secure3dVersion.One, gateway); } // secure 3d v2 if (Secure3dVersion.Equals(Entities.Secure3dVersion.Two) || Secure3dVersion.Equals(Entities.Secure3dVersion.Any)) { Gp3DSProvider secure3d2 = new Gp3DSProvider { MerchantId = MerchantId, AccountId = AccountId, SharedSecret = SharedSecret, ServiceUrl = Environment.Equals(Entities.Environment.TEST) ? ServiceEndpoints.THREE_DS_AUTH_TEST : ServiceEndpoints.THREE_DS_AUTH_PRODUCTION, MerchantContactUrl = MerchantContactUrl, MethodNotificationUrl = MethodNotificationUrl, ChallengeNotificationUrl = ChallengeNotificationUrl, Timeout = Timeout, RequestLogger = RequestLogger, WebProxy = WebProxy //secure3d2.EnableLogging = EnableLogging }; services.SetSecure3dProvider(Entities.Secure3dVersion.Two, secure3d2); } if (EnableBankPayment) { var openBanking = new OpenBankingProvider(); openBanking.MerchantId = gateway.MerchantId; openBanking.AccountId = gateway.AccountId; openBanking.SharedSecret = gateway.SharedSecret; openBanking.ShaHashType = ShaHashType; openBanking.ServiceUrl = Environment.Equals(Entities.Environment.TEST) ? ServiceEndpoints.OPEN_BANKING_TEST : ServiceEndpoints.OPEN_BANKING_PRODUCTION; openBanking.Timeout = gateway.Timeout; openBanking.RequestLogger = RequestLogger; openBanking.WebProxy = WebProxy; services.SetOpenBanking(openBanking); } }