protected override ApiResultMessage HandleRequest(object args) { string token = ((JObject)args)["token"].ToString(); int pin = Convert.ToInt32(((JObject)args)["pin"]); decimal amount = Convert.ToDecimal(((JObject)args)["amount"]); string processorValue = ((JObject)args)["processor"].ToString(); int userId = ApiAccessToken.ValidateAndGetUserId(token); Member User = new Member(userId); User.ValidatePIN(pin.ToString()); Money Amount = new Money(amount); Amount = Money.Parse(Amount.ToShortClearString()); var userAccountAddress = String.Empty; try { var CustomProcessor = new CustomPayoutProcessor(int.Parse(processorValue)); userAccountAddress = User.GetPaymentAddress(CustomProcessor.Id); } catch (Exception) { var selectedProcessor = processorValue; PaymentProcessor targetprocessor = PaymentAccountDetails.GetFromStringType(selectedProcessor); userAccountAddress = User.GetPaymentAddress(targetprocessor); } //Lets process to cashout PayoutManager Manager = new PayoutManager(User, Amount, processorValue, CustomPayoutProcessor.IsCustomPayoutProcessor(processorValue), CustomPayoutProcessor.GetCustomPayoutProcessorId(processorValue), userAccountAddress); string successMessage = Manager.TryMakePayout(); return(new ApiResultMessage { success = true, message = successMessage, data = null }); }
protected void CashoutButtonConfirm_Click(object sender, EventArgs e) { if (Page.IsValid) { SuccMessagePanel.Visible = false; ErrorMessagePanel.Visible = false; CashoutButtonConfirm.Visible = false; try { //Parse amount Money Transferred; try { Transferred = Money.Parse(AmountToCashoutTextBox.Text).FromMulticurrency(); Transferred = Money.Parse(Transferred.ToShortClearString()); } catch (Exception ex) { throw new MsgException(U2502.INVALIDMONEYFORMAT); } if (!AppSettings.Payments.WithdrawalEmailEnabled && AppSettings.Proxy.SMSType == ProxySMSType.EveryCashout) { User.IsPhoneVerifiedBeforeCashout = true; User.UnconfirmedSMSSent--; User.Save(); } //Lets process to cashout PayoutManager Manager = new PayoutManager(User, Transferred, RadioFrom.SelectedValue, CustomPayoutProcessor.IsCustomPayoutProcessor(RadioFrom.SelectedValue), CustomPayoutProcessor.GetCustomPayoutProcessorId(RadioFrom.SelectedValue), Account.Text); SuccMessage.Text = Manager.TryMakePayout(); SuccMessagePanel.Visible = true; } catch (Exception ex) { ErrorMessagePanel.Visible = true; ErrorMessage.Text = ex.Message; } finally { Account.Enabled = true; PIN.Enabled = true; AmountToCashoutTextBox.Enabled = true; CashoutButton.Visible = true; ConfirmationCodePlaceHolder2.Visible = false; CashoutButtonConfirm.Visible = false; } } }