/// <summary> /// Refund. This method allows you make a refund. /// In this case a Refund button will be visible on the order details page in admin area. /// Note that an order should be paid, and SupportRefund or SupportPartiallyRefund property should return true. /// </summary> /// <param name="refundPaymentRequest"></param> /// <returns></returns> public RefundPaymentResult Refund(RefundPaymentRequest refundPaymentRequest) { ListResponse <OrderResponse> listResponse = _mollieOrderClient.GetOrderListAsync().Result; var mollieOrderId = ""; foreach (var orderItem in listResponse.Items) { if (orderItem.OrderNumber == refundPaymentRequest.Order.CustomOrderNumber) { mollieOrderId = orderItem.Id; } } if (string.IsNullOrEmpty(mollieOrderId)) { return new RefundPaymentResult { Errors = new[] { "Mollie OrderID is Null or Empty" } } } ; OrderResponse retrieveOrder = _mollieOrderClient.GetOrderAsync(mollieOrderId).Result; var orderlineList = new List <OrderLineDetails>(); foreach (var item in _orderService.GetOrderItems(refundPaymentRequest.Order.Id)) { foreach (var line in retrieveOrder.Lines) { orderlineList.Add(new OrderLineDetails() { Id = line.Id, Quantity = item.Quantity, Amount = new Amount(SelectCurrency().CurrencyCode, line.TotalAmount) }); } } OrderRefundRequest refundRequest = new OrderRefundRequest() { Lines = orderlineList }; OrderRefundResponse result = _mollieOrderClient.CreateOrderRefundAsync(mollieOrderId, refundRequest).Result; return(new RefundPaymentResult { NewPaymentStatus = refundPaymentRequest.IsPartialRefund ? PaymentStatus.PartiallyRefunded : PaymentStatus.Refunded }); }