public void TestRecur()
        {
            const string customerRefNo       = "Customer reference number or client order number";
            const string subscriptionId      = "The subscription id";
            const long   amount              = 66600L;
            var          hostedActionRequest = new HostedAdmin(SveaConfig.GetDefaultConfig(), CountryCode.SE)
                                               .Recur(new Recur(
                                                          customerRefNo: customerRefNo,
                                                          subscriptionId: subscriptionId,
                                                          currency: Currency.SEK,
                                                          amount: amount
                                                          ));

            HostedAdminRequest hostedAdminRequest = hostedActionRequest.PrepareRequest();

            Assert.That(hostedAdminRequest.MessageXmlDocument.SelectSingleNode("/recur/currency").InnerText, Is.EqualTo(Currency.SEK.ToString()));
            Assert.That(hostedAdminRequest.MessageXmlDocument.SelectSingleNode("/recur/amount").InnerText, Is.EqualTo(amount + ""));
            Assert.That(hostedAdminRequest.MessageXmlDocument.SelectSingleNode("/recur/customerrefno").InnerText, Is.EqualTo(customerRefNo));
            Assert.That(hostedAdminRequest.MessageXmlDocument.SelectSingleNode("/recur/subscriptionid").InnerText, Is.EqualTo(subscriptionId));

            var hostedAdminResponse = hostedActionRequest.DoRequest <HostedAdminResponse>();

            //Call to non-existing subscription
            Assert.That(hostedAdminResponse.MessageXmlDocument.SelectSingleNode("/response/statuscode").InnerText, Is.EqualTo("322"));
        }
Exemplo n.º 2
0
        public AnnulResponse DoRequest()
        {
            var hostedActionRequest = new HostedAdmin(_builder.GetConfig(), _builder.GetCountryCode())
                                      .Annul(new Annul(transactionId: _builder.Id));

            return(hostedActionRequest.DoRequest <AnnulResponse>());
        }
 public void TestSemiManualCancelRecurSubscription()
 {
     var hostedActionRequest = new HostedAdmin(SveaConfig.GetDefaultConfig(), CountryCode.SE)
                               .CancelRecurSubscription(new CancelRecurSubscription(
                                                            subscriptionId: "3352"
                                                            ))
                               .DoRequest <RecurResponse>();
 }
 public void TestSemiManualConfirm()
 {
     var hostedActionRequest = new HostedAdmin(SveaConfig.GetDefaultConfig(), CountryCode.SE)
                               .Confirm(new Confirm(
                                            transactionId: 598683,
                                            captureDate: DateTime.Now
                                            ))
                               .DoRequest <ConfirmResponse>();
 }
Exemplo n.º 5
0
        public QueryResponse DoRequest()
        {
            // should validate _builder.GetOrderId() existence here

            var hostedActionRequest = new HostedAdmin(_builder.GetConfig(), _builder.GetCountryCode())
                                      .Query(new QueryByTransactionId(
                                                 transactionId: _builder.Id));

            return(hostedActionRequest.DoRequest <QueryResponse>());
        }
Exemplo n.º 6
0
        public ConfirmResponse DoRequest()
        {
            // calculate original order rows total, incvat row sum over numberedOrderRows
            var originalOrderTotal = 0M;

            foreach (NumberedOrderRowBuilder originalRow in _builder.NumberedOrderRows)
            {
                originalOrderTotal += GetRowAmountIncVatFromBuilderOrderRow(
                    originalRow.GetVatPercent(), originalRow.GetAmountIncVat(), originalRow.GetAmountExVat(), originalRow.GetQuantity());
            }

            // calculate delivered order rows total, incvat row sum over deliveredOrderRows
            var deliveredOrderTotal = 0M;

            foreach (int rowIndex in _builder.RowIndexesToDeliver)
            {
                var deliveredRow = _builder.NumberedOrderRows[(rowIndex - 1)]; // -1 as NumberedOrderRows is one-indexed
                deliveredOrderTotal += GetRowAmountIncVatFromBuilderOrderRow(
                    deliveredRow.GetVatPercent(), deliveredRow.GetAmountIncVat(), deliveredRow.GetAmountExVat(), deliveredRow.GetQuantity());
            }

            var amountToLowerOrderBy = originalOrderTotal - deliveredOrderTotal;

            if (amountToLowerOrderBy > 0M)
            {
                // first loweramount, then confirm!
                var lowerAmountRequest = new HostedAdmin(_builder.GetConfig(), _builder.GetCountryCode())
                                         .LowerAmount(new LowerAmount(
                                                          transactionId: _builder.Id,
                                                          amountToLower: Decimal.ToInt64(amountToLowerOrderBy * 100) // centessimal
                                                          ));

                var lowerAmountResponse = lowerAmountRequest.DoRequest <LowerAmountResponse>();

                // if error lowering amount, return a dummy ConfirmRespose response w/status code 100 INTERNAL_ERROR
                if (!lowerAmountResponse.Accepted)
                {
                    var dummyInternalErrorResponseXml = new XmlDocument();
                    dummyInternalErrorResponseXml.LoadXml(@"<?xml version='1.0' encoding='UTF-8'?>
                        <response>
                            <statuscode>100</statuscode>
                        </response>");

                    return(Confirm.Response(dummyInternalErrorResponseXml));
                }
            }
            var hostedActionRequest = new HostedAdmin(_builder.GetConfig(), _builder.GetCountryCode())
                                      .Confirm(new Confirm(
                                                   transactionId: _builder.Id,
                                                   captureDate: _builder.CaptureDate ?? DateTime.Now // if no captureDate set, use today's date as default.
                                                   ));

            return(hostedActionRequest.DoRequest <ConfirmResponse>());
        }
        public void TestCancelRecurSubscription()
        {
            var hostedActionRequest = new HostedAdmin(SveaConfig.GetDefaultConfig(), CountryCode.SE)
                                      .CancelRecurSubscription(new CancelRecurSubscription(
                                                                   subscriptionId: "12341234"
                                                                   ));

            var hostedAdminRequest = hostedActionRequest.PrepareRequest();

            Assert.That(hostedAdminRequest.MessageXmlDocument.SelectSingleNode("/cancelrecursubscription/subscriptionid").InnerText, Is.EqualTo("12341234"));
        }
        public CreditResponse DoRequest()
        {
            // should validate _builder.GetOrderId() existence here

            var hostedActionRequest = new HostedAdmin(SveaConfig.GetDefaultConfig(), CountryCode.SE)
                                      .Credit(new Credit(
                                                  transactionId: _builder.Id,
                                                  amountToCredit: Decimal.ToInt64(_builder.AmountIncVat * 100) //centessimal
                                                  ));

            return(hostedActionRequest.DoRequest <CreditResponse>());
        }
        public HostedActionRequest DeliverCardOrder()
        {
            // no validation for this release, we fall back on the service error messages

            var action = new Confirm(
                this.GetOrderId(),
                this._captureDate ?? DateTime.Now // if no captureDate given, use today
                );

            var request = new HostedAdmin(this._config, this._countryCode);

            return(request.Confirm(action));
        }
Exemplo n.º 10
0
        public void TestConfirm()
        {
            var hostedActionRequest = new HostedAdmin(SveaConfig.GetDefaultConfig(), CountryCode.SE)
                                      .Confirm(new Confirm(
                                                   transactionId: 12341234,
                                                   captureDate: new DateTime(2015, 05, 22)
                                                   ));

            var hostedAdminRequest = hostedActionRequest.PrepareRequest();

            Assert.That(hostedAdminRequest.MessageXmlDocument.SelectSingleNode("/confirm/transactionid").InnerText, Is.EqualTo("12341234"));
            Assert.That(hostedAdminRequest.MessageXmlDocument.SelectSingleNode("/confirm/capturedate").InnerText, Is.EqualTo("2015-05-22"));
        }
Exemplo n.º 11
0
        public void TestAnnul()
        {
            var payment = MakePreparedPayment(PrepareRegularPayment(PaymentMethod.KORTCERT, CreateCustomerRefNo()));

            var hostedActionRequest = new HostedAdmin(SveaConfig.GetDefaultConfig(), CountryCode.SE)
                                      .Annul(new Annul(
                                                 transactionId: payment.TransactionId
                                                 ));
            AnnulResponse response = hostedActionRequest.DoRequest <AnnulResponse>();

            Assert.IsTrue(response.Accepted);
            Assert.That(response.StatusCode, Is.EqualTo(0));
            Assert.That(response.TransactionId, Is.EqualTo(payment.TransactionId));
        }
Exemplo n.º 12
0
        public void TestLowerAmountCompleteFlow()
        {
            var customerRefNo = CreateCustomerRefNo();
            var payment       = MakePreparedPayment(PrepareRegularPayment(PaymentMethod.KORTCERT, customerRefNo));

            LowerAmountResponse lowerAmountResponse = new HostedAdmin(SveaConfig.GetDefaultConfig(), CountryCode.SE)
                                                      .LowerAmount(new LowerAmount(
                                                                       transactionId: payment.TransactionId,
                                                                       amountToLower: 666
                                                                       ))
                                                      .PrepareRequest()
                                                      .DoRequest()
                                                      .To(LowerAmount.Response);
        }
Exemplo n.º 13
0
        public void TestQueryCustomerRefNoDirectPayment()
        {
            var customerRefNo = CreateCustomerRefNo();
            var payment       = MakePreparedPayment(PrepareRegularPayment(PaymentMethod.NORDEASE, customerRefNo));
            var now           = DateTime.Now;

            var hostedActionRequest = new HostedAdmin(SveaConfig.GetDefaultConfig(), CountryCode.SE)
                                      .Query(new QueryByCustomerRefNo(
                                                 customerRefNo: customerRefNo
                                                 ));

            HostedAdminRequest hostedAdminRequest = hostedActionRequest.PrepareRequest();

            Assert.That(hostedAdminRequest.MessageXmlDocument.SelectSingleNode("/query/customerrefno").InnerText, Is.EqualTo(customerRefNo));

            var hostedAdminResponse = hostedActionRequest.DoRequest <HostedAdminResponse>();

            Assert.That(hostedAdminResponse.MessageXmlDocument.SelectSingleNode("/response/statuscode").InnerText, Is.EqualTo("0"));
            Assert.That(hostedAdminResponse.MessageXmlDocument.SelectSingleNode("/response/transaction/customerrefno").InnerText, Is.EqualTo(customerRefNo));
        }
Exemplo n.º 14
0
        public void TestGetReconciliationReport()
        {
            var hostedActionRequest = new HostedAdmin(SveaConfig.GetDefaultConfig(), CountryCode.SE)
                                      .GetReconciliationReport(new GetReconciliationReport(
                                                                   date: new DateTime(2015, 04, 17)
                                                                   ));

            var hostedAdminRequest = hostedActionRequest.PrepareRequest();

            Assert.That(hostedAdminRequest.MessageXmlDocument.SelectSingleNode("/getreconciliationreport/date").InnerText, Is.EqualTo("2015-04-17"));

            var hostedAdminResponse = hostedActionRequest.DoRequest <HostedAdminResponse>();

            Assert.That(hostedAdminResponse.MessageXmlDocument.SelectSingleNode("/response/statuscode").InnerText, Is.EqualTo("0"));

            Assert.That(hostedAdminResponse.MessageXmlDocument.SelectSingleNode("/response/reconciliation").InnerXml,
                        Is.StringStarting("<reconciliationtransaction><transactionid>598268</transactionid><customerrefno>ti-3-183-Nakkilankatu-A3</customerrefno><paymentmethod>KORTCERT</paymentmethod><amount>28420</amount><currency>SEK</currency><time>2015-04-17 00:15:22 CEST</time></reconciliationtransaction>"));

            Assert.That(hostedAdminResponse.To(GetReconciliationReport.Response).ReconciliationTransactions[0].Amount, Is.EqualTo(284.20M));
        }
Exemplo n.º 15
0
        public void TestQueryTransactionIdDirectPayment()
        {
            var customerRefNo = CreateCustomerRefNo();
            var payment       = MakePreparedPayment(PrepareRegularPayment(PaymentMethod.NORDEASE, customerRefNo));
            var now           = DateTime.Now;

            var hostedActionRequest = new HostedAdmin(SveaConfig.GetDefaultConfig(), CountryCode.SE)
                                      .Query(new QueryByTransactionId(
                                                 transactionId: payment.TransactionId
                                                 ));

            HostedAdminRequest hostedAdminRequest = hostedActionRequest.PrepareRequest();

            Assert.That(hostedAdminRequest.MessageXmlDocument.SelectSingleNode("/query/transactionid").InnerText, Is.EqualTo(payment.TransactionId + ""));

            var hostedAdminResponse = hostedActionRequest.DoRequest <HostedAdminResponse>();

            Assert.That(hostedAdminResponse.MessageXmlDocument.SelectSingleNode("/response/statuscode").InnerText, Is.EqualTo("0"));
            Assert.That(hostedAdminResponse.MessageXmlDocument.SelectSingleNode("/response/transaction/customerrefno").InnerText, Is.EqualTo(customerRefNo));
            Assert.That(hostedAdminResponse.MessageXmlDocument.SelectSingleNode("/response/transaction/merchantid").InnerText, Is.EqualTo("1130"));
            Assert.That(hostedAdminResponse.MessageXmlDocument.SelectSingleNode("/response/transaction/status").InnerText, Is.EqualTo("SUCCESS"));
            Assert.That(hostedAdminResponse.MessageXmlDocument.SelectSingleNode("/response/transaction/amount").InnerText, Is.EqualTo("25000"));
            Assert.That(hostedAdminResponse.MessageXmlDocument.SelectSingleNode("/response/transaction/currency").InnerText, Is.EqualTo("SEK"));
            Assert.That(hostedAdminResponse.MessageXmlDocument.SelectSingleNode("/response/transaction/vat").InnerText, Is.EqualTo("5000"));
            Assert.That(hostedAdminResponse.MessageXmlDocument.SelectSingleNode("/response/transaction/capturedamount").InnerText, Is.EqualTo("25000"));
            Assert.That(hostedAdminResponse.MessageXmlDocument.SelectSingleNode("/response/transaction/authorizedamount").InnerText, Is.EqualTo("25000"));

            var created = DateTime.Parse(hostedAdminResponse.MessageXmlDocument.SelectSingleNode("/response/transaction/created").InnerText);

            Assert.That(created.Year, Is.EqualTo(now.Year));
            Assert.That(created.Month, Is.EqualTo(now.Month));
            Assert.That(created.Day, Is.EqualTo(now.Day));

            Assert.That(hostedAdminResponse.MessageXmlDocument.SelectSingleNode("/response/transaction/creditstatus").InnerText, Is.EqualTo("CREDNONE"));
            Assert.That(hostedAdminResponse.MessageXmlDocument.SelectSingleNode("/response/transaction/creditedamount").InnerText, Is.EqualTo("0"));
            Assert.That(hostedAdminResponse.MessageXmlDocument.SelectSingleNode("/response/transaction/merchantresponsecode").InnerText, Is.EqualTo("0"));
            Assert.That(hostedAdminResponse.MessageXmlDocument.SelectSingleNode("/response/transaction/paymentmethod").InnerText, Is.EqualTo("DBNORDEASE"));

            Assert.That(hostedAdminResponse.MessageXmlDocument.SelectSingleNode("/response/transaction/customer/firstname").InnerXml, Is.EqualTo("TestCompagniet"));
            Assert.That(hostedAdminResponse.MessageXmlDocument.SelectSingleNode("/response/transaction/customer/ssn").InnerXml, Is.EqualTo("2345234"));
        }
        public LowerAmountResponse DoRequest()
        {
            // calculate sum of cancelled order rows, applying RowsToCancel to passed in NumberedOrderRows
            var amountToLowerOrderBy = 0M;

            foreach (int rowIndex in _builder.RowIndexesToCancel)
            {
                var deliveredRow = _builder.NumberedOrderRows[(rowIndex - 1)]; // -1 as NumberedOrderRows is one-indexed
                amountToLowerOrderBy += GetRowAmountIncVatFromBuilderOrderRow(
                    deliveredRow.GetVatPercent(), deliveredRow.GetAmountIncVat(), deliveredRow.GetAmountExVat(), deliveredRow.GetQuantity());
            }

            // lower order by calculated amount
            var hostedActionRequest = new HostedAdmin(SveaConfig.GetDefaultConfig(), CountryCode.SE)
                                      .LowerAmount(new LowerAmount(
                                                       transactionId: _builder.Id,
                                                       amountToLower: Decimal.ToInt64(amountToLowerOrderBy * 100) // centessimal
                                                       ));

            return(hostedActionRequest.DoRequest <LowerAmountResponse>());
        }
Exemplo n.º 17
0
        public void TestGetPaymentMethods()
        {
            var hostedActionRequest = new HostedAdmin(SveaConfig.GetDefaultConfig(), CountryCode.SE)
                                      .GetPaymentMethods(new GetPaymentMethods(
                                                             merchantId: 1130
                                                             ));

            var hostedAdminRequest = hostedActionRequest.PrepareRequest();

            Assert.That(hostedAdminRequest.MessageXmlDocument.SelectSingleNode("/getpaymentmethods/merchantid").InnerText, Is.EqualTo("1130"));

            var hostedAdminResponse = hostedActionRequest.DoRequest <HostedAdminResponse>();

            Assert.That(hostedAdminResponse.MessageXmlDocument.SelectSingleNode("/response/statuscode").InnerText, Is.EqualTo("0"));

            var actualPaymentmethodsXml   = hostedAdminResponse.MessageXmlDocument.SelectSingleNode("/response/paymentmethods").InnerXml;
            var expectedPaymentmethodsXml =
                "<paymentmethod>BANKAXESS</paymentmethod><paymentmethod>DBNORDEASE</paymentmethod><paymentmethod>DBSEBSE</paymentmethod><paymentmethod>KORTCERT</paymentmethod><paymentmethod>SVEACARDPAY</paymentmethod><paymentmethod>SVEAINVOICEEU_SE</paymentmethod><paymentmethod>SVEASPLITEU_SE</paymentmethod>";

            Assert.That(actualPaymentmethodsXml, Is.EqualTo(expectedPaymentmethodsXml));
        }
Exemplo n.º 18
0
        public void TestLowerAmount()
        {
            var customerRefNo = CreateCustomerRefNo();
            var payment       = MakePreparedPayment(PrepareRegularPayment(PaymentMethod.KORTCERT, customerRefNo));

            var hostedActionRequest = new HostedAdmin(SveaConfig.GetDefaultConfig(), CountryCode.SE)
                                      .LowerAmount(new LowerAmount(
                                                       transactionId: payment.TransactionId,
                                                       amountToLower: 666
                                                       ));

            HostedAdminRequest hostedAdminRequest = hostedActionRequest.PrepareRequest();

            Assert.That(hostedAdminRequest.MessageXmlDocument.SelectSingleNode("/loweramount/transactionid").InnerText, Is.EqualTo(payment.TransactionId + ""));
            Assert.That(hostedAdminRequest.MessageXmlDocument.SelectSingleNode("/loweramount/amounttolower").InnerText, Is.EqualTo("666"));

            var hostedAdminResponse = hostedActionRequest.DoRequest <HostedAdminResponse>();

            Assert.That(hostedAdminResponse.MessageXmlDocument.SelectSingleNode("/response/statuscode").InnerText, Is.EqualTo("0"));
            Assert.That(hostedAdminResponse.MessageXmlDocument.SelectSingleNode("/response/transaction/customerrefno").InnerText, Is.EqualTo(customerRefNo));
        }