static void Main(string[] args) { RemitaHttpClient remita = new RemitaHttpClient("27768931", "35126630", "Q1dHREVNTzEyMzR8Q1dHREVNTw=="); SetupMandate mandate = new SetupMandate { amount = "1000.00", payerAccount = "1234890001", endDate = "03/07/2020", startDate = "30/07/2020", maxNoOfDebits = "1", payerName = "John Doe", payerEmail = "*****@*****.**", payerBankCode = "057", payerPhone = "07066576295" }; var result = remita.SetUpMandateStandingOrder(mandate).Result; }
/// <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; } }