public async Task <WithdrawResponse> WithdrawAsync(WithdrawData withdrawData) { HttpResponseMessage response = null; try { logger.Debug("WithdrawAsync:" + withdrawData.Description); string json = JsonConvert.SerializeObject(withdrawData, jsonSettings); StringContent httpContent = new StringContent(json, Encoding.UTF8, "application/json"); response = await client.PostAsync(this.zebedeeUrl + "withdrawal-requests", httpContent); response.EnsureSuccessStatusCode(); string responseBody = await response.Content.ReadAsStringAsync(); //Deserialize WithdrawResponse deserializedCharge = JsonConvert.DeserializeObject <WithdrawResponse>(responseBody, jsonSettings); return(deserializedCharge); } catch (Exception e) { logger.Error(string.Format("WithdrawAsync with Exception : {0}", e)); logger.Error(response.ToString()); throw e; } }
private async void handleWithdrawal(WithdrawResponse withdraw) { string lnURL = withdraw.Data.Invoice.Request; if (string.IsNullOrEmpty(lnURL)) { logger.Debug("lnURL is not set in withdrawal response."); logger.Debug(withdraw.Data.Invoice.Request); return; } QRcodeText.text = "Congrats! Withdraw " + gamePlayFeeSats + " sats"; Texture2D texs = GenerateQR(lnURL);//Generate QR code image //4.Set the QR code image to image Gameobject QRcodeImage.GetComponent <Image>().sprite = Sprite.Create(texs, new Rect(0.0f, 0.0f, texs.width, texs.height), new Vector2(0.5f, 0.5f), 100.0f); //5.Subscribe to a callback method with ID to be monitored string status = await zbdClient.SubscribeWithDrawAsync(withdraw.Data.Id); if ("completed".Equals(status)) { //Change the image from QR to Paid QRcodeImage.GetComponent <Image>().sprite = Resources.Load <Sprite>("image/withdrawn"); logger.Debug("withdraw is success"); } else { //for example, if the amount paid is not full, do something.the line below just print the status. logger.Error("withdraw is not success:" + status); } }
public async Task WithdrawAsync(WithdrawData withdrawData, Action <WithdrawResponse> withdrawAction) { //Deserialize WithdrawResponse deserializedCharge = await WithdrawAsync(withdrawData); withdrawAction(deserializedCharge); }
public WithdrawResponse Withdraw(WithdrawRequest request) { var response = new WithdrawResponse(request); try { _accountBalance.ValidateWithdraw(request.Amount); _withdrawNotesService.ValidateWithdraw(request.Amount); _accountBalance.Withdraw(request.Amount); response.Notes = _withdrawNotesService.Withdraw(request.Amount); response.IsSucceeded = true; } catch (ArgumentException ex) { response.Message = ex.Message; } catch (Exception) { throw; } return(response); }
public override void OnBotCommand(string command) { if (command.Equals("withdraw")) { //Get current pot and all items in inventory string withdrawUrl = "http://csgowinbig.com/php/bot-withdraw.php"; var withdrawRequest = (HttpWebRequest)WebRequest.Create(withdrawUrl); var withdrawResponse = (HttpWebResponse)withdrawRequest.GetResponse(); string withdrawString = new StreamReader(withdrawResponse.GetResponseStream()).ReadToEnd(); WithdrawResponse botInventory = JsonConvert.DeserializeObject <WithdrawResponse> (withdrawString); var data = botInventory.data; var rgInventory = data.rgInventory; var currentPot = data.currentPot; var withdrawTradeOffer = Bot.NewTradeOffer(new SteamID(76561198020620333)); foreach (var inventoryItemKeyVal in rgInventory) { var invItem = inventoryItemKeyVal.Value; long classId = invItem.classid, instanceId = invItem.instanceid; bool withdrawThisItem = true; //Check to see if this item is in the current pot foreach (var potItem in currentPot) { long classIdPot = potItem.classid, instanceIdPot = potItem.instanceid; if (classId == classIdPot && instanceId == instanceIdPot) { withdrawThisItem = false; } } if (withdrawThisItem) { var assetId = invItem.id; withdrawTradeOffer.Items.AddMyItem(730, 2, assetId, 1); } } if (withdrawTradeOffer.Items.GetMyItems().Count != 0) { string withdrawOfferId; withdrawTradeOffer.Send(out withdrawOfferId, "Here are the withdraw items requested."); Log.Success("Withdraw trade offer sent. Offer ID: " + withdrawOfferId); } else { Log.Error("There are no profit items to withdraw at this time."); } } }
//Withdraw without Callback public async Task <WithdrawResponse> WithDrawAsync(Withdraw withdraw) { //Satoshi to milli satoshi WithdrawData withdrawRequest = new WithdrawData(); withdrawRequest.Amount = withdraw.AmountInSatoshi * 1000; withdrawRequest.Name = withdraw.Name; withdrawRequest.Description = withdraw.Description; WithdrawResponse withdrawResponse = await zbdService.WithdrawAsync(withdrawRequest); return(withdrawResponse); }
void HandleResponse(WithdrawResponse response) { if (response.Success) { if (response.WithdrawalPending > 0) { MessageBox.Show(response.WithdrawalPending.ToString() + " " + Currency.ToString() + " is now pending for withdrawal"); } Close(); return; } Enabled = true; DisplayError(response); }
private async Task <WithdrawResponse> getWithdrawDetailAsync(String withdrawUuid) { WithdrawResponse withdrawDetail = null; try { HttpResponseMessage response = await client.GetAsync(this.zebedeeUrl + "withdrawal-requests/" + withdrawUuid); response.EnsureSuccessStatusCode(); string responseBody = await response.Content.ReadAsStringAsync(); //Deserialize withdrawDetail = JsonConvert.DeserializeObject <WithdrawResponse>(responseBody, jsonSettings); } catch (Exception e) { logger.Error(string.Format("GET WithDraw with Exception: {0}", e)); throw e; } return(withdrawDetail); }
/// <summary> /// Submit a withdraw request. /// </summary> /// <param name="asset">Asset to withdraw.</param> /// <param name="amount">Amount to withdraw.</param> /// <param name="address">Address where the asset will be deposited.</param> /// <param name="addressName">Address name.</param> /// <param name="recvWindow">Specific number of milliseconds the request is valid for.</param> /// <returns></returns> public async Task <WithdrawResponse> Withdraw(string asset, decimal amount, string address, string addressName = "", long recvWindow = 50000) { if (string.IsNullOrWhiteSpace(asset)) { throw new ArgumentException("asset cannot be empty. ", "asset"); } if (amount <= 0m) { throw new ArgumentException("amount must be greater than zero.", "amount"); } if (string.IsNullOrWhiteSpace(address)) { throw new ArgumentException("address cannot be empty. ", "address"); } string args = $"asset={asset.ToUpper()}&amount={amount}&address={address}" + (!string.IsNullOrWhiteSpace(addressName) ? $"&name={addressName}" : "") + $"&recvWindow={recvWindow}"; WithdrawResponse result = await _apiClient.CallAsync <WithdrawResponse>(ApiMethod.POST, EndPoints.Withdraw, true, args); return(result); }
public async Task <WithdrawResponse> SubscribeWithdrawAsync(string withdrawUuid, int timeoutSec = 60) { logger.Debug("SubscribeWithdraw:" + withdrawUuid); TimeSpan delay = TimeSpan.FromSeconds(1); TimeSpan timeout = TimeSpan.FromSeconds(Math.Min(timeoutSec, 60));//Max 60 sec Task timeoutTask = Task.Delay(timeout); WithdrawResponse withdrawDetail = null; // Keep retry when satus is pending or timeoutTask is not completed while ((withdrawDetail == null || withdrawDetail.Data.Status == "pending") && !timeoutTask.IsCompleted) { withdrawDetail = await getWithdrawDetailAsync(withdrawUuid); await Task.Delay(delay); } if (timeoutTask.IsCompleted) { throw new ZedebeeException("Get withdraw Detail Timeout"); } return(withdrawDetail); }
void DisplayError(WithdrawResponse response) { if (response.WithdrawalTooSmall) { MessageBox.Show("Amount is too small for withdrawal (0.0001 BTC / 1 Doge / 0.001 LTC / 0.001 ETH is taken by the transaction fee)"); } else if (response.RateLimited) { MessageBox.Show("Actions are being performed too quickly, please slow down"); } else if (response.InsufficientFunds) { MessageBox.Show("You have insufficient funds for the withdrawal"); } else if (response.ErrorMessage != null) { MessageBox.Show("Error: " + response.ErrorMessage); } else { MessageBox.Show("An error has occurred requesting the withdrawal"); } }
private async void handleWithdrawal(WithdrawResponse withdraw) { string lnURL = withdraw.Data.Invoice.Request; if (string.IsNullOrEmpty(lnURL)) { logger.Debug("lnURL is not set in withdrawal response."); logger.Debug(withdraw.Data.Invoice.Request); return; } Texture2D texs = GenerateQR(lnURL);//Generate QR code image //4.Set the QR code iamge to image Gameobject //4.取得したBOLTからQRコードを作成し、ウオレットでスキャンするために表示する。 QRcodeLnURL.GetComponent <Image>().sprite = Sprite.Create(texs, new Rect(0.0f, 0.0f, texs.width, texs.height), new Vector2(0.5f, 0.5f), 100.0f); //5.Subscribe the an callback method with invoice ID to be monitored //5.支払がされたら実行されるコールバックを引き渡して、コールーチンで実行する // StartCoroutine(btcPayClient.SubscribeInvoiceCoroutine(invoice.Id, printInvoice)); //StartCoroutine(btcPayClient.listenInvoice(invoice.Id, printInvoice)); string status = await zbdClient.SubscribeWithDrawAsync(withdraw.Data.Id); if ("completed".Equals(status)) { //インボイスのステータスがcompleteであれば、全額が支払われた状態なので、支払完了のイメージに変更する //Change the image from QR to Paid QRcodeLnURL.GetComponent <Image>().sprite = Resources.Load <Sprite>("image/withdrawn"); logger.Debug("withdraw is success"); } else { //for example, if the amount paid is not full, do something.the line below just print the status. //全額支払いでない場合には、なにか処理をおこなう。以下は、ただ ステータスを表示して終了。 logger.Error("withdraw is not success:" + status); } }
public override void OnBotCommand(string command) { if (IsAdmin) { if (command.Equals("confirm")) { Bot.AcceptAllMobileTradeConfirmations(); Log.Success("All trade offers confirmed... on bot: " + Bot.SteamUser.SteamID.ConvertToUInt64()); } } if (command.Equals("skins")) { //Get current pot and all items in inventory string withdrawUrl = Bot.BotWebsiteURL + "/php/bot-withdraw.php"; var withdrawRequest = (HttpWebRequest)WebRequest.Create(withdrawUrl); var withdrawResponse = (HttpWebResponse)withdrawRequest.GetResponse(); string withdrawString = new StreamReader(withdrawResponse.GetResponseStream()).ReadToEnd(); WithdrawResponse botInventory = JsonConvert.DeserializeObject <WithdrawResponse>(withdrawString); var data = botInventory.data; var rgInventory = data.rgInventory; var currentPot = data.currentPot; var withdrawTradeOffer = Bot.NewTradeOffer(new SteamID(Bot.ProfitAdmin)); foreach (var inventoryItemKeyVal in rgInventory) { var invItem = inventoryItemKeyVal.Value; long classId = invItem.classid, instanceId = invItem.instanceid; bool withdrawThisItem = true; //Check to see if this item is in the current pot foreach (var potItem in currentPot) { long classIdPot = potItem.classid, instanceIdPot = potItem.instanceid; if (classId == classIdPot && instanceId == instanceIdPot) { withdrawThisItem = false; } } if (withdrawThisItem) { if (invItem.instanceid != 0) { if (invItem.instanceid != 519977179) { var assetId = invItem.id; withdrawTradeOffer.Items.AddMyItem(730, 2, assetId, 1); } } } } if (withdrawTradeOffer.Items.GetMyItems().Count != 0) { string withdrawOfferId; withdrawTradeOffer.Send(out withdrawOfferId, "Here are the withdraw items requested."); Bot.AcceptAllMobileTradeConfirmations(); Log.Success("Withdraw trade offer sent. Offer ID: " + withdrawOfferId); } else { Log.Error("There are no profit items to withdraw at this time."); } } if (command.Equals("withdraw")) { //Get current pot and all items in inventory string withdrawUrl = Bot.BotWebsiteURL + "/php/bot-withdraw.php"; var withdrawRequest = (HttpWebRequest)WebRequest.Create(withdrawUrl); var withdrawResponse = (HttpWebResponse)withdrawRequest.GetResponse(); string withdrawString = new StreamReader(withdrawResponse.GetResponseStream()).ReadToEnd(); WithdrawResponse botInventory = JsonConvert.DeserializeObject <WithdrawResponse>(withdrawString); var data = botInventory.data; var rgInventory = data.rgInventory; var currentPot = data.currentPot; var withdrawTradeOffer = Bot.NewTradeOffer(new SteamID(Bot.ProfitAdmin)); foreach (var inventoryItemKeyVal in rgInventory) { var invItem = inventoryItemKeyVal.Value; long classId = invItem.classid, instanceId = invItem.instanceid; bool withdrawThisItem = true; //Check to see if this item is in the current pot foreach (var potItem in currentPot) { long classIdPot = potItem.classid, instanceIdPot = potItem.instanceid; if (classId == classIdPot && instanceId == instanceIdPot) { withdrawThisItem = false; } } if (withdrawThisItem) { var assetId = invItem.id; withdrawTradeOffer.Items.AddMyItem(730, 2, assetId, 1); } } if (withdrawTradeOffer.Items.GetMyItems().Count != 0) { string withdrawOfferId; withdrawTradeOffer.Send(out withdrawOfferId, "Here are the withdraw items requested."); Bot.AcceptAllMobileTradeConfirmations(); Log.Success("Withdraw trade offer sent. Offer ID: " + withdrawOfferId); } else { Log.Error("There are no profit items to withdraw at this time."); } } }
public IActionResult NoteView(WithdrawResponse request) { return(View(request)); }
public async Task <string> SubscribeWithDrawAsync(string withdrawId, int timeoutSec = 60) { WithdrawResponse withdrawDetail = await zbdService.SubscribeWithdrawAsync(withdrawId, timeoutSec); return(withdrawDetail.Data.Status); }