private async Task <bool> ValidateDataAsync(PayFastNotify notifyViewModel) { try { var nameValueList = this.Notify.GetUnderlyingProperties(); if (nameValueList == null) { return(false); } using (var formContent = new FormUrlEncodedContent(nameValueList)) { using (var webClient = new HttpClient()) { //Forces use of higher ssl. Connection was being forcibly closed on the payfast sandbox when attempting to validate. System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls; using (var response = await webClient.PostAsync(this.Settings.ValidateUrl, formContent)) { if (response.IsSuccessStatusCode) { var result = await response.Content.ReadAsStringAsync(); if (result == null || !result.Equals("VALID")) { return(false); } return(true); } return(false); } } } } catch (Exception ex) { throw ex; } }
private async Task <bool> ValidateDataAsync(PayFastNotify notifyViewModel) { try { var nameValueList = this.Notify.GetUnderlyingProperties(); if (nameValueList == null) { return(false); } using (var formContent = new FormUrlEncodedContent(nameValueList)) { using (var webClient = new HttpClient()) { using (var response = await webClient.PostAsync(this.Settings.ValidateUrl, formContent)) { if (response.IsSuccessStatusCode) { var result = await response.Content.ReadAsStringAsync(); if (result == null || !result.Equals("VALID")) { return(false); } return(true); } return(false); } } } } catch (Exception ex) { throw ex; } }
public PayFastValidator(PayFastSettings settings, PayFastNotify notify, IPAddress requestIpAddress) { this.Settings = settings; this.Notify = notify; this.RequestIpAddress = requestIpAddress; }