F2FBiz.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. using Aop.Api;
  2. using BaseModel.Models;
  3. using System.Collections.Generic;
  4. namespace WayneCloud.PaymentProcessors.Alipay.FromSDK
  5. {
  6. /// <summary>
  7. /// F2FBiz 的摘要说明
  8. /// </summary>
  9. public class F2FBiz
  10. {
  11. private F2FBiz() { }
  12. private static volatile IAopClient client;
  13. private static volatile Dictionary<AliPayConfig, IAopClient> clients = new Dictionary<AliPayConfig, IAopClient>();
  14. public static IAopClient Clients(AliPayConfig config)
  15. {
  16. if (config != null)
  17. {
  18. if (client == null)
  19. {
  20. client = new DefaultAopClient(config.serverUrl,
  21. config.appId,
  22. config.merchant_private_key,
  23. "json",
  24. config.version,
  25. config.sign_type,
  26. config.alipay_public_key,
  27. config.charset);
  28. }
  29. return client;
  30. }
  31. if (config != null)
  32. {
  33. var newClient = new DefaultAopClient(config.serverUrl,
  34. config.appId,
  35. config.merchant_private_key,
  36. "json",
  37. config.version,
  38. config.sign_type,
  39. config.alipay_public_key,
  40. config.charset);
  41. clients.Add(config, newClient);
  42. return newClient;
  43. }
  44. else
  45. {
  46. return clients[config];
  47. }
  48. }
  49. public static IAopClient GetAopClient(AliPayConfig config)
  50. {
  51. return Clients(config);
  52. }
  53. }
  54. }