/// <summary> /// Returns MandateSetupResponse and string that represents the meaning of the status code returned from the remita API /// /// If the HTTP response Status Code returned from Remita is not 200, you'll receieve a tuple value of null and the HTTP response code received from remita /// /// The hash value is also automatically handled from the code. /// /// The mandate Type sepcified in the contructor. /// /// </summary> /// <param name="mandate"></param> /// <returns></returns> public async Task <MandateSetupResponse> SetUpMandateStandingOrder(SetupMandate mandate) { try { _hash = Util.SHA512Hash(_merchantId + _serviceTypeId + _requestId + mandate.amount + _apiKey); mandate.hash = _hash; mandate.mandateType = _mandateType; mandate.requestId = _requestId; mandate.serviceTypeId = _serviceTypeId; mandate.mandateType = _mandateType; mandate.merchantId = _merchantId; mandate.startDate = Convert.ToDateTime(mandate.startDate).ToString("dd/M/yyyy", CultureInfo.InvariantCulture); mandate.endDate = Convert.ToDateTime(mandate.endDate).ToString("dd/M/yyyy", CultureInfo.InvariantCulture); _client.BaseAddress = new Uri($"{_remitaBaseUrl}{_mandateSetUpUrl}"); var payLoad = JsonConvert.SerializeObject(mandate); var content = new StringContent(payLoad, Encoding.UTF8, "application/json"); var response = await _client.PostAsync("", content); if (response.IsSuccessStatusCode) { var resultStream = await response.Content.ReadAsStreamAsync(); var returnResult = JsonExtensions.DeserializeEmbeddedJsonP <MandateSetupResponse>(resultStream); return(returnResult); } else { return(null); } } catch (Exception ex) { throw ex; } }