PaymentInformation.py 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. import json
  4. from alipay.aop.api.constant.ParamConstants import *
  5. from alipay.aop.api.domain.PriceInformation import PriceInformation
  6. class PaymentInformation(object):
  7. def __init__(self):
  8. self._action = None
  9. self._amount = None
  10. self._request_no = None
  11. @property
  12. def action(self):
  13. return self._action
  14. @action.setter
  15. def action(self, value):
  16. self._action = value
  17. @property
  18. def amount(self):
  19. return self._amount
  20. @amount.setter
  21. def amount(self, value):
  22. if isinstance(value, PriceInformation):
  23. self._amount = value
  24. else:
  25. self._amount = PriceInformation.from_alipay_dict(value)
  26. @property
  27. def request_no(self):
  28. return self._request_no
  29. @request_no.setter
  30. def request_no(self, value):
  31. self._request_no = value
  32. def to_alipay_dict(self):
  33. params = dict()
  34. if self.action:
  35. if hasattr(self.action, 'to_alipay_dict'):
  36. params['action'] = self.action.to_alipay_dict()
  37. else:
  38. params['action'] = self.action
  39. if self.amount:
  40. if hasattr(self.amount, 'to_alipay_dict'):
  41. params['amount'] = self.amount.to_alipay_dict()
  42. else:
  43. params['amount'] = self.amount
  44. if self.request_no:
  45. if hasattr(self.request_no, 'to_alipay_dict'):
  46. params['request_no'] = self.request_no.to_alipay_dict()
  47. else:
  48. params['request_no'] = self.request_no
  49. return params
  50. @staticmethod
  51. def from_alipay_dict(d):
  52. if not d:
  53. return None
  54. o = PaymentInformation()
  55. if 'action' in d:
  56. o.action = d['action']
  57. if 'amount' in d:
  58. o.amount = d['amount']
  59. if 'request_no' in d:
  60. o.request_no = d['request_no']
  61. return o