/// <summary> /// Moves Charge to Canceled state and releases any authorized payments. /// </summary> /// <returns>AmazonPayResponse response</returns> /// <remarks> /// You can call this operation until Capture is initiated while Charge is in an AuthorizationInitiated or Authorized state. /// </remarks> public ChargeResponse CancelCharge(string chargeId, CancelChargeRequest cancelRequest, Dictionary <string, string> headers = null) { var apiPath = apiUrlBuilder.BuildFullApiPath(Constants.ApiServices.Default, Constants.Resources.WebStore.Charges, chargeId, Constants.Methods.Cancel); var apiRequest = new ApiRequest(apiPath, HttpMethod.DELETE, cancelRequest, headers); var result = CallAPI <ChargeResponse>(apiRequest); return(result); }
public void CanConstructWithAllPropertiesInitializedAsExpected() { // act var request = new CancelChargeRequest("foo"); // assert Assert.IsNotNull(request); Assert.AreEqual("foo", request.CancellationReason); }
public void CanCancelCharge() { mockClient.Protected().As <IClientMapping>() .Setup(c => c.ProcessRequest <ChargeResponse>(It.IsAny <ApiRequest>(), It.IsAny <Dictionary <string, string> >())) .Returns((ApiRequest request, Dictionary <string, string> headers) => AssertPreProcessRequestFlow <ChargeResponse>(request, headers, HttpMethod.DELETE, $"{Constants.Resources.WebStore.Charges}/{checkoutSessionIdToTest}/cancel")); var testRequest = new CancelChargeRequest("my reason"); var result = mockClient.Object.CancelCharge(checkoutSessionIdToTest, testRequest); }
public void CanConvertToJson() { // arrange var request = new CancelChargeRequest("foo"); // act string json = request.ToJson(); string json2 = request.ToJson(); // assert Assert.AreEqual(json, json2); Assert.AreEqual("{\"cancellationReason\":\"foo\"}", json); }