public bool ProcessPayment(IPayment payment, ref string message) { try { Logger.Debug("Klarna checkout gateway. Processing Payment ...."); if (_orderForm == null) { _orderForm = OrderGroup.Forms.FirstOrDefault(form => form.Payments.Contains(payment)); } var authorizePaymentStep = new AuthorizePaymentStep(payment, OrderGroup.MarketId, KlarnaOrderServiceFactory); var capturePaymentStep = new CapturePaymentStep(payment, OrderGroup.MarketId, KlarnaOrderServiceFactory); var creditPaymentStep = new CreditPaymentStep(payment, OrderGroup.MarketId, KlarnaOrderServiceFactory); var cancelPaymentStep = new CancelPaymentStep(payment, OrderGroup.MarketId, KlarnaOrderServiceFactory); authorizePaymentStep.SetSuccessor(capturePaymentStep); capturePaymentStep.SetSuccessor(creditPaymentStep); creditPaymentStep.SetSuccessor(cancelPaymentStep); return(authorizePaymentStep.Process(payment, _orderForm, OrderGroup, OrderGroup.GetFirstShipment(), ref message)); } catch (Exception ex) { Logger.Error("Process checkout failed with error: " + ex.Message, ex); message = ex.Message; throw; } }
public PaymentStepResult ProcessPayment(IPayment payment, IShipment shipment) { var paymentStepResult = new PaymentStepResult(); _shipment = shipment; if (_orderForm == null) { _orderForm = (payment as Payment)?.Parent ?? OrderGroup?.Forms.FirstOrDefault(form => form.Payments.Contains(payment)); } if (OrderGroup == null) { OrderGroup = (_orderForm as OrderForm)?.Parent; } if (OrderGroup == null) { paymentStepResult.Message = "OrderGroup is null"; throw new Exception(paymentStepResult.Message); } try { Logger.Debug("SwedbankPay checkout gateway. Processing Payment ...."); if (_orderForm == null) { _orderForm = OrderGroup.Forms.FirstOrDefault(form => form.Payments.Contains(payment)); } var market = MarketService.GetMarket(OrderGroup.MarketId); var authorizePaymentStep = new AuthorizePaymentStep(payment, market, SwedbankPayClientFactory); var capturePaymentStep = new CapturePaymentStep(payment, market, SwedbankPayClientFactory, RequestFactory); var creditPaymentStep = new CreditPaymentStep(payment, market, SwedbankPayClientFactory, RequestFactory); var cancelPaymentStep = new CancelPaymentStep(payment, market, SwedbankPayClientFactory, RequestFactory); authorizePaymentStep.SetSuccessor(capturePaymentStep); capturePaymentStep.SetSuccessor(creditPaymentStep); creditPaymentStep.SetSuccessor(cancelPaymentStep); return(authorizePaymentStep.Process(payment, _orderForm, OrderGroup, _shipment)); } catch (Exception ex) { Logger.Error("Process checkout failed with error: " + ex.Message, ex); paymentStepResult.Message = ex.Message; throw; } }
public virtual PaymentProcessingResult ProcessPayment(IOrderGroup orderGroup, IPayment payment) { PaymentStepResult stepResult; try { Logger.Debug("Netaxept checkout gateway. Processing Payment ...."); if (_orderForm == null) { _orderForm = orderGroup.Forms.FirstOrDefault(form => form.Payments.Contains(payment)); } var registerPaymentStep = new RegisterPaymentStep(payment); var authorizationPaymentStep = new AuthorizationPaymentStep(payment); var capturePaymentStep = new CapturePaymentStep(payment); var creditPaymentStep = new CreditPaymentStep(payment); var annulPaymentStep = new AnnulPaymentStep(payment); registerPaymentStep.SetSuccessor(authorizationPaymentStep); authorizationPaymentStep.SetSuccessor(capturePaymentStep); capturePaymentStep.SetSuccessor(creditPaymentStep); creditPaymentStep.SetSuccessor(annulPaymentStep); stepResult = registerPaymentStep.Process(payment, _orderForm, orderGroup); } catch (Exception exception) { Logger.Error("Process payment failed with error: " + exception.Message, exception); stepResult = new PaymentStepResult { IsSuccessful = false, Message = exception.Message }; } if (stepResult.IsSuccessful) { return(PaymentProcessingResult.CreateSuccessfulResult(stepResult.Message, stepResult.RedirectUrl)); } // COM-10168 Payment: bug in Commerce 12 but fixed in Commerce 13.13. The unsuccessfull result is ignored by Episerver and payment is set to processed. When package // is made compatible for Commerce 13 this code can be removed and the commented out code can be restored. // return PaymentProcessingResult.CreateUnsuccessfulResult(stepResult.Message); throw new PaymentException(PaymentException.ErrorType.ProviderError, string.Empty, stepResult.Message); }
public virtual PaymentProcessingResult ProcessPayment(IOrderGroup orderGroup, IPayment payment) { PaymentStepResult stepResult; try { Logger.Debug("Netaxept checkout gateway. Processing Payment ...."); if (_orderForm == null) { _orderForm = orderGroup.Forms.FirstOrDefault(form => form.Payments.Contains(payment)); } var registerPaymentStep = new RegisterPaymentStep(payment); var capturePaymentStep = new CapturePaymentStep(payment); var creditPaymentStep = new CreditPaymentStep(payment); var annulPaymentStep = new AnnulPaymentStep(payment); registerPaymentStep.SetSuccessor(capturePaymentStep); capturePaymentStep.SetSuccessor(creditPaymentStep); creditPaymentStep.SetSuccessor(annulPaymentStep); stepResult = registerPaymentStep.Process(payment, _orderForm, orderGroup); } catch (Exception exception) { Logger.Error("Process payment failed with error: " + exception.Message, exception); stepResult = new PaymentStepResult { IsSuccessful = false, Message = exception.Message }; } if (stepResult.IsSuccessful) { return(PaymentProcessingResult.CreateSuccessfulResult(stepResult.Message, stepResult.RedirectUrl)); } return(PaymentProcessingResult.CreateUnsuccessfulResult(stepResult.Message)); }