text连接到付费频道(代码片段)

author author     2022-12-01     128

关键词:

*** singleUseTokenId -- check (angular - payway for Angular)


public PaywayCustomerResponse CreateCustomer(PaywayCustomerRequest customer)

    PaywayCustomerResponse response = null;

    var createCustomerURL = "https://api.payway.com.au/rest/v1/customers";

    var apiToken = "payway publishable api key";

    string input = "singleUseTokenId=4f6f4751-30d6-4a97-ac46-34cde80d478b&merchantId=TEST&bankAccountId=0000000A&customerName=cvcvbbb&emailAddress=&sendEmailReceipts=false&phoneNumber=&street1=&street2=&state=&postalCode=";

    if (apiToken != null && !apiToken.HasError && !string.IsNullOrWhiteSpace(createCustomerURL))
    
        // Create customer in Payway Customer Vault

        try
        
            response = GetJsonResult<PaywayCustomerResponse>(createCustomerURL, "POST", GetEndcodedAPIKey(apiToken), input);
        
        catch (Exception ex)
        
            _dickerDataLogger.Add(LogTypes.Payway, "PAYWAY", "CreatePaywayCustomer", ex.ToString());
        
    
    else
    
        _dickerDataLogger.Add(LogTypes.Payway, "PAYWAY", "CreatePaywayCustomer", "API Token / URL null error");
    

    return response;




private string GetEndcodedAPIKey(string in_key)

  return Convert.ToBase64String(Encoding.UTF8.GetBytes(in_key));


public T GetJsonResult<T>(string url, string method, string token, dynamic content = null) where T : new()

  var request = (HttpWebRequest)HttpWebRequest.Create(url);
  var result = new T();
  string contentString = string.Empty;
  string errorDesc = string.Empty;

  request.Method = method.ToUpper();
  request.KeepAlive = false;

  ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

  request.Accept = "application/json";

  if (content != null)
  
      if (content is String)
      
          contentString = content;
      
      else
      
          contentString = JsonConvert.SerializeObject(content);
      

      using (var writer = new StreamWriter(request.GetRequestStream()))
      
          writer.Write(contentString);
      
  

  string idempotency_key = string.Empty;

  request.Headers.Add("Authorization", "Basic " + token);

  if (method.ToUpper() == "POST" || method.ToUpper() == "PUT")
  
      idempotency_key = Guid.NewGuid().ToString();
      request.Headers.Add("Idempotency-Key", idempotency_key);
      request.ContentType = "application/x-www-form-urlencoded";
  

  var settings = new JsonSerializerSettings
  
      PreserveReferencesHandling = PreserveReferencesHandling.Objects,
      Converters =  new JsonExtractor.StringOrArrayConverter() ,
      Error = (sender, args) =>
      
          if (System.Diagnostics.Debugger.IsAttached)
          
              System.Diagnostics.Debug.Write(args.CurrentObject.ToString());
              System.Diagnostics.Debugger.Break();
          
      
  ;

  try
  
      var response = (HttpWebResponse)request.GetResponse();

      if (request.Method.ToUpper() == "DELETE" && response.StatusCode.ToString() == "NoContent")
      
          result = JsonConvert.DeserializeObject<T>("true", settings);
      
      else
      
          using (var reader = new StreamReader(response.GetResponseStream()))
          
              var responseContent = reader.ReadToEnd();
              try
              
                  result = JsonConvert.DeserializeObject<T>(responseContent, settings);
              
              catch (Exception ex)
              
                  _tools.SendEmail(_tools.GetConfigKey("AppConfig", "EmailFrom"), _tools.GetConfigKey("AppConfig", "ITSupport"), "Payway Error in DeserializeObject", ex.ToString(), _tools.GetConfigKey("AppConfig", "EmailCCList"));
                  throw new Exception(ex.ToString());
              

              request = null;
              return result;
          
      
  
  catch (WebException webException)
  

      if (webException.Response != null)
      
          using (var reader = new StreamReader(webException.Response.GetResponseStream()))
          
              var responseContent = reader.ReadToEnd();
              _tools.SendEmail(_tools.GetConfigKey("AppConfig", "EmailFrom"), _tools.GetConfigKey("AppConfig", "ITSupport"), "Payway Web Response Content String", responseContent, _tools.GetConfigKey("AppConfig", "EmailCCList"));

              PaywayError err = new PaywayError();

              if (!string.IsNullOrWhiteSpace(responseContent))
              
                  err = JsonConvert.DeserializeObject<PaywayError>(responseContent, settings);
                  if (err != null)
                  
                      errorDesc += err.message + "<br >";
                      foreach (var error in err.data)
                      
                          errorDesc += error.message + "<br >";
                      

                      _tools.SendEmail(_tools.GetConfigKey("AppConfig", "EmailFrom"), _tools.GetConfigKey("AppConfig", "ITSupport"), "Payway Web Response Error description", errorDesc, _tools.GetConfigKey("AppConfig", "EmailCCList"), null, true);

                      throw new Exception(errorDesc);
                  
              
              else
              
                  throw new Exception(webException.ToString());
              
          
      
      else
      
          //Tools.SendEmail(Tools.GetConfigKey("EmailFrom"), Tools.GetConfigKey("ITSupport"), "CSP Response Content Inner Exception", webException.ToString(), Tools.GetConfigKey("EmailCCList"));
          if (webException.Message != null && webException.InnerException != null)
          
              errorDesc = webException.Message + "<br>" + webException.InnerException.ToString();
          
          else
          
              errorDesc = webException.ToString();
          

          _tools.SendEmail(_tools.GetConfigKey("AppConfig", "EmailFrom"), _tools.GetConfigKey("AppConfig", "ITSupport"), "Payway Web Response NULL, Error description", errorDesc, _tools.GetConfigKey("AppConfig", "EmailCCList"), null, true);

          throw new Exception(errorDesc);
      

  
  catch (Exception ex)
  
      errorDesc = ex.ToString();
      _tools.SendEmail(_tools.GetConfigKey("AppConfig", "EmailFrom"), _tools.GetConfigKey("AppConfig", "ITSupport"), "Payway Web Response NULL, Error description", errorDesc, _tools.GetConfigKey("AppConfig", "EmailCCList"), null, true);
      throw new Exception(errorDesc);
  

  return result;

text连接到远程计算机(代码片段)

查看详情

textangular的付费频道(代码片段)

查看详情

text在gcp上连接到vm(代码片段)

查看详情

text工作-如何连接到打印机-教程(代码片段)

查看详情

text连接到没有dbcontext的数据库(代码片段)

查看详情

text使用flask_sqlalchemy连接到azuresql(代码片段)

查看详情

text无法连接到主机127.0.0.1,或请求超时。(代码片段)

查看详情

text如何允许远程连接到本地开发postgresql服务器?(代码片段)

查看详情

text在ssh连接到另一台机器时更改iterm2配置文件(即:背景颜色)(代码片段)

查看详情

为啥 TIdIRC 不能连接到频道?有没有更好的组件?

】为啥TIdIRC不能连接到频道?有没有更好的组件?【英文标题】:Whywon\'tTIdIRCconnecttochannel?Isthereabettercomponent?为什么TIdIRC不能连接到频道?有没有更好的组件?【发布时间】:2012-05-2103:19:38【问题描述】:我一直在为Google的垃圾... 查看详情

将 Colab 连接到付费 TPU

】将Colab连接到付费TPU【英文标题】:ConnectColabtopaidTPU【发布时间】:2020-05-0421:01:39【问题描述】:我想(从免费TPU升级)。我使用本指南创建了一个JSON密钥:https://cloud.google.com/docs/authentication/production#auth-cloud-explicit-python,然... 查看详情

windows错误10061-django频道(代码片段)

在某些Windows10计算机中使用Django频道时出现问题。基本上我无法连接到套接字[错误10061]和python给我一个错误ERROR-server-Exceptioninsideapplication:Multipleexceptions:[Errno10061]Connectcallfailed('::1',6379),[Errno10061]Connectcallfailed('12 查看详情

(Discord.js) 如何让所有成员连接到某个类别的语音频道?

】(Discord.js)如何让所有成员连接到某个类别的语音频道?【英文标题】:(Discord.js)Howdoigetallthemembersconnectedtothevoicechannelsofacategory?【发布时间】:2019-10-2711:24:02【问题描述】:所以,我正在制作一个名为“movedebat”的命令,将所... 查看详情

如何连接到 solana discord 开发者频道?

】如何连接到solanadiscord开发者频道?【英文标题】:Howtoconnecttosolanadiscorddeveloperchannel?【发布时间】:2021-11-1714:05:18【问题描述】:我想问一下有关solana网络的问题。所以,我检查了https://docs.solana.com/。有不和谐频道邀请链接。... 查看详情

IRC Bot 未连接到频道

】IRCBot未连接到频道【英文标题】:IRCBotnotconnectingtothechannel【发布时间】:2013-11-0707:50:42【问题描述】:我正在关注这个网站上的教程:http://wiki.shellium.org/w/Writing_an_IRC_bot_in_Python当我在Ubuntu中打开终端并运行screenpythonircbot.py时... 查看详情

Laravel Echo - 允许访客连接到出席频道

】LaravelEcho-允许访客连接到出席频道【英文标题】:LaravelEcho-Allowgueststoconnecttopresencechannel【发布时间】:2017-09-0614:21:30【问题描述】:我正在使用laravel-echo-server运行LaravelEcho来广播事件。我有一个用户计数器频道,它显示应用... 查看详情

text验证youtube频道,视频id(代码片段)

查看详情

text添加新货币到付费会员专业版(代码片段)

查看详情