public bool CancelReservation(string s) { return(_klarnaApi.CancelReservation(s)); }
public override VoidProcessPaymentResult VoidProcessPayment(VoidProcessPaymentEvaluationContext context) { if (context == null) throw new ArgumentNullException("context"); if (context.Payment == null) throw new ArgumentNullException("context.Payment"); var retVal = new VoidProcessPaymentResult(); if (!context.Payment.IsApproved && (context.Payment.PaymentStatus == PaymentStatus.Authorized || context.Payment.PaymentStatus == PaymentStatus.Cancelled)) { 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 result = api.CancelReservation(reservation); if (result) { retVal.NewPaymentStatus = context.Payment.PaymentStatus = PaymentStatus.Voided; context.Payment.VoidedDate = context.Payment.CancelledDate = DateTime.UtcNow; context.Payment.IsCancelled = true; retVal.IsSuccess = true; } else { retVal.ErrorMessage = "Payment was not canceled, try later"; } } catch(Exception ex) { retVal.ErrorMessage = ex.Message; } } } else if(context.Payment.IsApproved) { retVal.ErrorMessage = "Payment already approved, use refund"; retVal.NewPaymentStatus = PaymentStatus.Paid; } else if(context.Payment.IsCancelled) { retVal.ErrorMessage = "Payment already canceled"; retVal.NewPaymentStatus = PaymentStatus.Voided; } return retVal; }
public override VoidProcessPaymentResult VoidProcessPayment(VoidProcessPaymentEvaluationContext context) { if (context == null) { throw new ArgumentNullException("context"); } if (context.Payment == null) { throw new ArgumentNullException("context.Payment"); } var retVal = new VoidProcessPaymentResult(); if (!context.Payment.IsApproved && (context.Payment.PaymentStatus == PaymentStatus.Authorized || context.Payment.PaymentStatus == PaymentStatus.Cancelled)) { 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 result = api.CancelReservation(reservation); if (result) { retVal.NewPaymentStatus = context.Payment.PaymentStatus = PaymentStatus.Voided; context.Payment.VoidedDate = context.Payment.CancelledDate = DateTime.UtcNow; context.Payment.IsCancelled = true; retVal.IsSuccess = true; } else { retVal.ErrorMessage = "Payment was not canceled, try later"; } } catch (Exception ex) { retVal.ErrorMessage = ex.Message; } } } else if (context.Payment.IsApproved) { retVal.ErrorMessage = "Payment already approved, use refund"; retVal.NewPaymentStatus = PaymentStatus.Paid; } else if (context.Payment.IsCancelled) { retVal.ErrorMessage = "Payment already canceled"; retVal.NewPaymentStatus = PaymentStatus.Voided; } return(retVal); }