コード例 #1
0
        public CompletionResult Complete(IPurchaseOrder purchaseOrder)
        {
            if (purchaseOrder == null)
            {
                throw new ArgumentNullException(nameof(purchaseOrder));
            }
            var orderForm = purchaseOrder.GetFirstForm();
            var payment   = orderForm?.Payments.FirstOrDefault(x => x.PaymentMethodName.Equals(Constants.KlarnaPaymentSystemKeyword));

            if (payment == null)
            {
                return(CompletionResult.Empty);
            }

            SetOrderStatus(purchaseOrder, payment);

            var url = payment.Properties[Constants.KlarnaConfirmationUrlPaymentField]?.ToString();

            if (string.IsNullOrEmpty(url))
            {
                return(CompletionResult.Empty);
            }

            return(CompletionResult.WithRedirectUrl(url));
        }