public void OrderApi_CreateOrder() { OrdersApi api = new OrdersApi(BaseUrl, apiToken, apiKey); CreateOrdersRequest req = new CreateOrdersRequest(); req.Amount = new AmountsCreateOrdersRequest() { Currency = CurrencyType.BRL, Subtotals = new TotaisAmountsCreateOrdersRequest() { Shipping = 0 } }; string idCliente = "CUS-1IO9IR204YI4"; req.Customer = new ClienteCreateOrdersRequest(idCliente); req.Items = new System.Collections.Generic.List <OrderItemCreateOrdersRequest>(); req.Items.Add(new OrderItemCreateOrdersRequest() { Detail = "Detalhe Produto de teste ", Price = 100, Product = "Produto de teste ", Quantity = 1 }); req.OwnId = "231"; req.Receivers = new System.Collections.Generic.List <ReceiverCreateOrdersRequest>(); req.Receivers.Add(new ReceiverCreateOrdersRequest() { Type = ReceiverType.PRIMARY, Amount = new AmountReceiverCreateOrdersRequest() { Percentual = 1, ValueFixed = 1 }, FeePayor = false, moipAccount = new MoipAccountReceiverCreateOrdersRequest() { Id = "MPA-9B34B54E286C" } }); var retorno = api.CreateOrder(req); }
public void CreateOrderTest_CustomItems() { const string referenceId = "reference_id"; CreateOrderRequest request = new CreateOrderRequest( IdempotencyKey: Guid.NewGuid().ToString(), ReferenceId: referenceId, LineItems: new List <CreateOrderRequestLineItem>() { new CreateOrderRequestLineItem( Name: "Printed T Shirt", Quantity: "2", BasePriceMoney: new Money(Amount: 1500, Currency: "USD"), Discounts: new List <CreateOrderRequestDiscount>() { new CreateOrderRequestDiscount( Name: "7% off previous season item", Percentage: "7" ), new CreateOrderRequestDiscount( Name: "$3 off Customer Discount", AmountMoney: new Money(300, "USD") ) } ), new CreateOrderRequestLineItem( Name: "Slim Jeans", Quantity: "1", BasePriceMoney: new Money(Amount: 2500, Currency: "USD") ), new CreateOrderRequestLineItem( Name: "Woven Sweater", Quantity: "3", BasePriceMoney: new Money(Amount: 3500, Currency: "USD"), Discounts: new List <CreateOrderRequestDiscount>() { new CreateOrderRequestDiscount( Name: "$11 off Customer Discount", AmountMoney: new Money(1100, "USD") ) }, Taxes: new List <CreateOrderRequestTax>() { new CreateOrderRequestTax( Name: "Fair Trade Tax", Percentage: "5" ) } ) }, Discounts: new List <CreateOrderRequestDiscount>() { new CreateOrderRequestDiscount( Name: "Father's day 12% OFF", Percentage: "12" ), new CreateOrderRequestDiscount( Name: "Global Sales $55 OFF", AmountMoney: new Money(5500, "USD") ) }, Taxes: new List <CreateOrderRequestTax>() { new CreateOrderRequestTax( Name: "Sales Tax", Percentage: "8.5" ) } ); CreateOrderResponse response = instance.CreateOrder(locationId, request); Assert.IsNull(response.Errors); Order actual = response.Order; Assert.IsNotNull(actual); Assert.AreEqual(request.ReferenceId, actual.ReferenceId); Assert.AreEqual(locationId, actual.LocationId); Assert.AreEqual(3, actual.LineItems.Count); Assert.AreEqual(7818, actual.TotalMoney.Amount); Assert.AreEqual("USD", actual.TotalMoney.Currency); Assert.AreEqual(823, actual.TotalTaxMoney.Amount); Assert.AreEqual("USD", actual.TotalTaxMoney.Currency); Assert.AreEqual(9005, actual.TotalDiscountMoney.Amount); Assert.AreEqual("USD", actual.TotalDiscountMoney.Currency); }