public async Task <ActionResult> PutAsync(int id, [FromBody] Mandates item) { if (!ModelState.IsValid || id != item.id) { return(BadRequest()); } try { var exist = await service.GetByIdAsync(id); if (exist != null) { var result = await service.UpdateAsync(item); return(result ? Ok(item) : StatusCode(500, new Response() { Status = false, Description = "Error updating record" })); } else { return(BadRequest()); } } catch (Exception ex) { logger.LogError(ex.Message); return(StatusCode(500, new Response() { Status = false, Description = "System error" })); } }
public Mandates ListMandates(string customerId) { string jsonData = LoadWebRequest("GET", "customers/" + customerId + "/mandates", ""); Mandates mandates = JsonConvert.DeserializeObject <Mandates>(jsonData, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); return(mandates); }
protected void submit(object sender, System.EventArgs e) { string apiKey = System.Configuration.ConfigurationManager.AppSettings["ApiKey"]; string apiSecret = System.Configuration.ConfigurationManager.AppSettings["ApiSecret"]; string accountNumber = System.Configuration.ConfigurationManager.AppSettings["AccountNumber"]; PaysafeApiClient client = new PaysafeApiClient(apiKey, apiSecret, Paysafe.Environment.TEST, accountNumber); try { Profile profile = client.customerVaultService().create(Profile.Builder() .merchantCustomerId(System.Guid.NewGuid().ToString()) .locale("en_US") .firstName("John") .lastName("Smith") .email("*****@*****.**") .phone("713-444-5555") .Build()); Address address = client.customerVaultService().create(Address.Builder() .nickName("home") .street("100 Queen Street West") .street2("Unit 201") .city("Toronto") .country("CA") .state("ON") .zip("M5H 2N2") .recipientName("Jane Doe") .phone("647-788-3901") .profileId(profile.id()) .Build()); List <Mandates> mandateList = new List <Mandates>(); Mandates mandate = Mandates.Builder() .reference("SUBCRIP35") .Build(); mandateList.Add(mandate); SEPABankAccounts account = client.customerVaultService().create(SEPABankAccounts.Builder() .iban(Request.Form["iban"]) .bic(Request.Form["bic"]) .mandates(mandateList) .accountHolderName(Request.Form["account_holder_name"]) .nickName(Request.Form["nick_name"]) .billingAddressId(address.id()) .profileId(profile.id()) .Build()); this.response = account.ToString(); } catch (Exception ex) { Response.Write("<font style=\"color: #FF0000;\">Error Message is : " + ex.Message + "</font>\n"); } }
public async Task <ActionResult> PostAsync([FromBody] Mandates item) { if (!ModelState.IsValid) { return(BadRequest()); } try { var exist = await service.GetAsync(x => x.mandatereference == item.mandatereference); if (exist != null) { return(Conflict(new Response() { Status = false, Description = "Duplicate record" })); } var result = await service.AddAsync(item); if (result) { var newitem = await service.GetAsync(x => x.mandatereference == item.mandatereference); return(StatusCode(201, newitem)); } else { return(BadRequest()); } } catch (Exception ex) { logger.LogError(ex.Message); return(StatusCode(500, new Response() { Status = false, Description = "System error" })); } }