public async Task Payment_Card_Capture(Product[] products, PayexInfo payexInfo)
        {
            GoToOrdersPage(products, payexInfo, Checkout.Option.LocalPaymentMenu)
            .PaymentLink.StoreValueAsUri(out var paymentLink)
            .Actions.Rows[y => y.Name.Value.Contains(PaymentResourceOperations.CreateCapture)].ExecuteAction.ClickAndGo()
            .Actions.Rows[y => y.Name.Value.Contains(PaymentResourceOperations.CreateReversal)].Should.BeVisible()
            .Actions.Rows[y => y.Name.Value.Contains(PaymentResourceOperations.PaidPayment)].Should.BeVisible()
            .Actions.Rows[y => y.Name.Value.Contains(PaymentResourceOperations.ViewPayment)].Should.BeVisible()
            .Actions.Rows.Count.Should.Equal(3);

            var cardPayment = await SwedbankPayClient.Payments.CardPayments.Get(paymentLink, PaymentExpand.All);

            // Operations
            Assert.That(cardPayment.Operations[LinkRelation.CreateCancellation], Is.Null);
            Assert.That(cardPayment.Operations[LinkRelation.CreateCapture], Is.Null);
            Assert.That(cardPayment.Operations[LinkRelation.PaidPayment], Is.Not.Null);
            Assert.That(cardPayment.Operations[LinkRelation.CreateReversal], Is.Not.Null);

            // Transactions
            Assert.That(cardPayment.Payment.Transactions.TransactionList.Count, Is.EqualTo(2));
            Assert.That(cardPayment.Payment.Transactions.TransactionList.First(x => x.Type == TransactionType.Authorization).State,
                        Is.EqualTo(State.Completed));
            Assert.That(cardPayment.Payment.Transactions.TransactionList.First(x => x.Type == TransactionType.Capture).State,
                        Is.EqualTo(State.Completed));
        }
        public void Anonymous_PaymentOrder_Invoice_Reversal(Product[] products, PayexInfo payexInfo)
        {
            Assert.DoesNotThrowAsync(async() => {
                _ = GoToOrdersPage(products, payexInfo, Checkout.Option.Anonymous)
                    .PaymentOrderLink.StoreValueAsUri(out var orderLink)
                    .Actions.Rows[y => y.Name.Value.Contains(PaymentOrderResourceOperations.CreatePaymentOrderCapture)].ExecuteAction.ClickAndGo()
                    .Actions.Rows[y => y.Name.Value.Contains(PaymentOrderResourceOperations.CreatePaymentOrderReversal)].ExecuteAction.ClickAndGo()
                    .Actions.Rows[y => y.Name.Value.Contains(PaymentOrderResourceOperations.PaidPaymentOrder)].Should.BeVisible()
                    .Actions.Rows.Count.Should.Equal(1);

                var order = await SwedbankPayClient.PaymentOrders.Get(orderLink, PaymentOrderExpand.All);

                // Operations
                Assert.That(order.Operations[LinkRelation.CreatePaymentOrderCancel], Is.Null);
                Assert.That(order.Operations[LinkRelation.CreatePaymentOrderCapture], Is.Null);
                Assert.That(order.Operations[LinkRelation.CreatePaymentOrderReversal], Is.Null);
                Assert.That(order.Operations[LinkRelation.PaidPaymentOrder], Is.Not.Null);

                // Transactions
                Assert.That(order.PaymentOrder.CurrentPayment.Payment.Transactions.TransactionList.Count, Is.EqualTo(4));
                //Assert.That(order.PaymentOrder.CurrentPayment.Payment.Transactions.TransactionList.First(x => x.Type == "Initialization").State,
                //            Is.EqualTo(State.Completed));
                Assert.That(order.PaymentOrder.CurrentPayment.Payment.Transactions.TransactionList.First(x => x.Type == TransactionType.Authorization).State,
                            Is.EqualTo(State.Completed));
                Assert.That(order.PaymentOrder.CurrentPayment.Payment.Transactions.TransactionList.First(x => x.Type == TransactionType.Capture).State,
                            Is.EqualTo(State.Completed));
                Assert.That(order.PaymentOrder.CurrentPayment.Payment.Transactions.TransactionList.First(x => x.Type == TransactionType.Reversal).State,
                            Is.EqualTo(State.Completed));
            });
        }
        public async Task Payment_Card_Authorization(Product[] products, PayexInfo payexInfo)
        {
            GoToOrdersPage(products, payexInfo, Checkout.Option.LocalPaymentMenu)
            .PaymentLink.StoreValueAsUri(out var paymentLink)
            .Actions.Rows[y => y.Name.Value.Contains(PaymentResourceOperations.CreateCancellation)].Should.BeVisible()
            .Actions.Rows[y => y.Name.Value.Contains(PaymentResourceOperations.CreateCapture)].Should.BeVisible()
            .Actions.Rows[y => y.Name.Value.Contains(PaymentResourceOperations.PaidPayment)].Should.BeVisible()
            .Actions.Rows[y => y.Name.Value.Contains(PaymentResourceOperations.ViewPayment)].Should.BeVisible()
            .Actions.Rows.Count.Should.Equal(4);

            var cardPayment = await SwedbankPayClient.Payments.CardPayments.Get(paymentLink, PaymentExpand.All);

            // Global Order
            Assert.That(cardPayment.Payment.Amount.InLowestMonetaryUnit, Is.EqualTo(products.Select(x => x.UnitPrice * x.Quantity).Sum()));
            Assert.That(cardPayment.Payment.Currency.ToString(), Is.EqualTo("SEK"));
            Assert.That(cardPayment.Payment.State, Is.EqualTo(State.Ready));

            // Operations
            Assert.That(cardPayment.Operations[LinkRelation.CreateReversal], Is.Null);
            Assert.That(cardPayment.Operations[LinkRelation.CreateCancellation], Is.Not.Null);
            Assert.That(cardPayment.Operations[LinkRelation.CreateCapture], Is.Not.Null);
            Assert.That(cardPayment.Operations[LinkRelation.PaidPayment], Is.Not.Null);

            // Transactions
            Assert.That(cardPayment.Payment.Transactions.TransactionList.Count, Is.EqualTo(1));
            Assert.That(cardPayment.Payment.Transactions.TransactionList.First(x => x.Type == TransactionType.Authorization).State,
                        Is.EqualTo(State.Completed));
        }
示例#4
0
        protected OrdersPage GoToOrdersPage(Product[] products, PayexInfo payexInfo, Checkout.Option checkout = Checkout.Option.Anonymous)
        {
            ThankYouPage page = null;

            switch (payexInfo)
            {
            case PayexCardInfo cardInfo:
                page = PayWithPayexCard(products, cardInfo, checkout);
                break;

            case PayexSwishInfo swishInfo:
                page = PayWithPayexSwish(products, swishInfo, checkout);
                break;

            case PayexInvoiceInfo invoiceInfo:
                page = PayWithPayexInvoice(products, invoiceInfo, checkout);
                break;

            case PayexTrustlyInfo trustlyInfo:
                page = PayWithPayexTrustly(products, trustlyInfo, checkout);
                break;
            }

            return(page?
                   .ThankYou.IsVisible.WaitTo.Within(120).BeTrue()
                   .Header.Orders.ClickAndGo());
        }
示例#5
0
        public void Update_PaymentOrder(Product[] products, PayexInfo payexInfo)
        {
            Assert.DoesNotThrowAsync(async() => {
                GoToPayexSwishPaymentFrame(products.Skip(1).ToArray())
                .Pay.Content.Should.BeEquivalent($"Betala {string.Format("{0:N2}", Convert.ToDecimal(products.Skip(1).First().UnitPrice / 100 * products.Skip(1).First().Quantity))} kr")
                .SwitchToRoot <HomePage>()
                .Header.Products.ClickAndGo();

                GoToOrdersPage(products, payexInfo, Checkout.Option.Anonymous)
                .PaymentOrderLink.StoreValueAsUri(out var orderLink)
                .Actions.Rows[y => y.Name.Value.Contains(PaymentOrderResourceOperations.CreatePaymentOrderCancel)].Should.BeVisible()
                .Actions.Rows[y => y.Name.Value.Contains(PaymentOrderResourceOperations.CreatePaymentOrderCapture)].Should.BeVisible()
                .Actions.Rows[y => y.Name.Value.Contains(PaymentOrderResourceOperations.PaidPaymentOrder)].Should.BeVisible()
                .Actions.Rows.Count.Should.Equal(3);

                await SwedbankPayClient.PaymentOrders.Get(orderLink, PaymentOrderExpand.All);
            });
        }
示例#6
0
        public void Payment_Invoice_Cancellation(Product[] products, PayexInfo payexInfo)
        {
            Assert.DoesNotThrowAsync(async() => {
                GoToOrdersPage(products, payexInfo, Checkout.Option.LocalPaymentMenu)
                .PaymentLink.StoreValueAsUri(out var paymentLink)
                .Actions.Rows[y => y.Name.Value.Contains(PaymentResourceOperations.CreateCancellation)].ExecuteAction.ClickAndGo();

                var invoicePayment = await SwedbankPayClient.Payments.InvoicePayments.Get(paymentLink, PaymentExpand.All);

                // Operations
                Assert.That(invoicePayment.Operations[LinkRelation.CreateCancellation], Is.Not.Null);
                Assert.That(invoicePayment.Operations[LinkRelation.CreateCapture], Is.Not.Null);
                Assert.That(invoicePayment.Operations[LinkRelation.CreateReversal], Is.Null);
                Assert.That(invoicePayment.Operations[LinkRelation.PaidPayment], Is.Not.Null);

                // Transactions
                Assert.That(invoicePayment.Payment.Transactions.TransactionList.Count, Is.EqualTo(2));
            });
        }
        public void Standard_PaymentOrder_Invoice_Authorization(Product[] products, PayexInfo payexInfo)
        {
            Assert.DoesNotThrowAsync(async() => {
                GoToOrdersPage(products, payexInfo, Checkout.Option.Standard)
                .PaymentOrderLink.StoreValueAsUri(out var orderLink)
                .Actions.Rows[y => y.Name.Value.Contains(PaymentOrderResourceOperations.CreatePaymentOrderCancel)].Should.BeVisible()
                .Actions.Rows[y => y.Name.Value.Contains(PaymentOrderResourceOperations.CreatePaymentOrderCapture)].Should.BeVisible()
                .Actions.Rows[y => y.Name.Value.Contains(PaymentOrderResourceOperations.PaidPaymentOrder)].Should.BeVisible()
                .Actions.Rows.Count.Should.Equal(3);

                var order = await SwedbankPayClient.PaymentOrders.Get(orderLink, PaymentOrderExpand.All);

                // Global Order
                Assert.That(order.PaymentOrder.Amount.InLowestMonetaryUnit, Is.EqualTo(products.Select(x => x.UnitPrice * x.Quantity).Sum()));
                Assert.That(order.PaymentOrder.Currency.ToString(), Is.EqualTo("SEK"));
                Assert.That(order.PaymentOrder.State, Is.EqualTo(State.Ready));

                // Operations
                Assert.That(order.Operations[LinkRelation.CreatePaymentOrderReversal], Is.Null);
                Assert.That(order.Operations[LinkRelation.CreateCancellation], Is.Not.Null);
                Assert.That(order.Operations[LinkRelation.CreatePaymentOrderCapture], Is.Not.Null);
                Assert.That(order.Operations[LinkRelation.PaidPaymentOrder], Is.Not.Null);

                // Transactions
                Assert.That(order.PaymentOrder.CurrentPayment.Payment.Transactions.TransactionList.Count, Is.EqualTo(2));
                Assert.That(order.PaymentOrder.CurrentPayment.Payment.Transactions.TransactionList.First(x => x.Type == TransactionType.Initialization).State,
                            Is.EqualTo(State.Completed));
                Assert.That(order.PaymentOrder.CurrentPayment.Payment.Transactions.TransactionList.First(x => x.Type == TransactionType.Authorization).State,
                            Is.EqualTo(State.Completed));

                // Order Items
                Assert.That(order.PaymentOrder.OrderItems.OrderItemList.Count, Is.EqualTo(products.Count()));
                for (var i = 0; i < products.Count(); i++)
                {
                    Assert.That(order.PaymentOrder.OrderItems.OrderItemList.ElementAt(i).Name, Is.EqualTo(products[i].Name));
                    Assert.That(order.PaymentOrder.OrderItems.OrderItemList.ElementAt(i).UnitPrice.InLowestMonetaryUnit, Is.EqualTo(products[i].UnitPrice));
                    Assert.That(order.PaymentOrder.OrderItems.OrderItemList.ElementAt(i).Quantity, Is.EqualTo(products[i].Quantity));
                    Assert.That(order.PaymentOrder.OrderItems.OrderItemList.ElementAt(i).Amount.InLowestMonetaryUnit, Is.EqualTo(products[i].UnitPrice * products[i].Quantity));
                }
            });
        }
        public void Anonymous_PaymentOrder_Swish_Reversal(Product[] products, PayexInfo payexInfo)
        {
            Assert.DoesNotThrowAsync(async() => {
                GoToOrdersPage(products, payexInfo, Checkout.Option.Anonymous)
                .PaymentOrderLink.StoreValueAsUri(out var orderLink)
                .Actions.Rows[y => y.Name.Value.Contains(PaymentOrderResourceOperations.CreatePaymentOrderReversal)].ExecuteAction.ClickAndGo()
                .Actions.Rows[y => y.Name.Value.Contains(PaymentOrderResourceOperations.PaidPaymentOrder)].Should.BeVisible()
                .Actions.Rows.Count.Should.Equal(1);

                var counter = 0;
                var order   = await SwedbankPayClient.PaymentOrders.Get(orderLink, PaymentOrderExpand.All);

                while (order.PaymentOrder.CurrentPayment.Payment.Transactions.TransactionList.First(x => x.Type == TransactionType.Reversal).State != State.Completed && counter <= 15)
                {
                    Thread.Sleep(1000);
                    try
                    {
                        order = await SwedbankPayClient.PaymentOrders.Get(orderLink, PaymentOrderExpand.All);
                    }
                    catch { }
                    counter++;
                }

                // Operations
                Assert.That(order.Operations[LinkRelation.CreatePaymentOrderCancel], Is.Null);
                Assert.That(order.Operations[LinkRelation.CreatePaymentOrderCapture], Is.Null);
                Assert.That(order.Operations[LinkRelation.CreatePaymentOrderReversal], Is.Null);
                Assert.That(order.Operations[LinkRelation.PaidPaymentOrder], Is.Not.Null);

                // Transactions
                Assert.That(order.PaymentOrder.CurrentPayment.Payment.Transactions.TransactionList.Count, Is.EqualTo(2));
                Assert.That(order.PaymentOrder.CurrentPayment.Payment.Transactions.TransactionList.First(x => x.Type == TransactionType.Sale).State,
                            Is.EqualTo(State.Completed));
                Assert.That(order.PaymentOrder.CurrentPayment.Payment.Transactions.TransactionList.First(x => x.Type == TransactionType.Reversal).State,
                            Is.EqualTo(State.Completed));
            });
        }
        public async Task Payment_Swish_Reversal(Product[] products, PayexInfo payexInfo)
        {
            GoToOrdersPage(products, payexInfo, Checkout.Option.LocalPaymentMenu)
            .PaymentLink.StoreValueAsUri(out var paymentLink)
            .Actions.Rows[y => y.Name.Value.Contains(PaymentResourceOperations.CreateReversal)].ExecuteAction.ClickAndGo()
            .Actions.Rows[y => y.Name.Value.Contains(PaymentResourceOperations.ViewPayment)].Should.BeVisible()
            .Actions.Rows.Count.Should.Equal(1);

            var swishPayment = await SwedbankPayClient.Payments.SwishPayments.Get(paymentLink, PaymentExpand.All);

            var counter = 0;

            while (swishPayment.Payment.Transactions.TransactionList.First(x => x.Type == TransactionType.Reversal).State != State.Completed && counter <= 15)
            {
                Thread.Sleep(1000);
                try
                {
                    swishPayment = await SwedbankPayClient.Payments.SwishPayments.Get(paymentLink, PaymentExpand.All);
                }
                catch (HttpResponseException) {}

                counter++;
            }

            // Operations
            Assert.That(swishPayment.Operations[LinkRelation.CreateCancellation], Is.Null);
            Assert.That(swishPayment.Operations[LinkRelation.CreateCapture], Is.Null);
            Assert.That(swishPayment.Operations[LinkRelation.CreateReversal], Is.Null);
            Assert.That(swishPayment.Operations[LinkRelation.ViewPayment], Is.Not.Null);

            // Transactions
            Assert.That(swishPayment.Payment.Transactions.TransactionList.Count, Is.EqualTo(2));
            Assert.That(swishPayment.Payment.Transactions.TransactionList.First(x => x.Type == TransactionType.Sale).State,
                        Is.EqualTo(State.Completed));
            Assert.That(swishPayment.Payment.Transactions.TransactionList.First(x => x.Type == TransactionType.Reversal).State,
                        Is.EqualTo(State.Completed));
        }
示例#10
0
        public async Task Payment_Card_Recur(Product[] products, PayexInfo payexInfo)
        {
            GoToOrdersPage(products, payexInfo, Checkout.Option.LocalPaymentMenu)
            .PaymentLink.StoreValueAsUri(out var paymentLink)
            .Actions.Rows[y => y.Name.Value.Contains(PaymentResourceOperations.CreateCancellation)].Should.BeVisible()
            .Actions.Rows[y => y.Name.Value.Contains(PaymentResourceOperations.CreateCapture)].Should.BeVisible()
            .Actions.Rows[y => y.Name.Value.Contains(PaymentResourceOperations.PaidPayment)].Should.BeVisible()
            .Actions.Rows[y => y.Name.Value.Contains(PaymentResourceOperations.ViewPayment)].Should.BeVisible()
            .Actions.Rows.Count.Should.Equal(4);

            var cardPayment = await SwedbankPayClient.Payments.CardPayments.Get(paymentLink, PaymentExpand.All);

            Assert.NotNull(cardPayment.Payment.RecurrenceToken);
            Assert.True(!string.IsNullOrEmpty(cardPayment.Payment.RecurrenceToken));
            Assert.NotNull(cardPayment.Payment.Urls);
            Assert.NotNull(cardPayment.Payment.Urls.CallbackUrl);

            IPayeeInfo payeeInfo = new PayeeInfo(cardPayment.Payment.PayeeInfo.PayeeId, GeneratePayeeReference());
            var        recur     = new SwedbankPay.Sdk.PaymentInstruments.Card.CardPaymentRecurRequest(Operation.Verify,
                                                                                                       PaymentIntent.Authorization,
                                                                                                       cardPayment.Payment.RecurrenceToken,
                                                                                                       cardPayment.Payment.Currency,
                                                                                                       cardPayment.Payment.Amount,
                                                                                                       cardPayment.Payment.VatAmount,
                                                                                                       cardPayment.Payment.Description,
                                                                                                       cardPayment.Payment.UserAgent,
                                                                                                       cardPayment.Payment.Language,
                                                                                                       cardPayment.Payment.Urls,
                                                                                                       payeeInfo);

            recur.Payment.Metadata = cardPayment.Payment.Metadata;

            var result = await SwedbankPayClient.Payments.CardPayments.Create(recur);

            Assert.NotNull(result);
            Assert.NotNull(result.Payment);
        }