Example #1
0
        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);
        }
Example #2
0
 public void Init()
 {
     instance = new AccountDebitsApi();
 }