Example #1
0
        protected virtual async Task <Payment> PreparePaymentSwitch(UpdatePaymentMethodParam param, Payment activePayment)
        {
            //TODO: Remove for now, but we should void (Bug with Moneris when payment is PendingVerification).
            await PaymentRepository.RemovePaymentAsync(new VoidOrRemovePaymentParam
            {
                CartName    = param.CartName,
                CultureInfo = param.CultureInfo,
                CustomerId  = param.CustomerId,
                PaymentId   = activePayment.Id,
                Scope       = param.Scope
            }).ConfigureAwait(false);

            var cart = await CartRepository.AddPaymentAsync(new AddPaymentParam
            {
                BillingAddress = activePayment.BillingAddress.Clone(),
                CartName       = param.CartName,
                CultureInfo    = param.CultureInfo,
                CustomerId     = param.CustomerId,
                Scope          = param.Scope
            });

            var newPayment = GetActivePayment(cart);

            return(newPayment);
        }
Example #2
0
        public virtual Task <ProcessedCart> AddPaymentIfRequired(FixCartParam param)
        {
            var cart = param.Cart;

            if (!HasAnyValidPayment(cart))
            {
                var task = CartRepository.AddPaymentAsync(new AddPaymentParam
                {
                    CartName    = cart.Name,
                    CultureInfo = new CultureInfo(cart.CultureName),
                    CustomerId  = cart.CustomerId,
                    Scope       = cart.ScopeId
                });

                return(task);
            }

            return(Task.FromResult(cart));
        }