static Guid?CreateAndFundTransactionExample(Configuration configuration) { Guid?transactionId = CreateTransactionExample(configuration); if (transactionId == null) { return(null); } // Please see https://docs.transferzero.com/docs/transaction-flow/#funding-transactions // on details about funding transactions Debit debit = new Debit( currency: "USD", toId: transactionId, toType: "Transaction" ); DebitRequestWrapper debitRequest = new DebitRequestWrapper( debit: new List <Debit>() { debit } ); AccountDebitsApi debitsApi = new AccountDebitsApi(configuration); try { DebitListResponse debitListResponse = debitsApi.PostAccountsDebits(debitRequest); System.Console.WriteLine("Transaction Funded Successfully"); System.Console.WriteLine(debitListResponse.Object[0]); } catch (ApiException e) { if (e.IsValidationError) { DebitListResponse debitListResponse = e.ParseObject <DebitListResponse>(); System.Console.WriteLine("Transaction could not be funded"); System.Console.WriteLine(debitListResponse.Object[0].Errors); } else { throw e; } } return(transactionId); }
/// <summary> /// Creating an account debit Creates a new account debit finding transaction through the internal balance To successfully fund a transaction - - The currency needs to be the same as the input_currency on the transaction - The amount has to be the same as the input_amount on the transaction - The to_id is the id of the transaction - You need to have enough balance of the appropriate currency inside your wallet Once the transaction is funded, we will immediately start trying to pay out the recipient(s). It is also possible to create multiple account debits by supplying an array of debit objects /// </summary> /// <exception cref="TransferZero.Sdk.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="debitRequestWrapper"></param> /// <returns>Task of ApiResponse (DebitListResponse)</returns> public async System.Threading.Tasks.Task <ApiResponse <DebitListResponse> > PostAccountsDebitsAsyncWithHttpInfo(DebitRequestWrapper debitRequestWrapper) { // verify the required parameter 'debitRequestWrapper' is set if (debitRequestWrapper == null) { throw new ApiException(400, "Missing required parameter 'debitRequestWrapper' when calling AccountDebitsApi->PostAccountsDebits"); } var localVarPath = "/accounts/debits"; var localVarPathParams = new Dictionary <String, String>(); var localVarQueryParams = new List <KeyValuePair <String, String> >(); var localVarHeaderParams = new Dictionary <String, String>(this.Configuration.DefaultHeader); var localVarFormParams = new Dictionary <String, String>(); var localVarFileParams = new Dictionary <String, FileParameter>(); Object localVarPostBody = null; // to determine the Content-Type header String[] localVarHttpContentTypes = new String[] { "application/json" }; String localVarHttpContentType = this.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); // to determine the Accept header String[] localVarHttpHeaderAccepts = new String[] { "application/json" }; String localVarHttpHeaderAccept = this.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); if (localVarHttpHeaderAccept != null) { localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); } if (debitRequestWrapper != null && debitRequestWrapper.GetType() != typeof(byte[])) { localVarPostBody = this.Configuration.ApiClient.Serialize(debitRequestWrapper); // http body (model) parameter } else { localVarPostBody = debitRequestWrapper; // byte array } var request = new RestRequest(localVarPath, Method.POST); // add path parameter, if any foreach (var param in localVarPathParams) { request.AddParameter(param.Key, param.Value, ParameterType.UrlSegment); } foreach (var param in localVarQueryParams) { request.AddQueryParameter(param.Key, param.Value); } // generate full URL string fullUri = this.Configuration.ApiClient.RestClient.BuildUri(request).AbsoluteUri; string nonce = System.Guid.NewGuid().ToString(); string authSignature = this.Configuration.GetSignature(nonce, fullUri, "POST", localVarPostBody == null ? "" : localVarPostBody.ToString()); localVarHeaderParams.Add("Authorization-Key", this.Configuration.ApiKey); localVarHeaderParams.Add("Authorization-Nonce", nonce); localVarHeaderParams.Add("Authorization-Signature", authSignature); // make the HTTP request IRestResponse localVarResponse = (IRestResponse)await this.Configuration.ApiClient.CallApiAsync(localVarPath, Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarPathParams, localVarHttpContentType); int localVarStatusCode = (int)localVarResponse.StatusCode; if (ExceptionFactory != null) { Exception exception = ExceptionFactory("PostAccountsDebits", localVarResponse); if (exception != null) { throw exception; } } return(new ApiResponse <DebitListResponse>(localVarStatusCode, localVarResponse.Headers.ToDictionary(x => x.Name, x => string.Join(",", x.Value)), (DebitListResponse)this.Configuration.ApiClient.Deserialize(localVarResponse, typeof(DebitListResponse)))); }
/// <summary> /// Creating an account debit Creates a new account debit finding transaction through the internal balance To successfully fund a transaction - - The currency needs to be the same as the input_currency on the transaction - The amount has to be the same as the input_amount on the transaction - The to_id is the id of the transaction - You need to have enough balance of the appropriate currency inside your wallet Once the transaction is funded, we will immediately start trying to pay out the recipient(s). It is also possible to create multiple account debits by supplying an array of debit objects /// </summary> /// <exception cref="TransferZero.Sdk.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="debitRequestWrapper"></param> /// <returns>Task of DebitListResponse</returns> public async System.Threading.Tasks.Task <DebitListResponse> PostAccountsDebitsAsync(DebitRequestWrapper debitRequestWrapper) { ApiResponse <DebitListResponse> localVarResponse = await PostAccountsDebitsAsyncWithHttpInfo(debitRequestWrapper); return(localVarResponse.Data); }
/// <summary> /// Creating an account debit Creates a new account debit finding transaction through the internal balance To successfully fund a transaction - - The currency needs to be the same as the input_currency on the transaction - The amount has to be the same as the input_amount on the transaction - The to_id is the id of the transaction - You need to have enough balance of the appropriate currency inside your wallet Once the transaction is funded, we will immediately start trying to pay out the recipient(s). It is also possible to create multiple account debits by supplying an array of debit objects /// </summary> /// <exception cref="TransferZero.Sdk.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="debitRequestWrapper"></param> /// <returns>DebitListResponse</returns> public DebitListResponse PostAccountsDebits(DebitRequestWrapper debitRequestWrapper) { ApiResponse <DebitListResponse> localVarResponse = PostAccountsDebitsWithHttpInfo(debitRequestWrapper); return(localVarResponse.Data); }