Beispiel #1
0
        /// <summary>
        /// Runs capture, updates order id and handles partial shipment
        /// </summary>
        /// <param name="reservationNumber"></param>
        /// <param name="transactionId"></param>
        /// <param name="orderId"></param>
        /// <param name="cartItems"></param>
        /// <returns></returns>
        public ActivateResponse Activate(string reservationNumber, string transactionId, string orderId, List <ICartItem> cartItems)
        {
            var result = new ActivateResponse(string.Empty, RiskStatus.Undefined, transactionId);

            try
            {
                var api = new Api(CurrentConfiguration);
                api.UpdateCart(cartItems);
                api.OrderId1 = orderId;
                api.Update(reservationNumber); // update with order id and cart items

                var response = api.Activate(reservationNumber);

                return(new ActivateResponse(response.InvoiceNumber, response.RiskStatus, transactionId)
                {
                    IsSuccess = true
                });
            }
            catch (Exception ex)
            {
                SetError(result, ex);
            }

            return(result);
        }
        public ActivateReservationResponse Activate(global::Nop.Core.Domain.Orders.Order order)
        {
            var reservation = order.AuthorizationTransactionId;

            if (!string.IsNullOrEmpty(order.CaptureTransactionId))
            {
                throw new KlarnaCheckoutException("The payment has already been captured. Order Id: " + order.Id);
            }

            try
            {
                var configuration = new Configuration(Country.Code.SE, Language.Code.SV, Currency.Code.SEK, Encoding.Sweden)
                {
                    Eid        = _klarnaSettings.EId,
                    Secret     = _klarnaSettings.SharedSecret,
                    IsLiveMode = !_klarnaSettings.TestMode
                };

                var api = new Api(configuration);
                return(api.Activate(reservation));
            }
            catch (Exception ex)
            {
                throw new KlarnaCheckoutException("Error activating Klarna reservation for order " + order.Id, ex);
            }
        }
        public ActivateReservationResponse Activate(global::Nop.Core.Domain.Orders.Order order)
        {
            var reservation = order.AuthorizationTransactionId;

            if (!string.IsNullOrEmpty(order.CaptureTransactionId))
            {
                throw new KlarnaCheckoutException("The payment has already been captured. Order Id: " + order.Id);
            }

            try
            {
                var configuration = new Configuration(Country.Code.SE, Language.Code.SV, Currency.Code.SEK, Encoding.Sweden)
                {
                    Eid = _klarnaSettings.EId,
                    Secret = _klarnaSettings.SharedSecret,
                    IsLiveMode = !_klarnaSettings.TestMode
                };

                var api = new Api(configuration);
                return api.Activate(reservation);
            }
            catch (Exception ex)
            {
                throw new KlarnaCheckoutException("Error activating Klarna reservation for order " + order.Id, ex);
            }
        }
        public ActivateReservationResponse Activate(string reservation, global::Nop.Core.Domain.Customers.Customer customer)
        {
            try
            {
                var configuration = new Configuration(Country.Code.SE, Language.Code.SV, Currency.Code.SEK, Encoding.Sweden)
                {
                    Eid = _klarnaSettings.EId,
                    Secret = _klarnaSettings.SharedSecret,
                    IsLiveMode = !_klarnaSettings.TestMode
                };

                var api = new Api(configuration);
                var result = api.Activate(reservation);

                _logger.Debug(string.Format(CultureInfo.InvariantCulture, "KlarnaCheckout: Reservation Activated: RiskStatus: {0}, InvoiceNumber: {1}",
                    result.RiskStatus, result.InvoiceNumber), customer: customer);

                return result;
            }
            catch (Exception ex)
            {
                _logger.Error("KlarnaCheckout: Error activating reservation: " + reservation, exception: ex, customer: customer);
            }

            return null;
        }