public static bool CheckBankAccount(FiatProcessorSettings fiatSettings, string bankaccount) { var jsonBody = JsonConvert.SerializeObject(new { account = bankaccount }); var response = RestUtils.ServiceRequest(fiatSettings.FiatServerUrl, "bankaccount_is_valid", null, jsonBody); if (response.IsSuccessful) { var json = JsonConvert.DeserializeObject <Dictionary <string, object> >(response.Content); if (json.ContainsKey("result") && json["result"] is bool) { return((bool)json["result"]); } } return(true); }
public static viafront3.Models.ApiViewModels.ApiFiatPaymentRequest GetFiatPaymentRequest(FiatProcessorSettings fiatSettings, string token) { var jsonBody = JsonConvert.SerializeObject(new { api_key = fiatSettings.FiatServerApiKey, token = token }); var response = RestUtils.ServiceRequest(fiatSettings.FiatServerUrl, "payment_status", fiatSettings.FiatServerSecret, jsonBody); if (response.IsSuccessful) { var json = JsonConvert.DeserializeObject <Dictionary <string, string> >(response.Content); if (json.ContainsKey("status")) { var status = json["status"]; var asset = json["asset"]; var amount = json["amount"]; // return to user var model = new viafront3.Models.ApiViewModels.ApiFiatPaymentRequest { Token = token, ServiceUrl = $"{fiatSettings.FiatServerUrl}/request/{token}", Status = status, Asset = asset, Amount = decimal.Parse(amount), }; return(model); } } return(null); }
public static viafront3.Models.ApiViewModels.ApiFiatPaymentRequest CreateFiatPaymentRequest(ILogger logger, FiatProcessorSettings fiatSettings, string token, string asset, decimal amount, long expiry) { // call payment server to create request var amount_cents = Convert.ToInt32(amount * 100); var jsonBody = JsonConvert.SerializeObject(new { api_key = fiatSettings.FiatServerApiKey, token = token, asset = asset, amount = amount_cents, return_url = "", expiry = expiry }); var response = RestUtils.ServiceRequest(fiatSettings.FiatServerUrl, "payment_create", fiatSettings.FiatServerSecret, jsonBody); if (response.IsSuccessful) { var json = JsonConvert.DeserializeObject <Dictionary <string, string> >(response.Content); if (json.ContainsKey("status")) { var status = json["status"]; // return to user var model = new viafront3.Models.ApiViewModels.ApiFiatPaymentRequest { Token = token, ServiceUrl = $"{fiatSettings.FiatServerUrl}/payment/{token}", Status = status, Asset = asset, Amount = amount, }; return(model); } } else { logger.LogError($"fiat payment request ({fiatSettings.FiatServerUrl}) failed with http statuscode: {response.StatusCode}"); } return(null); }
public static viafront3.Models.ApiViewModels.ApiFiatPayoutRequest CreateFiatPayoutRequest(ILogger logger, ExchangeSettings settings, FiatProcessorSettings fiatSettings, string token, string asset, decimal amount, string account_number, string email) { var cents = amount * Utils.IntPow(10, settings.Assets[asset].Decimals); var centsInt = Convert.ToInt64(cents); // call payment server to create request var jsonBody = JsonConvert.SerializeObject(new { api_key = fiatSettings.FiatServerApiKey, token = token, asset = asset, amount = centsInt, account_number = account_number, account_name = email, reference = fiatSettings.PayoutsReference, code = token }); var response = ServiceRequest(fiatSettings.FiatServerUrl, "payout_create", fiatSettings.FiatServerSecret, jsonBody); if (response.IsSuccessful) { var json = JsonConvert.DeserializeObject <Dictionary <string, string> >(response.Content); if (json.ContainsKey("status")) { var status = json["status"]; // return to user var model = new viafront3.Models.ApiViewModels.ApiFiatPayoutRequest { Token = token, Status = status, Asset = asset, Amount = amount, }; return(model); } } else { logger.LogError($"fiat payment request ({fiatSettings.FiatServerUrl}) failed with http statuscode: {response.StatusCode}"); } return(null); }