private PostProcessPaymentResult OldRegisterKlarnaOrder(PostProcessPaymentEvaluationContext context) { var retVal = new PostProcessPaymentResult(); Uri resourceUri = new Uri(string.Format("{0}/{1}", _euroTestBaseUrl, context.OuterId)); var connector = Connector.Create(AppSecret); Order order = new Order(connector, resourceUri) { ContentType = _contentType }; order.Fetch(); var status = order.GetValue("status") as string; if (status == "checkout_complete") { var data = new Dictionary <string, object> { { "status", "created" } }; order.Update(data); order.Fetch(); status = order.GetValue("status") as string; } if (status == "created") { var reservation = order.GetValue("reservation") as string; if (!string.IsNullOrEmpty(reservation)) { Configuration configuration = new Configuration(Country.Code.SE, Language.Code.SV, Currency.Code.SEK, Encoding.Sweden) { Eid = Convert.ToInt32(AppKey), Secret = AppSecret, IsLiveMode = false }; Api.Api api = new Api.Api(configuration); var response = api.Activate(reservation); order.Fetch(); var klarnaCart = order.GetValue("cart") as JObject; } } retVal.IsSuccess = status == "created"; retVal.NewPaymentStatus = retVal.IsSuccess ? PaymentStatus.Paid : PaymentStatus.Pending; retVal.OrderId = context.Order.Id; return(retVal); }
public override CaptureProcessPaymentResult CaptureProcessPayment(CaptureProcessPaymentEvaluationContext context) { if (context == null) { throw new ArgumentNullException("context"); } if (context.Payment == null) { throw new ArgumentNullException("context.Payment"); } var retVal = new CaptureProcessPaymentResult(); Uri resourceUri = new Uri(string.Format("{0}/{1}", _euroTestBaseUrl, context.Payment.OuterId)); var connector = Connector.Create(AppSecret); Order order = new Order(connector, resourceUri) { ContentType = _contentType }; order.Fetch(); var reservation = order.GetValue("reservation") as string; if (!string.IsNullOrEmpty(reservation)) { try { Configuration configuration = new Configuration(Country.Code.SE, Language.Code.SV, Currency.Code.SEK, Encoding.Sweden) { Eid = Convert.ToInt32(AppKey), Secret = AppSecret, IsLiveMode = false }; Api.Api api = new Api.Api(configuration); var response = api.Activate(reservation); retVal.NewPaymentStatus = context.Payment.PaymentStatus = PaymentStatus.Paid; context.Payment.CapturedDate = DateTime.UtcNow; context.Payment.IsApproved = true; retVal.IsSuccess = true; retVal.OuterId = context.Payment.OuterId = response.InvoiceNumber; } catch (Exception ex) { retVal.ErrorMessage = ex.Message; } } else { retVal.ErrorMessage = "No reservation for this order"; } return(retVal); }
public override CaptureProcessPaymentResult CaptureProcessPayment(CaptureProcessPaymentEvaluationContext context) { if (context == null) throw new ArgumentNullException("context"); if (context.Payment == null) throw new ArgumentNullException("context.Payment"); var retVal = new CaptureProcessPaymentResult(); Uri resourceUri = new Uri(string.Format("{0}/{1}", _euroTestBaseUrl, context.Payment.OuterId)); var connector = Connector.Create(AppSecret); Order order = new Order(connector, resourceUri) { ContentType = _contentType }; order.Fetch(); var reservation = order.GetValue("reservation") as string; if (!string.IsNullOrEmpty(reservation)) { try { Configuration configuration = new Configuration(Country.Code.SE, Language.Code.SV, Currency.Code.SEK, Encoding.Sweden) { Eid = Convert.ToInt32(AppKey), Secret = AppSecret, IsLiveMode = false }; Api.Api api = new Api.Api(configuration); var response = api.Activate(reservation); retVal.NewPaymentStatus = context.Payment.PaymentStatus = PaymentStatus.Paid; context.Payment.CapturedDate = DateTime.UtcNow; context.Payment.IsApproved = true; retVal.IsSuccess = true; retVal.OuterId = context.Payment.OuterId = response.InvoiceNumber; } catch(Exception ex) { retVal.ErrorMessage = ex.Message; } } else { retVal.ErrorMessage = "No reservation for this order"; } return retVal; }
public ActivateReservationResponse Activate(string s) { return(_klarnaApi.Activate(s)); }
private PostProcessPaymentResult OldRegisterKlarnaOrder(PostProcessPaymentEvaluationContext context) { var retVal = new PostProcessPaymentResult(); Uri resourceUri = new Uri(string.Format("{0}/{1}", _euroTestBaseUrl, context.OuterId)); var connector = Connector.Create(AppSecret); Order order = new Order(connector, resourceUri) { ContentType = _contentType }; order.Fetch(); var status = order.GetValue("status") as string; if (status == "checkout_complete") { var data = new Dictionary<string, object> { { "status", "created" } }; order.Update(data); order.Fetch(); status = order.GetValue("status") as string; } if (status == "created") { var reservation = order.GetValue("reservation") as string; if (!string.IsNullOrEmpty(reservation)) { Configuration configuration = new Configuration(Country.Code.SE, Language.Code.SV, Currency.Code.SEK, Encoding.Sweden) { Eid = Convert.ToInt32(AppKey), Secret = AppSecret, IsLiveMode = false }; Api.Api api = new Api.Api(configuration); var response = api.Activate(reservation); order.Fetch(); var klarnaCart = order.GetValue("cart") as JObject; } } retVal.IsSuccess = status == "created"; retVal.NewPaymentStatus = retVal.IsSuccess ? PaymentStatus.Paid : PaymentStatus.Pending; retVal.OrderId = context.Order.Id; return retVal; }