private async Task PerformTest(UserType userType) { this.apiKeyRepository.Setup(v => v.GetApiKey(userType)).Returns(ApiKey); var expectedInput = new CreateRefundIn { Amount = AmountInMinorDenomination.Create(RefundCreditAmount).ToMajorDenomination(), CustomId = CreateTaxamoTransaction.CustomId }; CreateRefundIn actualInput = null; this.taxamoService.Setup(v => v.CreateRefundAsync(TaxamoTransactionKey, It.IsAny <CreateRefundIn>(), ApiKey)) .Callback <string, CreateRefundIn, string>((a, b, c) => actualInput = b) .ReturnsAsync(new CreateRefundOut { TotalAmount = 0.12m, TaxAmount = 0.02m, }); var result = await this.target.ExecuteAsync(TaxamoTransactionKey, RefundCreditAmount, userType); Assert.AreEqual( new CreateTaxamoRefund.TaxamoRefundResult( PositiveInt.Parse(12), NonNegativeInt.Parse(2)), result); Assert.AreEqual( JsonConvert.SerializeObject(expectedInput, Formatting.None), JsonConvert.SerializeObject(actualInput, Formatting.None)); }
public async Task <TaxamoRefundResult> ExecuteAsync( string taxamoTransactionKey, PositiveInt refundCreditAmount, UserType userType) { taxamoTransactionKey.AssertNotNull("taxamoTransactionKey"); refundCreditAmount.AssertNotNull("refundCreditAmount"); var amount = AmountInMinorDenomination.Create(refundCreditAmount).ToMajorDenomination(); var apiKey = this.taxamoApiKeyRepository.GetApiKey(userType); var input = new CreateRefundIn { Amount = amount, CustomId = CreateTaxamoTransaction.CustomId, }; var result = await this.taxamoService.CreateRefundAsync(taxamoTransactionKey, input, apiKey); var totalAmount = AmountInMinorDenomination.FromMajorDenomination(result.TotalAmount.Value); var taxAmount = AmountInMinorDenomination.FromMajorDenomination(result.TaxAmount.Value); return(new TaxamoRefundResult(totalAmount.ToPositiveInt(), taxAmount.ToNonNegativeInt())); }
/// <summary> /// Create a refund /// </summary> /// <param name="Key">Transaction key.</param>/// <param name="Input">Input</param> /// <returns>CreateRefundOut</returns> public CreateRefundOut CreateRefund(string Key, CreateRefundIn Input) { // verify the required parameter 'Key' is set if (Key == null) { throw new ApiException(400, "Missing required parameter 'Key' when calling CreateRefund"); } // verify the required parameter 'Input' is set if (Input == null) { throw new ApiException(400, "Missing required parameter 'Input' when calling CreateRefund"); } var path = "/api/v1/transactions/{key}/refunds"; path = path.Replace("{format}", "json"); path = path.Replace("{" + "key" + "}", this.apiClient.ParameterToString(Key)); var queryParams = new Dictionary <String, String>(); var headerParams = new Dictionary <String, String>(); var formParams = new Dictionary <String, String>(); var fileParams = new Dictionary <String, String>(); String postBody = null; postBody = this.apiClient.Serialize(Input); // http body (model) parameter // authentication setting, if any String[] authSettings = new String[] { }; // make the HTTP request IRestResponse response = (IRestResponse)this.apiClient.CallApi(path, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, authSettings); if (((int)response.StatusCode) >= 400) { throw new ApiException((int)response.StatusCode, "Error calling CreateRefund: " + response.Content, response.Content); } return((CreateRefundOut)this.apiClient.Deserialize(response.Content, typeof(CreateRefundOut))); }
public Task <CreateRefundOut> CreateRefundAsync(string transactionKey, CreateRefundIn input, string apiKey) { var refund = new ApivtransactionskeyrefundsApi(new ApiClient(apiKey)); return(refund.CreateRefundAsync(transactionKey, input)); }