示例#1
0
        public static Transaction RequestMoney(RequestMoneyTransaction transaction, APIKey apiKey)
        {
            RequestMoneyTransactionRequest request = new RequestMoneyTransactionRequest()
            {
                Transaction = transaction
            };

            TransactionResponse transactionResponse = (TransactionResponse)
                                                      PostResource(
                "transactions",
                "request_money",
                request,
                typeof(RequestMoneyTransactionRequest),
                typeof(TransactionResponse),
                apiKey
                );

            return(transactionResponse.Transaction);
        }
示例#2
0
        public static void TestConductTransactions(
            APIKey key1,
            APIKey key2
            )
        {
            Console.Write("Testing SendMoney w/ Valid Key: ");
            ReceiveAddress addr1 = API.GetReceiveAddress(key1);
            ReceiveAddress addr2 = API.GetReceiveAddress(key2);

            SendMoneyTransaction sendMoney = new SendMoneyTransaction()
            {
                ToAddr = addr1.Address,
                Amount = new Amount()
                {
                    AmountValue = 0.01m, Currency = "BTC"
                },
                Notes = "Testing send_money"
            };
            Transaction sendMoneyTransaction = API.SendMoney(
                sendMoney,
                key2
                );

            ASSERT(sendMoneyTransaction.IsValid, sendMoneyTransaction);

            if (!sendMoneyTransaction.IsValid)
            {
                return;
            }

            User user1 = API.GetUser(key1);

            if (!user1.IsValid)
            {
                return;
            }

            Console.Write("Testing RequestMoney w/ Valid Key: ");
            RequestMoneyTransaction requestMoney = new RequestMoneyTransaction()
            {
                FromAddr = user1.Email,
                Amount   = new Amount()
                {
                    AmountValue = 0.01m, Currency = "BTC"
                },
                Notes = "Testing request_money"
            };
            Transaction requestMoneyTransaction = API.RequestMoney(
                requestMoney,
                key2
                );

            ASSERT(requestMoneyTransaction.IsValid, requestMoneyTransaction);

            if (!requestMoneyTransaction.IsValid)
            {
                return;
            }

            Console.Write("Testing CancelRequest w/ Valid Key: ");
            CoinbaseResponse response = API.CancelRequest(requestMoneyTransaction.ID, key1);

            ASSERT(response.IsValid, response);

            requestMoneyTransaction = API.RequestMoney(
                requestMoney,
                key2
                );
            if (!requestMoneyTransaction.IsValid)
            {
                return;
            }

            response = API.ResendRequest(requestMoneyTransaction.ID, key2);
            Console.Write("Testing ResendRequest w/ Valid Key: ");
            ASSERT(response.IsValid, response);

            Console.Write("Testing CompleteRequest w/ Valid Key: ");
            response = API.CompleteRequest(requestMoneyTransaction.ID, key1);
            ASSERT(response.IsValid, response);
        }