public async Task WhenCalledAsTestUser_ItShouldCreateAPayment() { this.apiKeyRepository.Setup(v => v.GetApiKey(UserType.TestUser)).Returns(ApiKey); var expectedInput = new CreatePaymentIn { Amount = TaxamoTransactionResult.TotalAmount.ToMajorDenomination(), PaymentTimestamp = CommitTaxamoTransaction.ToTaxamoDateTimeString(StripeTransactionResult.Timestamp), PaymentInformation = string.Format( "Reference: {0}, StripeChargeId: {1}", StripeTransactionResult.TransactionReference.Value, StripeTransactionResult.StripeChargeId), }; CreatePaymentIn actualInput = null; this.taxamoService.Setup(v => v.CreatePaymentAsync(TaxamoTransactionResult.Key, It.IsAny <CreatePaymentIn>(), ApiKey)) .Callback <string, CreatePaymentIn, string>((a, b, c) => actualInput = b) .ReturnsAsync(new CreatePaymentOut()); await this.target.ExecuteAsync(TaxamoTransactionResult, StripeTransactionResult, UserType.TestUser); Assert.AreEqual( JsonConvert.SerializeObject(expectedInput, Formatting.None), JsonConvert.SerializeObject(actualInput, Formatting.None)); }
/// <summary> /// Register a payment /// </summary> /// <param name="Key">Transaction key.</param>/// <param name="Input">Input</param> /// <returns>CreatePaymentOut</returns> public async Task <CreatePaymentOut> CreatePaymentAsync(string Key, CreatePaymentIn Input) { // verify the required parameter 'Key' is set if (Key == null) { throw new ApiException(400, "Missing required parameter 'Key' when calling CreatePayment"); } // verify the required parameter 'Input' is set if (Input == null) { throw new ApiException(400, "Missing required parameter 'Input' when calling CreatePayment"); } var path = "/api/v1/transactions/{key}/payments"; 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)await this.apiClient.CallApiAsync(path, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, authSettings); if (((int)response.StatusCode) >= 400) { throw new ApiException((int)response.StatusCode, "Error calling CreatePayment: " + response.Content, response.Content); } return((CreatePaymentOut)this.apiClient.Deserialize(response.Content, typeof(CreatePaymentOut))); }
public async Task ExecuteAsync( TaxamoTransactionResult taxamoTransactionResult, StripeTransactionResult stripeTransactionResult, UserType userType) { taxamoTransactionResult.AssertNotNull("taxamoTransactionResult"); stripeTransactionResult.AssertNotNull("stripeTransactionResult"); var apiKey = this.taxamoApiKeyRepository.GetApiKey(userType); var input = new CreatePaymentIn { Amount = taxamoTransactionResult.TotalAmount.ToMajorDenomination(), PaymentTimestamp = ToTaxamoDateTimeString(stripeTransactionResult.Timestamp), PaymentInformation = string.Format( "Reference: {0}, StripeChargeId: {1}", stripeTransactionResult.TransactionReference.Value, stripeTransactionResult.StripeChargeId), }; await this.taxamoService.CreatePaymentAsync(taxamoTransactionResult.Key, input, apiKey); }
public Task <CreatePaymentOut> CreatePaymentAsync(string transactionKey, CreatePaymentIn input, string apiKey) { var transactionPayments = new ApivtransactionskeypaymentsApi(new ApiClient(apiKey)); return(transactionPayments.CreatePaymentAsync(transactionKey, input)); }