public async Task CreateNewPaymentRequest() { PaymentRequest payment = new PaymentRequest(); PayRequestOM result = await payment.CreateNewPaymentRequest("fiiitFmH9Cqk5B9gTH3LqZzBtqb8pxgHJ7sVqY", "abc", 10000, "test"); Assert.IsNotNull(result); }
public async Task <PayRequestOM> CreateNewPaymentRequest(string accountId, string tag, long amount, string comment) { AuthenticationHeaderValue authHeaderValue = null; RpcClient client = new RpcClient(new Uri(WalletNetwork.NetWork), authHeaderValue, null, null, "application/json"); RpcRequest request = RpcRequest.WithParameterList("CreateNewPaymentRequest", new List <object> { accountId, tag, amount, comment }, 1); RpcResponse response = await client.SendRequestAsync(request); if (response.HasError) { throw new ApiCustomException(response.Error.Code, response.Error.Message); } PayRequestOM responseValue = response.GetResult <PayRequestOM>(); return(responseValue); }
public static async Task <ApiResponse> CreateNewPaymentRequest(string tag, long amount, string comment) { ApiResponse response = new ApiResponse(); try { Accounts accounts = new Accounts(); PaymentRequest request = new PaymentRequest(); PayRequest pay = new PayRequest(); AccountInfoOM accountInfo = await accounts.GetNewAddress(tag); PayRequestOM result = await request.CreateNewPaymentRequest(accountInfo.Address, tag, amount, comment); if (result != null) { pay.AccountId = result.AccountId; pay.Amount = result.Amount; pay.Comment = result.Comment; pay.Id = result.Id; pay.Tag = result.Tag; pay.Timestamp = result.Timestamp; response.Result = Newtonsoft.Json.Linq.JToken.FromObject(pay); } else { response.Result = null; } } catch (ApiCustomException ex) { Logger.Singleton.Error(ex.Message); response.Error = new ApiError(ex.ErrorCode, ex.Message); } catch (Exception ex) { Logger.Singleton.Error(ex.Message); response.Error = new ApiError(ex.HResult, ex.Message); } return(response); }