From d62bb2d5bdc8cfee49d9045412fe4088f88f062f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Beaulieu?= Date: Fri, 5 Mar 2021 09:35:07 -0500 Subject: [PATCH 1/2] Fixing WebProxy option for all HttpClient consumers --- src/GlobalPayments.Api/Gateways/BillPayProvider.cs | 3 +++ src/GlobalPayments.Api/ServiceConfigs/BillPayConfig.cs | 3 ++- .../ServiceConfigs/Gateways/GeniusConfig.cs | 3 ++- .../ServiceConfigs/Gateways/GpEcomConfig.cs | 6 ++++-- .../ServiceConfigs/Gateways/PorticoConfig.cs | 9 ++++++--- .../ServiceConfigs/Gateways/TransitConfig.cs | 3 ++- 6 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/GlobalPayments.Api/Gateways/BillPayProvider.cs b/src/GlobalPayments.Api/Gateways/BillPayProvider.cs index f1a06bad..e8912b1d 100644 --- a/src/GlobalPayments.Api/Gateways/BillPayProvider.cs +++ b/src/GlobalPayments.Api/Gateways/BillPayProvider.cs @@ -2,6 +2,7 @@ using GlobalPayments.Api.Entities; using GlobalPayments.Api.Entities.Billing; using GlobalPayments.Api.Gateways.BillPay; +using System.Net; namespace GlobalPayments.Api.Gateways { internal class BillPayProvider: IBillingProvider, IPaymentGateway, IRecurringService { @@ -19,6 +20,8 @@ internal class BillPayProvider: IBillingProvider, IPaymentGateway, IRecurringSer public string ServiceUrl { get; set; } + public IWebProxy WebProxy { get; set; } + /// /// Invokes a request against the BillPay gateway using the AuthorizationBuilder /// diff --git a/src/GlobalPayments.Api/ServiceConfigs/BillPayConfig.cs b/src/GlobalPayments.Api/ServiceConfigs/BillPayConfig.cs index da7d9a4f..7af04d16 100644 --- a/src/GlobalPayments.Api/ServiceConfigs/BillPayConfig.cs +++ b/src/GlobalPayments.Api/ServiceConfigs/BillPayConfig.cs @@ -22,7 +22,8 @@ internal override void ConfigureContainer(ConfiguredServices services) { }, ServiceUrl = ServiceUrl ?? ServiceEndpoints.BILLPAY_PRODUCTION, Timeout = Timeout, - IsBillDataHosted = UseBillRecordlookup + IsBillDataHosted = UseBillRecordlookup, + WebProxy = WebProxy }; services.GatewayConnector = gateway; diff --git a/src/GlobalPayments.Api/ServiceConfigs/Gateways/GeniusConfig.cs b/src/GlobalPayments.Api/ServiceConfigs/Gateways/GeniusConfig.cs index eb9931a9..6ca53c7f 100644 --- a/src/GlobalPayments.Api/ServiceConfigs/Gateways/GeniusConfig.cs +++ b/src/GlobalPayments.Api/ServiceConfigs/Gateways/GeniusConfig.cs @@ -37,7 +37,8 @@ internal override void ConfigureContainer(ConfiguredServices services) { RegisterNumber = RegisterNumber, TerminalId = TerminalId, Timeout = Timeout, - ServiceUrl = ServiceUrl + ServiceUrl = ServiceUrl, + WebProxy = WebProxy }; services.GatewayConnector = gateway; diff --git a/src/GlobalPayments.Api/ServiceConfigs/Gateways/GpEcomConfig.cs b/src/GlobalPayments.Api/ServiceConfigs/Gateways/GpEcomConfig.cs index d5245912..b186faf3 100644 --- a/src/GlobalPayments.Api/ServiceConfigs/Gateways/GpEcomConfig.cs +++ b/src/GlobalPayments.Api/ServiceConfigs/Gateways/GpEcomConfig.cs @@ -73,7 +73,8 @@ internal override void ConfigureContainer(ConfiguredServices services) { SharedSecret = SharedSecret, Timeout = Timeout, ServiceUrl = ServiceUrl, - HostedPaymentConfig = HostedPaymentConfig + HostedPaymentConfig = HostedPaymentConfig, + WebProxy = WebProxy }; services.GatewayConnector = gateway; services.RecurringConnector = gateway; @@ -98,7 +99,8 @@ internal override void ConfigureContainer(ConfiguredServices services) { MerchantContactUrl = MerchantContactUrl, MethodNotificationUrl = MethodNotificationUrl, ChallengeNotificationUrl = ChallengeNotificationUrl, - Timeout = Timeout + Timeout = Timeout, + WebProxy = WebProxy //secure3d2.EnableLogging = EnableLogging }; diff --git a/src/GlobalPayments.Api/ServiceConfigs/Gateways/PorticoConfig.cs b/src/GlobalPayments.Api/ServiceConfigs/Gateways/PorticoConfig.cs index 635b30d3..7c5f23de 100644 --- a/src/GlobalPayments.Api/ServiceConfigs/Gateways/PorticoConfig.cs +++ b/src/GlobalPayments.Api/ServiceConfigs/Gateways/PorticoConfig.cs @@ -110,7 +110,8 @@ internal override void ConfigureContainer(ConfiguredServices services) { Timeout = Timeout, ServiceUrl = ServiceUrl + "/Hps.Exchange.PosGateway/PosGatewayService.asmx", UniqueDeviceId = UniqueDeviceId, - RequestLogger = RequestLogger + RequestLogger = RequestLogger, + WebProxy = WebProxy }; services.GatewayConnector = gateway; @@ -123,7 +124,8 @@ internal override void ConfigureContainer(ConfiguredServices services) { SecretApiKey = SecretApiKey, Timeout = Timeout, ServiceUrl = ServiceUrl + PayPlanEndpoint, - RequestLogger = RequestLogger + RequestLogger = RequestLogger, + WebProxy = WebProxy }; services.RecurringConnector = payplan; @@ -142,7 +144,8 @@ internal override void ConfigureContainer(ConfiguredServices services) { TermID = TerminalID, Timeout = Timeout, ServiceUrl = ServiceUrl, - X509CertPath = X509CertificatePath + X509CertPath = X509CertificatePath, + WebProxy = WebProxy }; services.PayFacProvider = payFac; diff --git a/src/GlobalPayments.Api/ServiceConfigs/Gateways/TransitConfig.cs b/src/GlobalPayments.Api/ServiceConfigs/Gateways/TransitConfig.cs index 71ad9598..3535cb90 100644 --- a/src/GlobalPayments.Api/ServiceConfigs/Gateways/TransitConfig.cs +++ b/src/GlobalPayments.Api/ServiceConfigs/Gateways/TransitConfig.cs @@ -29,7 +29,8 @@ internal override void ConfigureContainer(ConfiguredServices services) { TransactionKey = TransactionKey, ServiceUrl = ServiceUrl, Timeout = Timeout, - RequestLogger = RequestLogger + RequestLogger = RequestLogger, + WebProxy = WebProxy }; services.GatewayConnector = gateway; From 2c574267a26e6e4c9ce99561c343e6ce32b69901 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Beaulieu?= Date: Fri, 5 Mar 2021 15:39:52 -0500 Subject: [PATCH 2/2] Send the webproxy to each of the gateways to make WebProxy option work: AuthorizationRequest, ManagementRequest, BillingRequest and RecurringRequest. --- .../Gateways/BillPay/AuthorizationRequest.cs | 4 +++- src/GlobalPayments.Api/Gateways/BillPay/BillingRequest.cs | 4 +++- .../Gateways/BillPay/ManagementRequest.cs | 4 +++- .../Gateways/BillPay/RecurringRequest.cs | 4 +++- src/GlobalPayments.Api/Gateways/BillPayProvider.cs | 8 ++++---- 5 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/GlobalPayments.Api/Gateways/BillPay/AuthorizationRequest.cs b/src/GlobalPayments.Api/Gateways/BillPay/AuthorizationRequest.cs index 43f1e5a3..e36b9790 100644 --- a/src/GlobalPayments.Api/Gateways/BillPay/AuthorizationRequest.cs +++ b/src/GlobalPayments.Api/Gateways/BillPay/AuthorizationRequest.cs @@ -4,16 +4,18 @@ using GlobalPayments.Api.PaymentMethods; using GlobalPayments.Api.Utils; using System.Linq; +using System.Net; namespace GlobalPayments.Api.Gateways.BillPay { /// /// Factory method to create and return the request object based on the transaction type /// internal class AuthorizationRequest : GatewayRequestBase { - public AuthorizationRequest(Credentials credentials, string serviceUrl, int timeout) { + public AuthorizationRequest(Credentials credentials, string serviceUrl, int timeout, IWebProxy webProxy) { this.Credentials = credentials; this.ServiceUrl = serviceUrl; this.Timeout = timeout; + this.WebProxy = webProxy; } internal Transaction Execute(AuthorizationBuilder builder, bool isBillDataHosted) { diff --git a/src/GlobalPayments.Api/Gateways/BillPay/BillingRequest.cs b/src/GlobalPayments.Api/Gateways/BillPay/BillingRequest.cs index f23e943b..d62276fd 100644 --- a/src/GlobalPayments.Api/Gateways/BillPay/BillingRequest.cs +++ b/src/GlobalPayments.Api/Gateways/BillPay/BillingRequest.cs @@ -3,17 +3,19 @@ using GlobalPayments.Api.Entities.Billing; using GlobalPayments.Api.Entities.Enums; using GlobalPayments.Api.Utils; +using System.Net; namespace GlobalPayments.Api.Gateways.BillPay { /// /// Factory method to create and return the request object based on the transaction type /// internal class BillingRequest : GatewayRequestBase { - public BillingRequest(Credentials credentials, string serviceUrl, int timeout) + public BillingRequest(Credentials credentials, string serviceUrl, int timeout, IWebProxy webPRoxy) { this.Credentials = credentials; this.ServiceUrl = serviceUrl; this.Timeout = timeout; + this.WebProxy = webPRoxy; } internal BillingResponse Execute(BillingBuilder builder) { diff --git a/src/GlobalPayments.Api/Gateways/BillPay/ManagementRequest.cs b/src/GlobalPayments.Api/Gateways/BillPay/ManagementRequest.cs index 11aa7f7e..92ade804 100644 --- a/src/GlobalPayments.Api/Gateways/BillPay/ManagementRequest.cs +++ b/src/GlobalPayments.Api/Gateways/BillPay/ManagementRequest.cs @@ -3,16 +3,18 @@ using GlobalPayments.Api.Entities.Billing; using GlobalPayments.Api.PaymentMethods; using GlobalPayments.Api.Utils; +using System.Net; namespace GlobalPayments.Api.Gateways.BillPay { /// /// Factory method to create and return the request object based on the transaction type /// internal class ManagementRequest : GatewayRequestBase { - public ManagementRequest(Credentials credentials, string serviceUrl, int timeout) { + public ManagementRequest(Credentials credentials, string serviceUrl, int timeout, IWebProxy webProxy) { this.Credentials = credentials; this.ServiceUrl = serviceUrl; this.Timeout = timeout; + this.WebProxy = webProxy; } internal Transaction Execute(ManagementBuilder builder, bool isBillDataHosted) { diff --git a/src/GlobalPayments.Api/Gateways/BillPay/RecurringRequest.cs b/src/GlobalPayments.Api/Gateways/BillPay/RecurringRequest.cs index 77278b1c..8cd1d4f4 100644 --- a/src/GlobalPayments.Api/Gateways/BillPay/RecurringRequest.cs +++ b/src/GlobalPayments.Api/Gateways/BillPay/RecurringRequest.cs @@ -3,13 +3,15 @@ using GlobalPayments.Api.Entities.Billing; using GlobalPayments.Api.PaymentMethods; using GlobalPayments.Api.Utils; +using System.Net; namespace GlobalPayments.Api.Gateways.BillPay { internal sealed class RecurringRequest : GatewayRequestBase where T: class { - public RecurringRequest(Credentials credentials, string serviceUrl, int timeout) { + public RecurringRequest(Credentials credentials, string serviceUrl, int timeout, IWebProxy webProxy) { this.Credentials = credentials; this.ServiceUrl = serviceUrl; this.Timeout = timeout; + this.WebProxy = webProxy; } internal T Execute(RecurringBuilder builder) { diff --git a/src/GlobalPayments.Api/Gateways/BillPayProvider.cs b/src/GlobalPayments.Api/Gateways/BillPayProvider.cs index e8912b1d..80a68c52 100644 --- a/src/GlobalPayments.Api/Gateways/BillPayProvider.cs +++ b/src/GlobalPayments.Api/Gateways/BillPayProvider.cs @@ -28,7 +28,7 @@ internal class BillPayProvider: IBillingProvider, IPaymentGateway, IRecurringSer /// The AuthroizationBuilder containing the required information to build the request /// A Transaction response public Transaction ProcessAuthorization(AuthorizationBuilder builder) { - return new AuthorizationRequest(Credentials, ServiceUrl, Timeout) + return new AuthorizationRequest(Credentials, ServiceUrl, Timeout, WebProxy) .Execute(builder, IsBillDataHosted); } @@ -38,18 +38,18 @@ public Transaction ProcessAuthorization(AuthorizationBuilder builder) { /// The ManagementBuilder containing the required information to build the request /// A Transaction response public Transaction ManageTransaction(ManagementBuilder builder) { - return new ManagementRequest(Credentials, ServiceUrl, Timeout) + return new ManagementRequest(Credentials, ServiceUrl, Timeout, WebProxy) .Execute(builder, IsBillDataHosted); } public BillingResponse ProcessBillingRequest(BillingBuilder builder) { - return new BillingRequest(Credentials, ServiceUrl, Timeout) + return new BillingRequest(Credentials, ServiceUrl, Timeout, WebProxy) .Execute(builder); } public T ProcessRecurring(RecurringBuilder builder) where T : class { - return new RecurringRequest(Credentials, ServiceUrl, Timeout) + return new RecurringRequest(Credentials, ServiceUrl, Timeout, WebProxy) .Execute(builder); }