public static void AssignHeaders(HttpRequestHeaders headers, IdPayGatewayAccount account) { var api = account.IsTestAccount ? SandBoxApiKey : account.Api; headers.AddOrUpdate(ApiKey, api); if (account.IsTestAccount) { headers.AddOrUpdate(SandBoxKey, "1"); } else if (headers.Contains(SandBoxKey)) { headers.Remove(SandBoxKey); } }
public static async Task <PaymentRequestResult> CreateRequestResult( HttpResponseMessage responseMessage, IHttpContextAccessor httpContextAccessor, IdPayGatewayAccount account) { var response = await responseMessage.Content.ReadAsStringAsync().ConfigureAwaitFalse(); if (!responseMessage.IsSuccessStatusCode) { var errorModel = JsonConvert.DeserializeObject <IdPayErrorModel>(response); return(PaymentRequestResult.Failed(errorModel.ToString(), account.Name)); } var result = JsonConvert.DeserializeObject <IdPayRequestResultModel>(response); return(PaymentRequestResult.Succeed(new GatewayRedirect(httpContextAccessor, result.Link), account.Name)); }
public static async Task <PaymentRequestResult> CreateRequestResult( HttpResponseMessage responseMessage, HttpContext httpContext, IdPayGatewayAccount account) { var response = await responseMessage.Content.ReadAsStringAsync().ConfigureAwaitFalse(); if (!responseMessage.IsSuccessStatusCode) { var errorModel = JsonConvert.DeserializeObject <IdPayErrorModel>(response); return(PaymentRequestResult.Failed(errorModel.ToString(), account.Name)); } var result = JsonConvert.DeserializeObject <IdPayRequestResultModel>(response); var transporterDescriptor = GatewayTransporterDescriptor.CreateRedirect(result.Link); var transporter = new DefaultGatewayTransporter(httpContext, transporterDescriptor); return(PaymentRequestResult.Succeed(transporter, account.Name)); }