コード例 #1
0
        public async Task <ActionResult> AddOrderRow(long paymentId)
        {
            try
            {
                var paymentOrder = await this._sveaClient.PaymentAdmin.GetOrder(paymentId);

                TempData["ErrorMessage"] = ActionsValidationHelper.ValidateOrderAction(paymentOrder, OrderActionType.CanAddOrderRow);

                if (TempData["ErrorMessage"] == null)
                {
                    var response = await paymentOrder.Actions.AddOrderRow(
                        new AddOrderRowRequest(
                            articleNumber : "1234567890",
                            name : "Slim Fit 512",
                            quantity : MinorUnit.FromInt(2),
                            unitPrice : MinorUnit.FromInt(100),
                            discountPercent : MinorUnit.FromInt(0),
                            vatPercent : MinorUnit.FromInt(12),
                            unit : "SEK",
                            TimeSpan.FromSeconds(15)
                            )
                        );

                    TempData["OrderRowMessage"] = $"Order row has been added -> {response. ResourceUri.AbsoluteUri}";
                }
            }
            catch (Exception e)
            {
                TempData["ErrorMessage"] = $"Something unexpected happened. {e.Message}";
            }

            return(RedirectToAction("Details", "Orders"));
        }
コード例 #2
0
        public async Task <ActionResult> CreditNewRow(long paymentId, int deliveryId)
        {
            try
            {
                var paymentOrder = await this._sveaClient.PaymentAdmin.GetOrder(paymentId);

                TempData["ErrorMessage"] = ActionsValidationHelper.ValidateDeliveryAction(paymentOrder, deliveryId, DeliveryActionType.CanCreditNewRow);

                if (TempData["ErrorMessage"] == null)
                {
                    var delivery = paymentOrder.Deliveries.FirstOrDefault(dlv => dlv.Id == deliveryId);

                    var response = await delivery.Actions.CreditNewRow(
                        new CreditNewOrderRowRequest(
                            new CreditOrderRow(
                                name: "Slim Fit 512",
                                MinorUnit.FromDecimal(100),
                                MinorUnit.FromDecimal(12)
                                ),
                            pollingTimeout : TimeSpan.FromSeconds(15)
                            )
                        );

                    TempData["CreditMessage"] = $"New credit row created. -> {response.ResourceUri.AbsoluteUri}";
                }
            }
            catch (Exception e)
            {
                TempData["ErrorMessage"] = $"Something unexpected happened. {e.Message}";
            }

            return(RedirectToAction("Details", "Orders"));
        }
コード例 #3
0
        public async System.Threading.Tasks.Task AddOrderRow_Should_Serialize_AsExpected()
        {
            // Arrange
            var orderResponseObject    = JsonConvert.DeserializeObject <OrderResponseObject>(DataSample.AdminGetOrder, JsonSerialization.Settings);
            var expectedTask           = JsonConvert.DeserializeObject <Task>(DataSample.TaskResponse, JsonSerialization.Settings);
            var orderRowResponseObject = JsonConvert.DeserializeObject <AddOrderRowResponseObject>(DataSample.AddOrderRowResponse);
            var expectedOrderRow       = new AddOrderRowResponse(orderRowResponseObject);

            var sveaClient = SveaClient(CreateHandlerMockWithAction(DataSample.AdminGetOrder, "", expectedTask.ResourceUri.OriginalString, DataSample.TaskResponse, DataSample.AddOrderRowResponse));

            // Act
            var order = await sveaClient.PaymentAdmin.GetOrder(2291662);

            var resourceResponse = await order.Actions.AddOrderRow(
                new AddOrderRowRequest(
                    articleNumber : "1234567890",
                    name : "Slim Fit 512",
                    quantity : MinorUnit.FromInt(2),
                    unitPrice : MinorUnit.FromInt(1000),
                    discountPercent : MinorUnit.FromInt(0),
                    vatPercent : MinorUnit.FromInt(12),
                    unit : "SEK",
                    TimeSpan.FromSeconds(15)
                    )
                );

            // Assert
            Assert.Equal(expectedOrderRow.OrderRowId, resourceResponse.Resource.OrderRowId);
        }
コード例 #4
0
        public async System.Threading.Tasks.Task CreditNewRow_Should_Serialize_AsExpected()
        {
            // Arrange
            var creditResponseObject   = JsonConvert.DeserializeObject <CreditResponseObject>(DataSample.CreditResponse, JsonSerialization.Settings);
            var expectedTask           = JsonConvert.DeserializeObject <Task>(DataSample.TaskResponse, JsonSerialization.Settings);
            var expectedCreditResponse = new CreditResponse(creditResponseObject);
            var sveaClient             = SveaClient(CreateHandlerMockWithAction(DataSample.AdminDeliveredOrder, "", expectedTask.ResourceUri.OriginalString, DataSample.TaskResponse, DataSample.CreditResponse));

            // Act
            var order = await sveaClient.PaymentAdmin.GetOrder(2291662);

            var delivery         = order.Deliveries.FirstOrDefault(dlv => dlv.Id == 5588817);
            var orderRowIds      = delivery.OrderRows.Where(row => row.AvailableActions.Contains(OrderRowActionType.CanCreditRow)).Select(row => (long)row.OrderRowId).ToList();
            var resourceResponse = await delivery.Actions.CreditNewRow(new CreditNewOrderRowRequest(
                                                                           new CreditOrderRow(
                                                                               name: "Slim Fit 512",
                                                                               MinorUnit.FromDecimal(100),
                                                                               MinorUnit.FromDecimal(12)
                                                                               )
                                                                           ));

            // Assert
            Assert.Equal(expectedTask.ResourceUri.OriginalString, resourceResponse.TaskUri.OriginalString);
            Assert.True(DataComparison.CreditResponsesAreEqual(expectedCreditResponse, resourceResponse.Resource));
        }
コード例 #5
0
 internal OrderResponseObject(IList <string> actions, Address billingAddress, MinorUnit cancelledAmount, DateTime creationDate,
                              string currency, string customerReference, IList <DeliveryResponseObject> deliveries, EmailAddress emailAddress, long id,
                              bool isCompany, string merchantOrderId, string nationalId, MinorUnit orderAmount, IList <OrderRowResponseObject> orderRows,
                              OrderStatus orderStatus, PaymentType paymentType, string phoneNumber, Address shippingAddress, bool?sveaWillBuy)
 {
     Actions           = actions;
     BillingAddress    = billingAddress;
     CancelledAmount   = cancelledAmount;
     CreationDate      = creationDate;
     Currency          = currency;
     CustomerReference = customerReference;
     Deliveries        = deliveries;
     EmailAddress      = emailAddress;
     Id              = id;
     IsCompany       = isCompany;
     MerchantOrderId = merchantOrderId;
     NationalId      = nationalId;
     OrderAmount     = orderAmount;
     OrderRows       = orderRows;
     OrderStatus     = orderStatus;
     PaymentType     = paymentType;
     PhoneNumber     = phoneNumber;
     ShippingAddress = shippingAddress;
     SveaWillBuy     = sveaWillBuy;
 }
コード例 #6
0
        public CheckoutOrderBuilder UseTestValues()
        {
            var pushUri         = new Uri("https://svea.com/push.aspx?sid=123&svea_order=123");
            var termsUri        = new Uri("http://localhost:51898/terms");
            var checkoutUri     = new Uri("http://localhost:8080/php-checkout/examples/create-order.php");
            var confirmationUri = new Uri("http://localhost/php-checkout/examples/get-order.php");

            var orderRows = new List <OrderRow>
            {
                new OrderRow(
                    "ABC80",
                    "Computer",
                    MinorUnit.FromInt(10),
                    MinorUnit.FromDecimal(5000),
                    MinorUnit.FromDecimal(10),
                    MinorUnit.FromDecimal(25),
                    null,
                    null,
                    1)
            };

            this.cart              = new Cart(orderRows);
            this.merchantSettings  = new MerchantSettings(pushUri, termsUri, checkoutUri, confirmationUri);
            this.countryCode       = new RegionInfo("SE");
            this.currency          = new CurrencyCode("SEK");
            this.locale            = new Language("sv-SE");
            this.clientOrderNumber = DateTime.Now.Ticks.ToString();

            return(this);
        }
コード例 #7
0
 internal OrderRowResponseObject(string articleNumber, string name, MinorUnit quantity, MinorUnit unitPrice, MinorUnit discountPercent,
                                 MinorUnit vatPercent, string unit, bool isCancelled, int orderRowId, IList <string> actions)
 {
     ArticleNumber   = articleNumber;
     Name            = name;
     Quantity        = quantity;
     UnitPrice       = unitPrice;
     DiscountPercent = discountPercent;
     VatPercent      = vatPercent;
     Unit            = unit;
     IsCancelled     = isCancelled;
     OrderRowId      = orderRowId;
     Actions         = actions;
 }
コード例 #8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="articleNumber">
        /// <summary>
        /// Articlenumber as a string, can contain letters and numbers.
        /// </summary>
        /// <remarks>Max length: 256. Min length: 0.</remarks>
        /// </param>
        /// <param name="name">
        /// <summary>
        /// Article name.
        /// </summary>
        /// <remarks>Max length: 40. Min length: 0.</remarks>
        /// </param>
        /// <param name="quantity">
        /// <summary>
        /// Quantity of the product. 1-9 digits.
        /// </summary>
        /// <remarks>Required</remarks>
        /// </param>
        /// <param name="unitPrice">
        /// <summary>
        /// Price of the product including VAT. 1-13 digits, can be negative.
        /// </summary>
        /// <remarks>Required</remarks>
        /// </param>
        /// <param name="discountPercent">
        /// <summary>
        /// The discount percent of the product. Examples: 0-10000. No fractions.0 = 0%100 = 1%1000 = 10%9900 = 99%10000 = 100%
        /// </summary>
        /// </param>
        /// <param name="vatPercent">
        /// <summary>
        /// The VAT percentage of the current product. Valid vat percentage for that country.
        /// </summary>
        /// <remarks>SE 6, 12, 25</remarks>
        ///  </param>
        /// <param name="unit">
        /// <summary>
        /// The unit type, e.g., “st”, “pc”, “kg” etc.
        /// </summary>
        /// <remarks>Max length: 4. Min length: 0.</remarks>
        /// </param>
        /// <param name="temporaryReference">
        /// <summary>
        /// Can be used when creating or updating an order. The returned rows will have their corresponding temporaryreference as they were given in the indata.
        /// It will not be stored and will not be returned in GetOrder.
        /// </summary>
        /// </param>
        /// <param name="rowNumber">
        /// <summary>
        /// The row number the row will have in the Webpay system
        /// </summary>
        /// </param>
        /// <param name="merchantData">
        /// <summary>
        /// Metadata visible to the store
        /// </summary>
        /// <remarks>Max length: 255. Optional. Cleaned up from Checkout database after 45 days.</remarks>
        /// </param>
        public OrderRow(string articleNumber, string name, MinorUnit quantity, MinorUnit unitPrice, MinorUnit discountPercent,
                        MinorUnit vatPercent, string unit, string temporaryReference, int rowNumber, string merchantData = null)
        {
            ArticleNumber      = articleNumber;
            DiscountPercent    = discountPercent;
            Unit               = unit;
            TemporaryReference = temporaryReference;
            RowNumber          = rowNumber;
            MerchantData       = merchantData;

            Name       = name ?? throw new ArgumentNullException(nameof(name));
            Quantity   = quantity ?? throw new ArgumentNullException(nameof(quantity));
            UnitPrice  = unitPrice ?? throw new ArgumentNullException(nameof(unitPrice));
            VatPercent = vatPercent ?? throw new ArgumentNullException(nameof(vatPercent));

            if (ArticleNumber?.Length > 256)
            {
                throw new ArgumentOutOfRangeException(nameof(articleNumber), "Maximum 256 characters.");
            }

            if (DiscountPercent.Value.ToString().Length > 10000)
            {
                throw new ArgumentOutOfRangeException(nameof(discountPercent), "Value cannot be more than 100.");
            }

            if (Quantity.Value.ToString().Length > 9)
            {
                throw new ArgumentOutOfRangeException(nameof(quantity), "Value cannot be longer than 7 digits.");
            }

            if (UnitPrice.Value.ToString().Length > 13)
            {
                throw new ArgumentOutOfRangeException(nameof(unitPrice), "Value cannot be longer than 11 digits.");
            }

            if (Name.Length < 1 || Name.Length > 40)
            {
                throw new ArgumentOutOfRangeException(nameof(name), "Can only be 1-40 characters.");
            }

            if (Unit?.Length > 4)
            {
                throw new ArgumentOutOfRangeException(nameof(unit), "Can only be 0-4 characters.");
            }

            if (MerchantData?.Length > 255)
            {
                throw new ArgumentOutOfRangeException(nameof(merchantData), "Can only be 0-255 characters.");
            }
        }
コード例 #9
0
        public void CanSerialize_Amount()
        {
            //ARRANGE
            var orderRow = new OrderRow("1", "Test", MinorUnit.FromDecimal(1), MinorUnit.FromDecimal(1), MinorUnit.FromDecimal(0), MinorUnit.FromDecimal(25),
                                        "#", "", 1);

            //ACT
            var result = JsonConvert.SerializeObject(orderRow, JsonSerialization.Settings);
            var obj    = JObject.Parse(result);

            obj.TryGetValue("UnitPrice", StringComparison.InvariantCultureIgnoreCase, out var amount);

            //ASSERT
            Assert.Equal(this.expectedAmount, amount);
        }
コード例 #10
0
        /// <summary>
        /// CreditOrderRow
        /// </summary>
        /// <param name="name">Credit row name. Credit row name.</param>
        /// <param name="unitPrice">Credit amount including VAT.</param>
        /// <param name="vatPercent">The VAT percentage of the credit amount. Valid vat percentage for that country.</param>
        public CreditOrderRow(string name, MinorUnit unitPrice, MinorUnit vatPercent)
        {
            Name       = name ?? throw new ArgumentNullException(nameof(name));
            UnitPrice  = unitPrice ?? throw new ArgumentNullException(nameof(unitPrice));
            VatPercent = vatPercent ?? throw new ArgumentNullException(nameof(vatPercent));

            if (Name.Length < 1 || Name.Length > 40)
            {
                throw new ArgumentOutOfRangeException(nameof(name), "Can only be 1-40 characters.");
            }

            if (UnitPrice.Value.ToString().Length > 13)
            {
                throw new ArgumentOutOfRangeException(nameof(unitPrice), "Value cannot be longer than 11 digits.");
            }
        }
コード例 #11
0
        public async Task <ActionResult> ReplaceOrderRows(long paymentId)
        {
            try
            {
                var paymentOrder = await this._sveaClient.PaymentAdmin.GetOrder(paymentId);

                TempData["ErrorMessage"] = ActionsValidationHelper.ValidateOrderAction(paymentOrder, OrderActionType.CanAddOrderRow);

                if (TempData["ErrorMessage"] == null)
                {
                    var newOrderRows = new List <NewOrderRow>
                    {
                        new NewOrderRow(
                            name: "Slim Fit 512",
                            quantity: MinorUnit.FromInt(2),
                            unitPrice: MinorUnit.FromInt(100),
                            vatPercent: MinorUnit.FromInt(12),
                            discountPercent: MinorUnit.FromInt(0),
                            rowId: null,
                            unit: "SEK",
                            articleNumber: "1234567890"
                            ),
                        new NewOrderRow(
                            name: "Slim Fit 513",
                            quantity: MinorUnit.FromInt(3),
                            unitPrice: MinorUnit.FromInt(200),
                            vatPercent: MinorUnit.FromInt(25),
                            discountPercent: MinorUnit.FromInt(0),
                            rowId: null,
                            unit: "SEK",
                            articleNumber: "0987654321"
                            )
                    };

                    await paymentOrder.Actions.ReplaceOrderRows(new ReplaceOrderRowsRequest(newOrderRows));

                    TempData["OrderRowMessage"] = "Order rows have been updated";
                }
            }
            catch (Exception e)
            {
                TempData["ErrorMessage"] = $"Something unexpected happened. {e.Message}";
            }

            return(RedirectToAction("Details", "Orders"));
        }
コード例 #12
0
        public static IEnumerable <OrderRow> ToOrderItems(this IEnumerable <CartLine> lines)
        {
            var rowNumber = 1;

            foreach (var line in lines)
            {
                yield return(new OrderRow(
                                 line.Product.Reference,
                                 line.Product.Name,
                                 MinorUnit.FromDecimal(line.Quantity),
                                 MinorUnit.FromDecimal(line.Product.Price),
                                 MinorUnit.FromDecimal(0),
                                 MinorUnit.FromDecimal(line.Product.VatPercentage),
                                 null,
                                 null,
                                 rowNumber++));
            }
        }
コード例 #13
0
        public async System.Threading.Tasks.Task AddOrderRows_Should_Serialize_AsExpected()
        {
            // Arrange
            var orderResponseObject = JsonConvert.DeserializeObject <OrderResponseObject>(DataSample.AdminGetOrder, JsonSerialization.Settings);
            var expectedTask        = JsonConvert.DeserializeObject <Task>(DataSample.TaskResponse, JsonSerialization.Settings);
            var expectedResponse    = JsonConvert.DeserializeObject <AddOrderRowsResponse>(DataSample.AddOrderRowsResponse);

            var sveaClient = SveaClient(CreateHandlerMockWithAction(DataSample.AdminGetOrder, DataSample.AddOrderRowsResponse));

            // Act
            var order = await sveaClient.PaymentAdmin.GetOrder(2291662);

            var resourceResponse = await order.Actions.AddOrderRows(
                new AddOrderRowsRequest(
                    new List <NewOrderRow> {
                new NewOrderRow(
                    name: "Slim Fit 512",
                    quantity: MinorUnit.FromInt(2),
                    unitPrice: MinorUnit.FromInt(1000),
                    vatPercent: MinorUnit.FromInt(12),
                    discountPercent: MinorUnit.FromInt(0),
                    rowId: 3,
                    unit: "SEK",
                    articleNumber: "1234567890"
                    ),
                new NewOrderRow(
                    name: "Slim Fit 513",
                    quantity: MinorUnit.FromInt(3),
                    unitPrice: MinorUnit.FromInt(2000),
                    vatPercent: MinorUnit.FromInt(5),
                    discountPercent: MinorUnit.FromInt(0),
                    rowId: 4,
                    unit: "SEK",
                    articleNumber: "0987654321"
                    )
            }

                    )
                );

            // Assert
            // List of OrderRowId
            Assert.Equal(expectedResponse.OrderRowId, resourceResponse.OrderRowId);
        }
コード例 #14
0
        /// <summary>
        /// OrderRowRequest
        /// </summary>
        /// <param name="articleNumber">Article number as a string. Can contain letters and numbers. Maximum 256 characters.</param>
        /// <param name="name">Article name. 1-40 characters.</param>
        /// <param name="quantity">Quantity of the product.</param>
        /// <param name="unitPrice">Price of the product including VAT.</param>
        /// <param name="discountPercent">The discount percentage of the product.</param>
        /// <param name="vatPercent">The VAT percentage of the credit amount. Valid vat percentage for that country.</param>
        /// <param name="unit">The unit type, e.g., “st”, “pc”, “kg” etc. 0-4 characters.</param>
        /// <param name="pollingTimeout">If set the task will be polled until the resource is complete or the timeout has passed. If null the resource will be returned if complete, otherwise the task is returned. </param>
        public AddOrderRowRequest(string articleNumber, string name, MinorUnit quantity, MinorUnit unitPrice, MinorUnit discountPercent, MinorUnit vatPercent, string unit, TimeSpan?pollingTimeout = null)
        {
            ArticleNumber   = articleNumber;
            DiscountPercent = discountPercent;
            Unit            = unit;
            PollingTimeout  = pollingTimeout;

            Name       = name ?? throw new ArgumentNullException(nameof(name));
            Quantity   = quantity ?? throw new ArgumentNullException(nameof(quantity));
            UnitPrice  = unitPrice ?? throw new ArgumentNullException(nameof(unitPrice));
            VatPercent = vatPercent ?? throw new ArgumentNullException(nameof(vatPercent));

            if (ArticleNumber?.Length > 256)
            {
                throw new ArgumentOutOfRangeException(nameof(articleNumber), "Maximum 256 characters.");
            }

            if (DiscountPercent.Value.ToString().Length > 10000)
            {
                throw new ArgumentOutOfRangeException(nameof(discountPercent), "Value cannot be more than 100.");
            }

            if (Quantity.Value.ToString().Length > 9)
            {
                throw new ArgumentOutOfRangeException(nameof(quantity), "Value cannot be longer than 7 digits.");
            }

            if (UnitPrice.Value.ToString().Length > 13)
            {
                throw new ArgumentOutOfRangeException(nameof(unitPrice), "Value cannot be longer than 11 digits.");
            }

            if (Name.Length < 1 || Name.Length > 40)
            {
                throw new ArgumentOutOfRangeException(nameof(name), "Can only be 1-40 characters.");
            }

            if (Unit?.Length > 4)
            {
                throw new ArgumentOutOfRangeException(nameof(unit), "Can only be 0-4 characters.");
            }
        }
コード例 #15
0
        private static UpdateOrderModel CreateUpdateOrderRequest(string merchantData)
        {
            var orderRows = new List <OrderRow>
            {
                new OrderRow(
                    "ABC80",
                    "Computer",
                    MinorUnit.FromInt(4),
                    MinorUnit.FromDecimal(2000),
                    MinorUnit.FromDecimal(0),
                    MinorUnit.FromDecimal(6),
                    null,
                    null,
                    2)
            };

            var cart        = new Cart(orderRows);
            var updateModel = new UpdateOrderModel(cart, merchantData);

            return(updateModel);
        }
コード例 #16
0
        public async Task <ActionResult> UpdateOrderRows(long paymentId)
        {
            try
            {
                var paymentOrder = await this._sveaClient.PaymentAdmin.GetOrder(paymentId);

                TempData["ErrorMessage"] = ActionsValidationHelper.ValidateOrderAction(paymentOrder, OrderActionType.CanAddOrderRow);

                if (TempData["ErrorMessage"] == null)
                {
                    var existingOrderRows = paymentOrder.OrderRows;

                    var newOrderRows = new List <NewOrderRow>();

                    foreach (var orderRow in existingOrderRows)
                    {
                        newOrderRows.Add(new NewOrderRow(
                                             orderRow.Name,
                                             MinorUnit.FromInt((orderRow.Quantity.Value + 1) % 4 + 1),
                                             orderRow.UnitPrice,
                                             orderRow.VatPercent,
                                             orderRow.DiscountPercent,
                                             orderRow.OrderRowId,
                                             orderRow.Unit,
                                             orderRow.ArticleNumber
                                             ));
                    }

                    await paymentOrder.Actions.UpdateOrderRows(new UpdateOrderRowsRequest(newOrderRows));

                    TempData["OrderRowMessage"] = "Order rows have been updated";
                }
            }
            catch (Exception e)
            {
                TempData["ErrorMessage"] = $"Something unexpected happened. {e.Message}";
            }

            return(RedirectToAction("Details", "Orders"));
        }
コード例 #17
0
        public async System.Threading.Tasks.Task ReplaceOrderRows_Should_Serialize_AsExpected()
        {
            // Arrange
            var handlerMock = CreateHandlerMockWithAction(DataSample.AdminGetOrder);
            var sveaClient  = SveaClient(handlerMock);

            // Act
            var order = await sveaClient.PaymentAdmin.GetOrder(2291662);

            await order.Actions.ReplaceOrderRows(
                new ReplaceOrderRowsRequest(
                    new List <NewOrderRow> {
                new NewOrderRow(
                    name: "Slim Fit 512",
                    quantity: MinorUnit.FromInt(2),
                    unitPrice: MinorUnit.FromInt(1000),
                    vatPercent: MinorUnit.FromInt(12),
                    discountPercent: MinorUnit.FromInt(0),
                    rowId: 1,
                    unit: "SEK",
                    articleNumber: "1234567890"
                    ),
                new NewOrderRow(
                    name: "Slim Fit 513",
                    quantity: MinorUnit.FromInt(3),
                    unitPrice: MinorUnit.FromInt(2000),
                    vatPercent: MinorUnit.FromInt(5),
                    discountPercent: MinorUnit.FromInt(0),
                    rowId: 2,
                    unit: "SEK",
                    articleNumber: "0987654321"
                    )
            }
                    )
                );

            // Assert
            // No exeception thrown
        }
コード例 #18
0
        public async Task <ActionResult> CancelAmount(long paymentId)
        {
            try
            {
                var paymentOrder = await this._sveaClient.PaymentAdmin.GetOrder(paymentId);

                TempData["ErrorMessage"] = ActionsValidationHelper.ValidateOrderAction(paymentOrder, OrderActionType.CanCancelAmount);

                if (TempData["ErrorMessage"] == null)
                {
                    await paymentOrder.Actions.CancelAmount(new CancelAmountRequest(MinorUnit.FromDecimal(1)));

                    TempData["CancelMessage"] = $"Cancelling parts of the total amount: {paymentId}";
                }
            }
            catch (Exception e)
            {
                TempData["ErrorMessage"] = $"Something unexpected happened. {e.Message}";
            }

            return(RedirectToAction("Details", "Orders"));
        }
コード例 #19
0
 /// <summary>
 /// CancelAmountRequest
 /// </summary>
 /// <param name="cancelledAmount">The new CancelledAmount cannot be equal to or lower than the current CancelledAmount. Neither can it be higher than the total order amount.</param>
 public CancelAmountRequest(MinorUnit cancelledAmount)
 {
     CancelledAmount = cancelledAmount ?? throw new ArgumentNullException(nameof(cancelledAmount));
 }
コード例 #20
0
        public ValueAxis Build()
        {
            var valueAxis = new ValueAxis();

            valueAxis.AxisId = new AxisId {
                Val = this.Options.Id
            };

            valueAxis.Scaling = new Scaling();

            valueAxis.Scaling.Orientation = new Orientation {
                Val = this.Options.Orientation
            };

            if (this.Options.MinMaxBounds.HasValue)
            {
                var minAxisValue = new MinAxisValue {
                    Val = this.Options.MinMaxBounds.Value.MinValue
                };

                var maxAxisValue = new MaxAxisValue {
                    Val = this.Options.MinMaxBounds.Value.MaxValue
                };

                valueAxis.Scaling.Append(minAxisValue);

                valueAxis.Scaling.Append(maxAxisValue);
            }

            if (this.Options.MinMaxUnits.HasValue)
            {
                var minorUnit = new MinorUnit {
                    Val = this.Options.MinMaxUnits.Value.MinValue
                };

                var majorUnit = new MajorUnit {
                    Val = this.Options.MinMaxUnits.Value.MaxValue
                };

                valueAxis.Append(minorUnit);

                valueAxis.Append(majorUnit);
            }

            valueAxis.Delete = new Delete {
                Val = false
            };

            valueAxis.AxisPosition = new AxisPosition {
                Val = this.Options.AxisPosition
            };

            if (this.Options.ShowMajorGridlines)
            {
                var majorGridlinesBuilder = new MajorGridlinesBuilder(this.Options.MajorGridlinesOptions);

                valueAxis.MajorGridlines = majorGridlinesBuilder.Build();
            }

            if (this.Options.HasNumberingFormat)
            {
                valueAxis.NumberingFormat = new NumberingFormat
                {
                    FormatCode   = this.Options.FormatCode,
                    SourceLinked = this.Options.SourceLinked
                };
            }

            valueAxis.MajorTickMark = new MajorTickMark {
                Val = this.Options.MajorTickMark
            };

            valueAxis.MinorTickMark = new MinorTickMark {
                Val = this.Options.MinorTickMark
            };

            valueAxis.TickLabelPosition = new TickLabelPosition {
                Val = this.Options.TickLabelPosition
            };

            if (this.Options.HasChartShapeProperties)
            {
                var chartShapePropertiesBuilder = new ChartShapePropertiesBuilder(this.Options.ChartShapePropertiesOptions);

                valueAxis.ChartShapeProperties = chartShapePropertiesBuilder.Build();
            }

            if (this.Options.IsTextStylish)
            {
                valueAxis.TextProperties = new TextProperties();
                valueAxis.TextProperties.BodyProperties = new BodyProperties()
                {
                    Rotation            = -60000000,
                    UseParagraphSpacing = true,
                    VerticalOverflow    = TextVerticalOverflowValues.Ellipsis,
                    Vertical            = TextVerticalValues.Horizontal,
                    Wrap         = TextWrappingValues.Square,
                    Anchor       = TextAnchoringTypeValues.Center,
                    AnchorCenter = true
                };
                valueAxis.TextProperties.ListStyle = new ListStyle();

                var para = new Paragraph();
                para.ParagraphProperties = new ParagraphProperties();

                var defrunprops = new DefaultRunProperties();
                defrunprops.FontSize  = 900;
                defrunprops.Bold      = false;
                defrunprops.Italic    = false;
                defrunprops.Underline = TextUnderlineValues.None;
                defrunprops.Strike    = TextStrikeValues.NoStrike;
                defrunprops.Kerning   = 1200;
                defrunprops.Baseline  = 0;

                var schclr = new SchemeColor()
                {
                    Val = SchemeColorValues.Text1
                };
                schclr.Append(new LuminanceModulation()
                {
                    Val = 65000
                });
                schclr.Append(new LuminanceOffset()
                {
                    Val = 35000
                });
                defrunprops.Append(new SolidFill()
                {
                    SchemeColor = schclr
                });

                defrunprops.Append(new LatinFont()
                {
                    Typeface = "+mn-lt"
                });
                defrunprops.Append(new EastAsianFont()
                {
                    Typeface = "+mn-ea"
                });
                defrunprops.Append(new ComplexScriptFont()
                {
                    Typeface = "+mn-cs"
                });

                para.ParagraphProperties.Append(defrunprops);
                para.Append(new EndParagraphRunProperties()
                {
                    Language = System.Globalization.CultureInfo.CurrentCulture.Name
                });

                valueAxis.TextProperties.Append(para);
            }

            valueAxis.CrossingAxis = new CrossingAxis {
                Val = this.Options.CrossingAxisVal
            };

            if (this.Options.Crosses.HasValue)
            {
                valueAxis.Append(new Crosses {
                    Val = this.Options.Crosses
                });
            }
            else if (this.Options.CrossesAtVal.HasValue)
            {
                valueAxis.Append(new CrossesAt()
                {
                    Val = this.Options.CrossesAtVal
                });
            }

            valueAxis.Append(new CrossBetween {
                Val = this.Options.CrossBetween
            });

            return(valueAxis);
        }
コード例 #21
0
 /// <summary>
 /// CreditAmountRequest
 /// </summary>
 /// <param name="creditedAmount">To make a credit on a delivery, specify a credited amount larger than the current credited amount. The credited amount cannot be lower than the current credited amount or larger than the delivered amount.</param>
 public CreditAmountRequest(MinorUnit creditedAmount)
 {
     CreditedAmount = creditedAmount ?? throw new ArgumentNullException(nameof(creditedAmount));
 }
コード例 #22
0
 public static decimal ToDecimal(this MinorUnit amount)
 {
     return(MinorUnit.ToDecimal(amount));
 }
コード例 #23
0
        public async Task <ActionResult> CreditAmount(long paymentId, int deliveryId)
        {
            try
            {
                var paymentOrder = await this._sveaClient.PaymentAdmin.GetOrder(paymentId);

                TempData["ErrorMessage"] = ActionsValidationHelper.ValidateDeliveryAction(paymentOrder, deliveryId, DeliveryActionType.CanCreditAmount);

                if (TempData["ErrorMessage"] == null)
                {
                    var delivery = paymentOrder.Deliveries.FirstOrDefault(dlv => dlv.Id == deliveryId);

                    var response = await delivery.Actions.CreditAmount(new CreditAmountRequest(MinorUnit.FromInt(100)));

                    TempData["CreditMessage"] = $"Delivery credited. Credit id: {response.CreditId}";
                }
            }
            catch (Exception e)
            {
                TempData["ErrorMessage"] = $"Something unexpected happened. {e.Message}";
            }

            return(RedirectToAction("Details", "Orders"));
        }
コード例 #24
0
 public static int ToInt(this MinorUnit amount)
 {
     return(MinorUnit.ToInt(amount));
 }