Payment.cs 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Net.Http;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using SinochemCloudClient.Models;
  8. namespace SinochemCloudClient.Legacy
  9. {
  10. public class Payment : MessagingBase
  11. {
  12. private PaymentResponse response;
  13. public Payment(string url) : base(url)
  14. {
  15. }
  16. public override ResponseBase Response
  17. {
  18. get
  19. {
  20. return response;
  21. }
  22. }
  23. public override void SendRequest(RequestBase request)
  24. {
  25. PaymentRequest paymentRequest = request as PaymentRequest;
  26. if (paymentRequest == null)
  27. {
  28. throw new Exception("invalid request type, should be Type PaymentRequest");
  29. }
  30. HttpResponseMessage httpResponse = client.PostAsJsonAsync(url, paymentRequest).Result;
  31. httpResponse.EnsureSuccessStatusCode();
  32. response = httpResponse.Content.ReadAsAsync<PaymentResponse>().Result;
  33. }
  34. }
  35. }