AlipayTradePagePayModel.py 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470
  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.AgreementSignParams import AgreementSignParams
  6. from alipay.aop.api.domain.ExtUserInfo import ExtUserInfo
  7. from alipay.aop.api.domain.ExtendParams import ExtendParams
  8. from alipay.aop.api.domain.GoodsDetail import GoodsDetail
  9. from alipay.aop.api.domain.InvoiceInfo import InvoiceInfo
  10. from alipay.aop.api.domain.RoyaltyInfo import RoyaltyInfo
  11. from alipay.aop.api.domain.SettleInfo import SettleInfo
  12. from alipay.aop.api.domain.SubMerchant import SubMerchant
  13. class AlipayTradePagePayModel(object):
  14. def __init__(self):
  15. self._agreement_sign_params = None
  16. self._body = None
  17. self._business_params = None
  18. self._disable_pay_channels = None
  19. self._enable_pay_channels = None
  20. self._ext_user_info = None
  21. self._extend_params = None
  22. self._goods_detail = None
  23. self._goods_type = None
  24. self._integration_type = None
  25. self._invoice_info = None
  26. self._merchant_order_no = None
  27. self._out_trade_no = None
  28. self._passback_params = None
  29. self._product_code = None
  30. self._promo_params = None
  31. self._qr_pay_mode = None
  32. self._qrcode_width = None
  33. self._request_from_url = None
  34. self._royalty_info = None
  35. self._settle_info = None
  36. self._store_id = None
  37. self._sub_merchant = None
  38. self._subject = None
  39. self._time_expire = None
  40. self._timeout_express = None
  41. self._total_amount = None
  42. @property
  43. def agreement_sign_params(self):
  44. return self._agreement_sign_params
  45. @agreement_sign_params.setter
  46. def agreement_sign_params(self, value):
  47. if isinstance(value, AgreementSignParams):
  48. self._agreement_sign_params = value
  49. else:
  50. self._agreement_sign_params = AgreementSignParams.from_alipay_dict(value)
  51. @property
  52. def body(self):
  53. return self._body
  54. @body.setter
  55. def body(self, value):
  56. self._body = value
  57. @property
  58. def business_params(self):
  59. return self._business_params
  60. @business_params.setter
  61. def business_params(self, value):
  62. self._business_params = value
  63. @property
  64. def disable_pay_channels(self):
  65. return self._disable_pay_channels
  66. @disable_pay_channels.setter
  67. def disable_pay_channels(self, value):
  68. self._disable_pay_channels = value
  69. @property
  70. def enable_pay_channels(self):
  71. return self._enable_pay_channels
  72. @enable_pay_channels.setter
  73. def enable_pay_channels(self, value):
  74. self._enable_pay_channels = value
  75. @property
  76. def ext_user_info(self):
  77. return self._ext_user_info
  78. @ext_user_info.setter
  79. def ext_user_info(self, value):
  80. if isinstance(value, ExtUserInfo):
  81. self._ext_user_info = value
  82. else:
  83. self._ext_user_info = ExtUserInfo.from_alipay_dict(value)
  84. @property
  85. def extend_params(self):
  86. return self._extend_params
  87. @extend_params.setter
  88. def extend_params(self, value):
  89. if isinstance(value, ExtendParams):
  90. self._extend_params = value
  91. else:
  92. self._extend_params = ExtendParams.from_alipay_dict(value)
  93. @property
  94. def goods_detail(self):
  95. return self._goods_detail
  96. @goods_detail.setter
  97. def goods_detail(self, value):
  98. if isinstance(value, list):
  99. self._goods_detail = list()
  100. for i in value:
  101. if isinstance(i, GoodsDetail):
  102. self._goods_detail.append(i)
  103. else:
  104. self._goods_detail.append(GoodsDetail.from_alipay_dict(i))
  105. @property
  106. def goods_type(self):
  107. return self._goods_type
  108. @goods_type.setter
  109. def goods_type(self, value):
  110. self._goods_type = value
  111. @property
  112. def integration_type(self):
  113. return self._integration_type
  114. @integration_type.setter
  115. def integration_type(self, value):
  116. self._integration_type = value
  117. @property
  118. def invoice_info(self):
  119. return self._invoice_info
  120. @invoice_info.setter
  121. def invoice_info(self, value):
  122. if isinstance(value, InvoiceInfo):
  123. self._invoice_info = value
  124. else:
  125. self._invoice_info = InvoiceInfo.from_alipay_dict(value)
  126. @property
  127. def merchant_order_no(self):
  128. return self._merchant_order_no
  129. @merchant_order_no.setter
  130. def merchant_order_no(self, value):
  131. self._merchant_order_no = value
  132. @property
  133. def out_trade_no(self):
  134. return self._out_trade_no
  135. @out_trade_no.setter
  136. def out_trade_no(self, value):
  137. self._out_trade_no = value
  138. @property
  139. def passback_params(self):
  140. return self._passback_params
  141. @passback_params.setter
  142. def passback_params(self, value):
  143. self._passback_params = value
  144. @property
  145. def product_code(self):
  146. return self._product_code
  147. @product_code.setter
  148. def product_code(self, value):
  149. self._product_code = value
  150. @property
  151. def promo_params(self):
  152. return self._promo_params
  153. @promo_params.setter
  154. def promo_params(self, value):
  155. self._promo_params = value
  156. @property
  157. def qr_pay_mode(self):
  158. return self._qr_pay_mode
  159. @qr_pay_mode.setter
  160. def qr_pay_mode(self, value):
  161. self._qr_pay_mode = value
  162. @property
  163. def qrcode_width(self):
  164. return self._qrcode_width
  165. @qrcode_width.setter
  166. def qrcode_width(self, value):
  167. self._qrcode_width = value
  168. @property
  169. def request_from_url(self):
  170. return self._request_from_url
  171. @request_from_url.setter
  172. def request_from_url(self, value):
  173. self._request_from_url = value
  174. @property
  175. def royalty_info(self):
  176. return self._royalty_info
  177. @royalty_info.setter
  178. def royalty_info(self, value):
  179. if isinstance(value, RoyaltyInfo):
  180. self._royalty_info = value
  181. else:
  182. self._royalty_info = RoyaltyInfo.from_alipay_dict(value)
  183. @property
  184. def settle_info(self):
  185. return self._settle_info
  186. @settle_info.setter
  187. def settle_info(self, value):
  188. if isinstance(value, SettleInfo):
  189. self._settle_info = value
  190. else:
  191. self._settle_info = SettleInfo.from_alipay_dict(value)
  192. @property
  193. def store_id(self):
  194. return self._store_id
  195. @store_id.setter
  196. def store_id(self, value):
  197. self._store_id = value
  198. @property
  199. def sub_merchant(self):
  200. return self._sub_merchant
  201. @sub_merchant.setter
  202. def sub_merchant(self, value):
  203. if isinstance(value, SubMerchant):
  204. self._sub_merchant = value
  205. else:
  206. self._sub_merchant = SubMerchant.from_alipay_dict(value)
  207. @property
  208. def subject(self):
  209. return self._subject
  210. @subject.setter
  211. def subject(self, value):
  212. self._subject = value
  213. @property
  214. def time_expire(self):
  215. return self._time_expire
  216. @time_expire.setter
  217. def time_expire(self, value):
  218. self._time_expire = value
  219. @property
  220. def timeout_express(self):
  221. return self._timeout_express
  222. @timeout_express.setter
  223. def timeout_express(self, value):
  224. self._timeout_express = value
  225. @property
  226. def total_amount(self):
  227. return self._total_amount
  228. @total_amount.setter
  229. def total_amount(self, value):
  230. self._total_amount = value
  231. def to_alipay_dict(self):
  232. params = dict()
  233. if self.agreement_sign_params:
  234. if hasattr(self.agreement_sign_params, 'to_alipay_dict'):
  235. params['agreement_sign_params'] = self.agreement_sign_params.to_alipay_dict()
  236. else:
  237. params['agreement_sign_params'] = self.agreement_sign_params
  238. if self.body:
  239. if hasattr(self.body, 'to_alipay_dict'):
  240. params['body'] = self.body.to_alipay_dict()
  241. else:
  242. params['body'] = self.body
  243. if self.business_params:
  244. if hasattr(self.business_params, 'to_alipay_dict'):
  245. params['business_params'] = self.business_params.to_alipay_dict()
  246. else:
  247. params['business_params'] = self.business_params
  248. if self.disable_pay_channels:
  249. if hasattr(self.disable_pay_channels, 'to_alipay_dict'):
  250. params['disable_pay_channels'] = self.disable_pay_channels.to_alipay_dict()
  251. else:
  252. params['disable_pay_channels'] = self.disable_pay_channels
  253. if self.enable_pay_channels:
  254. if hasattr(self.enable_pay_channels, 'to_alipay_dict'):
  255. params['enable_pay_channels'] = self.enable_pay_channels.to_alipay_dict()
  256. else:
  257. params['enable_pay_channels'] = self.enable_pay_channels
  258. if self.ext_user_info:
  259. if hasattr(self.ext_user_info, 'to_alipay_dict'):
  260. params['ext_user_info'] = self.ext_user_info.to_alipay_dict()
  261. else:
  262. params['ext_user_info'] = self.ext_user_info
  263. if self.extend_params:
  264. if hasattr(self.extend_params, 'to_alipay_dict'):
  265. params['extend_params'] = self.extend_params.to_alipay_dict()
  266. else:
  267. params['extend_params'] = self.extend_params
  268. if self.goods_detail:
  269. if isinstance(self.goods_detail, list):
  270. for i in range(0, len(self.goods_detail)):
  271. element = self.goods_detail[i]
  272. if hasattr(element, 'to_alipay_dict'):
  273. self.goods_detail[i] = element.to_alipay_dict()
  274. if hasattr(self.goods_detail, 'to_alipay_dict'):
  275. params['goods_detail'] = self.goods_detail.to_alipay_dict()
  276. else:
  277. params['goods_detail'] = self.goods_detail
  278. if self.goods_type:
  279. if hasattr(self.goods_type, 'to_alipay_dict'):
  280. params['goods_type'] = self.goods_type.to_alipay_dict()
  281. else:
  282. params['goods_type'] = self.goods_type
  283. if self.integration_type:
  284. if hasattr(self.integration_type, 'to_alipay_dict'):
  285. params['integration_type'] = self.integration_type.to_alipay_dict()
  286. else:
  287. params['integration_type'] = self.integration_type
  288. if self.invoice_info:
  289. if hasattr(self.invoice_info, 'to_alipay_dict'):
  290. params['invoice_info'] = self.invoice_info.to_alipay_dict()
  291. else:
  292. params['invoice_info'] = self.invoice_info
  293. if self.merchant_order_no:
  294. if hasattr(self.merchant_order_no, 'to_alipay_dict'):
  295. params['merchant_order_no'] = self.merchant_order_no.to_alipay_dict()
  296. else:
  297. params['merchant_order_no'] = self.merchant_order_no
  298. if self.out_trade_no:
  299. if hasattr(self.out_trade_no, 'to_alipay_dict'):
  300. params['out_trade_no'] = self.out_trade_no.to_alipay_dict()
  301. else:
  302. params['out_trade_no'] = self.out_trade_no
  303. if self.passback_params:
  304. if hasattr(self.passback_params, 'to_alipay_dict'):
  305. params['passback_params'] = self.passback_params.to_alipay_dict()
  306. else:
  307. params['passback_params'] = self.passback_params
  308. if self.product_code:
  309. if hasattr(self.product_code, 'to_alipay_dict'):
  310. params['product_code'] = self.product_code.to_alipay_dict()
  311. else:
  312. params['product_code'] = self.product_code
  313. if self.promo_params:
  314. if hasattr(self.promo_params, 'to_alipay_dict'):
  315. params['promo_params'] = self.promo_params.to_alipay_dict()
  316. else:
  317. params['promo_params'] = self.promo_params
  318. if self.qr_pay_mode:
  319. if hasattr(self.qr_pay_mode, 'to_alipay_dict'):
  320. params['qr_pay_mode'] = self.qr_pay_mode.to_alipay_dict()
  321. else:
  322. params['qr_pay_mode'] = self.qr_pay_mode
  323. if self.qrcode_width:
  324. if hasattr(self.qrcode_width, 'to_alipay_dict'):
  325. params['qrcode_width'] = self.qrcode_width.to_alipay_dict()
  326. else:
  327. params['qrcode_width'] = self.qrcode_width
  328. if self.request_from_url:
  329. if hasattr(self.request_from_url, 'to_alipay_dict'):
  330. params['request_from_url'] = self.request_from_url.to_alipay_dict()
  331. else:
  332. params['request_from_url'] = self.request_from_url
  333. if self.royalty_info:
  334. if hasattr(self.royalty_info, 'to_alipay_dict'):
  335. params['royalty_info'] = self.royalty_info.to_alipay_dict()
  336. else:
  337. params['royalty_info'] = self.royalty_info
  338. if self.settle_info:
  339. if hasattr(self.settle_info, 'to_alipay_dict'):
  340. params['settle_info'] = self.settle_info.to_alipay_dict()
  341. else:
  342. params['settle_info'] = self.settle_info
  343. if self.store_id:
  344. if hasattr(self.store_id, 'to_alipay_dict'):
  345. params['store_id'] = self.store_id.to_alipay_dict()
  346. else:
  347. params['store_id'] = self.store_id
  348. if self.sub_merchant:
  349. if hasattr(self.sub_merchant, 'to_alipay_dict'):
  350. params['sub_merchant'] = self.sub_merchant.to_alipay_dict()
  351. else:
  352. params['sub_merchant'] = self.sub_merchant
  353. if self.subject:
  354. if hasattr(self.subject, 'to_alipay_dict'):
  355. params['subject'] = self.subject.to_alipay_dict()
  356. else:
  357. params['subject'] = self.subject
  358. if self.time_expire:
  359. if hasattr(self.time_expire, 'to_alipay_dict'):
  360. params['time_expire'] = self.time_expire.to_alipay_dict()
  361. else:
  362. params['time_expire'] = self.time_expire
  363. if self.timeout_express:
  364. if hasattr(self.timeout_express, 'to_alipay_dict'):
  365. params['timeout_express'] = self.timeout_express.to_alipay_dict()
  366. else:
  367. params['timeout_express'] = self.timeout_express
  368. if self.total_amount:
  369. if hasattr(self.total_amount, 'to_alipay_dict'):
  370. params['total_amount'] = self.total_amount.to_alipay_dict()
  371. else:
  372. params['total_amount'] = self.total_amount
  373. return params
  374. @staticmethod
  375. def from_alipay_dict(d):
  376. if not d:
  377. return None
  378. o = AlipayTradePagePayModel()
  379. if 'agreement_sign_params' in d:
  380. o.agreement_sign_params = d['agreement_sign_params']
  381. if 'body' in d:
  382. o.body = d['body']
  383. if 'business_params' in d:
  384. o.business_params = d['business_params']
  385. if 'disable_pay_channels' in d:
  386. o.disable_pay_channels = d['disable_pay_channels']
  387. if 'enable_pay_channels' in d:
  388. o.enable_pay_channels = d['enable_pay_channels']
  389. if 'ext_user_info' in d:
  390. o.ext_user_info = d['ext_user_info']
  391. if 'extend_params' in d:
  392. o.extend_params = d['extend_params']
  393. if 'goods_detail' in d:
  394. o.goods_detail = d['goods_detail']
  395. if 'goods_type' in d:
  396. o.goods_type = d['goods_type']
  397. if 'integration_type' in d:
  398. o.integration_type = d['integration_type']
  399. if 'invoice_info' in d:
  400. o.invoice_info = d['invoice_info']
  401. if 'merchant_order_no' in d:
  402. o.merchant_order_no = d['merchant_order_no']
  403. if 'out_trade_no' in d:
  404. o.out_trade_no = d['out_trade_no']
  405. if 'passback_params' in d:
  406. o.passback_params = d['passback_params']
  407. if 'product_code' in d:
  408. o.product_code = d['product_code']
  409. if 'promo_params' in d:
  410. o.promo_params = d['promo_params']
  411. if 'qr_pay_mode' in d:
  412. o.qr_pay_mode = d['qr_pay_mode']
  413. if 'qrcode_width' in d:
  414. o.qrcode_width = d['qrcode_width']
  415. if 'request_from_url' in d:
  416. o.request_from_url = d['request_from_url']
  417. if 'royalty_info' in d:
  418. o.royalty_info = d['royalty_info']
  419. if 'settle_info' in d:
  420. o.settle_info = d['settle_info']
  421. if 'store_id' in d:
  422. o.store_id = d['store_id']
  423. if 'sub_merchant' in d:
  424. o.sub_merchant = d['sub_merchant']
  425. if 'subject' in d:
  426. o.subject = d['subject']
  427. if 'time_expire' in d:
  428. o.time_expire = d['time_expire']
  429. if 'timeout_express' in d:
  430. o.timeout_express = d['timeout_express']
  431. if 'total_amount' in d:
  432. o.total_amount = d['total_amount']
  433. return o