AlipayTradeAppPayModel.py 16 KB

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