示例#1
0
 private async Task <string> InitializeCharge(ChargesTemplate charges)
 {
     try
     {
         var client = GetClient();
         var url    = urlBase;
         HttpResponseMessage httpResponse = new HttpResponseMessage();
         var json = JsonConvert.SerializeObject(charges);
         return(await GetContent(httpResponse, json, url, client));
     }
     catch (Exception e)
     {
         return(e.Message);
     }
 }
示例#2
0
        public async Task <ActionResult <string> > PayCharge(string name, ChargesTemplate charges)
        {
            if (name == null)
            {
                return(NotFound());
            }
            var getcake = await cake.GetCake(name);

            charges.Amount = getcake.Price;
            var newcharge = await InitializeCharge(charges);

            verification = JsonConvert.DeserializeObject <Verification>(newcharge);
            if (verification != null)
            {
                return(Ok(verification.Data.Reference));
            }
            return(BadRequest("Try again"));
        }