예제 #1
0
        public void ProposedOrderWithPartialAuth_ShouldSucceed()
        {
            int giftCardAmount = 1000;

            ClientModuleIntegrationTestingUtilities.RemoveAnyGiftCardCreditOnConsumerWithNoLinkedPaymentUserAccount();
            ClientModuleIntegrationTestingUtilities.AddGiftCardCreditOnConsumerWithNoLinkedPaymentUserAccount(giftCardAmount);

            var credit = ClientModuleIntegrationTestingUtilities.GetAvailableDiscountCredit(LevelUpTestConfiguration.Current.ConsumerWithNoLinkedPaymentQrData);

            int spendAmount = (1000 + giftCardAmount + credit);


            IManageProposedOrders orderClient = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <IManageProposedOrders>();
            var proposedOrder = orderClient.CreateProposedOrder(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken,
                                                                LevelUpTestConfiguration.Current.MerchantLocationId,
                                                                LevelUpTestConfiguration.Current.ConsumerWithNoLinkedPaymentQrData,
                                                                spendAmount, spendAmount, 0, 0, null, null, null, null, true, false, null);

            Assert.AreEqual(proposedOrder.DiscountAmountCents, credit);

            var completedOrder = orderClient.CompleteProposedOrder(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken,
                                                                   LevelUpTestConfiguration.Current.MerchantLocationId,
                                                                   LevelUpTestConfiguration.Current.ConsumerWithNoLinkedPaymentQrData,
                                                                   proposedOrder.ProposedOrderIdentifier,
                                                                   spendAmount, spendAmount, 0, 0, proposedOrder.DiscountAmountCents, null, null, null, null, true, false, null);

            Assert.AreEqual(completedOrder.SpendAmount, credit + giftCardAmount);
            Assert.AreNotEqual(completedOrder.SpendAmount, spendAmount);

            ICreateRefund refundClient = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <ICreateRefund>();

            refundClient.RefundOrder(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken, completedOrder.OrderIdentifier);
        }
예제 #2
0
        public void ProposedOrderWithNoPartialAuth_ShouldThrow_ForInsufficientCredit()
        {
            int giftCardAmount = 1000;

            ClientModuleIntegrationTestingUtilities.RemoveAnyGiftCardCreditOnConsumerWithNoLinkedPaymentUserAccount();
            ClientModuleIntegrationTestingUtilities.AddGiftCardCreditOnConsumerWithNoLinkedPaymentUserAccount(giftCardAmount);

            var discountCredit = ClientModuleIntegrationTestingUtilities.GetAvailableDiscountCredit(LevelUpTestConfiguration.Current.ConsumerWithNoLinkedPaymentQrData);

            int spendAmount = (1000 + giftCardAmount + discountCredit);


            IManageProposedOrders orderClient = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <IManageProposedOrders>();

            Assert.Throws <LevelUpApiException>(() =>
            {
                var proposedOrder = orderClient.CreateProposedOrder(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken,
                                                                    LevelUpTestConfiguration.Current.MerchantLocationId,
                                                                    LevelUpTestConfiguration.Current.ConsumerWithNoLinkedPaymentQrData,
                                                                    spendAmount, spendAmount, 0, 0, null, null, null, null, false, false, null);

                var completedOrder = orderClient.CompleteProposedOrder(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken,
                                                                       LevelUpTestConfiguration.Current.MerchantLocationId,
                                                                       LevelUpTestConfiguration.Current.ConsumerWithNoLinkedPaymentQrData,
                                                                       proposedOrder.ProposedOrderIdentifier,
                                                                       spendAmount, spendAmount, 0, 0, proposedOrder.DiscountAmountCents, null, null, null, null, false, false, null);
            });
        }
        public void CreateRefundForUnFinalizedProposedOrder()
        {
            int availableDiscountCents = ClientModuleIntegrationTestingUtilities.GetAvailableDiscountCredit(LevelUpTestConfiguration.Current.ConsumerQrData);

            const int giftCardAmountToUseInCents = 1000;

            ClientModuleIntegrationTestingUtilities.RemoveAnyGiftCardCreditOnConsumerUserAccount();
            ClientModuleIntegrationTestingUtilities.AddGiftCardCreditOnConsumerUserAccount(giftCardAmountToUseInCents);

            const int taxAmountInCents  = 100;
            int       costOfItemInCents = availableDiscountCents + giftCardAmountToUseInCents + taxAmountInCents + 500;

            IManageProposedOrders orderClient = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <IManageProposedOrders>();

            var proposedOrder = orderClient.CreateProposedOrder(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken,
                                                                LevelUpTestConfiguration.Current.MerchantLocationId,
                                                                LevelUpTestConfiguration.Current.ConsumerQrData,
                                                                costOfItemInCents,
                                                                costOfItemInCents,
                                                                taxAmountInCents,
                                                                0, null, null, null, null, true, false, null);

            ICreateRefund refundClient = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <ICreateRefund>();

            Assert.Throws <LevelUpApiException>(() =>
            {
                refundClient.RefundOrder(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken,
                                         proposedOrder.ProposedOrderIdentifier);
            });
        }
예제 #4
0
        public void ProposedOrderWithDiscountAndGiftCard_ShouldSucceed()
        {
            int availableDiscountCents = ClientModuleIntegrationTestingUtilities.GetAvailableDiscountCredit(LevelUpTestConfiguration.Current.ConsumerQrData);

            const int giftCardAmountToUseInCents = 1000;

            ClientModuleIntegrationTestingUtilities.RemoveAnyGiftCardCreditOnConsumerUserAccount();
            ClientModuleIntegrationTestingUtilities.AddGiftCardCreditOnConsumerUserAccount(giftCardAmountToUseInCents);

            const int taxAmountInCents = 100;

            // Make sure that gift card, credit card, and discount(if available) will all be requried as part of this test payment.
            int costOfItemInCents = availableDiscountCents + giftCardAmountToUseInCents + taxAmountInCents + 500;

            IManageProposedOrders orderClient = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <IManageProposedOrders>();
            var proposedOrder = orderClient.CreateProposedOrder(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken,
                                                                LevelUpTestConfiguration.Current.MerchantLocationId,
                                                                LevelUpTestConfiguration.Current.ConsumerQrData,
                                                                costOfItemInCents,
                                                                costOfItemInCents,
                                                                taxAmountInCents,
                                                                0, null, null, null, null, true, false, null);

            Assert.AreEqual(proposedOrder.DiscountAmountCents, availableDiscountCents);
            int taxAmountAfterDiscountApplied = (taxAmountInCents * (costOfItemInCents - proposedOrder.DiscountAmountCents)) / costOfItemInCents;

            var completedOrder = orderClient.CompleteProposedOrder(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken,
                                                                   LevelUpTestConfiguration.Current.MerchantLocationId,
                                                                   LevelUpTestConfiguration.Current.ConsumerQrData,
                                                                   proposedOrder.ProposedOrderIdentifier,
                                                                   costOfItemInCents,
                                                                   costOfItemInCents,
                                                                   taxAmountAfterDiscountApplied,
                                                                   0,
                                                                   proposedOrder.DiscountAmountCents,
                                                                   null, null, null, null, true, false, null);

            Assert.AreEqual(completedOrder.GiftCardTipAmount, 0);
            Assert.AreEqual(completedOrder.GiftCardTotalAmount, giftCardAmountToUseInCents);
            Assert.AreEqual(completedOrder.GiftCardTipAmount, 0);
            Assert.AreEqual(completedOrder.TipAmount, 0);
            Assert.AreEqual(completedOrder.SpendAmount, costOfItemInCents);

            ICreateRefund refundClient = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <ICreateRefund>();

            refundClient.RefundOrder(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken,
                                     completedOrder.OrderIdentifier);
        }