public void TestUpdateAuthorization() { // Arrange UpdateAuthorization updateAuthorization = new UpdateAuthorization() { Description = "TestUpdateAuthorization description" }; this.requestMock.Expect(x => x.CreateRequest(this.baseUrl.ToString().TrimEnd('/') + this.path + '/' + this.orderId + "/authorization")).Return(this.httpWebRequest); WebHeaderCollection headers = new WebHeaderCollection(); headers["Location"] = this.location; IResponse response = new Response(HttpStatusCode.NoContent, headers, string.Empty); this.requestMock.Expect(x => x.Send(this.httpWebRequest, updateAuthorization.ConvertToJson())).Return(response); // Act this.order.UpdateAuthorization(updateAuthorization); // Assert this.requestMock.VerifyAllExpectations(); Assert.AreEqual(this.httpWebRequest.ContentLength, updateAuthorization.ConvertToJson().Length); TestsHelper.AssertRequest(this.merchantId, this.secret, this.httpWebRequest, HttpMethod.Patch); }
public void OrderManagement_Order_UpdateAuthorization_Basic() { // Arrange UpdateAuthorization updateAuthorization = TestsHelper.GetUpdateAuthorization(); TestsHelper.Mock(HttpMethod.Patch, this.order.Location + "/authorization", updateAuthorization.ConvertToJson(), HttpStatusCode.NoContent, this.connectorMock); this.order.UpdateAuthorization(updateAuthorization); }
/// <summary> /// Get update authorization. /// </summary> /// <returns>a update authorization</returns> public static UpdateAuthorization GetUpdateAuthorization() { UpdateAuthorization updateAuthorization = new UpdateAuthorization() { OrderAmount = 111, Description = "A description" }; return(updateAuthorization); }
/// <summary> /// Run the example code. /// </summary> public static void Main() { const string MerchantId = "0"; const string SharedSecret = "sharedSecret"; string orderId = "12345"; IConnector connector = ConnectorFactory.Create(MerchantId, SharedSecret, Client.EuTestBaseUrl); Client client = new Client(connector); IOrder order = client.NewOrder(orderId); List <OrderLine> lines = new List <OrderLine>(); lines.Add(new OrderLine() { Type = "physical", Reference = "123050", Name = "Tomatoes", Quantity = 10, QuantityUnit = "kg", UnitPrice = 600, TaxRate = 2500, TotalAmount = 6000, TotalTaxAmount = 1200 }); UpdateAuthorization updateAuthorization = new UpdateAuthorization() { OrderAmount = 6000, Description = "Removed bad bananas", OrderLines = lines }; try { order.UpdateAuthorization(updateAuthorization); } catch (ApiException ex) { Console.WriteLine(ex.ErrorMessage.ErrorCode); Console.WriteLine(ex.ErrorMessage.ErrorMessages); Console.WriteLine(ex.ErrorMessage.CorrelationId); } catch (WebException ex) { Console.WriteLine(ex.Message); } }
/// <summary> /// Updates the authorization data. /// </summary> /// <param name="updateAuthorization">the updateAuthorization</param> public void UpdateAuthorization(UpdateAuthorization updateAuthorization) { this.Patch(this.Location + "/authorization", updateAuthorization) .Status(HttpStatusCode.NoContent); }
/// <summary> /// Sets new order amount and order lines /// <a href="https://developers.klarna.com/api/#order-management-api-set-new-order-amount-and-order-lines"> /// https://developers.klarna.com/api/#order-management-api-set-new-order-amount-and-order-lines /// </a> /// </summary> /// <param name="orderId">Id of order to update</param> /// <param name="newOrderAmountAndLines">The <see cref="UpdateAuthorization"/> object</param> /// <returns></returns> public Task SetNewOrderAmountAndOrderLines(string orderId, UpdateAuthorization newOrderAmountAndLines) { var url = ApiUrlHelper.GetApiUrlForController(ApiSession.ApiUrl, ApiControllerUri, $"{orderId}/authorization"); return(Patch(url, newOrderAmountAndLines)); }