AlipayTradePayModel.py 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579
  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.AgreementParams import AgreementParams
  6. from alipay.aop.api.domain.BusinessParams import BusinessParams
  7. from alipay.aop.api.domain.ExtUserInfo import ExtUserInfo
  8. from alipay.aop.api.domain.ExtendParams import ExtendParams
  9. from alipay.aop.api.domain.GoodsDetail import GoodsDetail
  10. from alipay.aop.api.domain.PromoParam import PromoParam
  11. from alipay.aop.api.domain.RoyaltyInfo import RoyaltyInfo
  12. from alipay.aop.api.domain.SettleInfo import SettleInfo
  13. from alipay.aop.api.domain.SubMerchant import SubMerchant
  14. class AlipayTradePayModel(object):
  15. def __init__(self):
  16. self._advance_payment_type = None
  17. self._agreement_params = None
  18. self._alipay_store_id = None
  19. self._auth_code = None
  20. self._auth_confirm_mode = None
  21. self._auth_no = None
  22. self._body = None
  23. self._business_params = None
  24. self._buyer_id = None
  25. self._disable_pay_channels = None
  26. self._discountable_amount = None
  27. self._ext_user_info = None
  28. self._extend_params = None
  29. self._goods_detail = None
  30. self._is_async_pay = None
  31. self._merchant_order_no = None
  32. self._operator_id = None
  33. self._out_trade_no = None
  34. self._product_code = None
  35. self._promo_params = None
  36. self._royalty_info = None
  37. self._scene = None
  38. self._seller_id = None
  39. self._settle_currency = None
  40. self._settle_info = None
  41. self._store_id = None
  42. self._sub_merchant = None
  43. self._subject = None
  44. self._terminal_id = None
  45. self._terminal_params = None
  46. self._timeout_express = None
  47. self._total_amount = None
  48. self._trans_currency = None
  49. self._undiscountable_amount = None
  50. @property
  51. def advance_payment_type(self):
  52. return self._advance_payment_type
  53. @advance_payment_type.setter
  54. def advance_payment_type(self, value):
  55. self._advance_payment_type = value
  56. @property
  57. def agreement_params(self):
  58. return self._agreement_params
  59. @agreement_params.setter
  60. def agreement_params(self, value):
  61. if isinstance(value, AgreementParams):
  62. self._agreement_params = value
  63. else:
  64. self._agreement_params = AgreementParams.from_alipay_dict(value)
  65. @property
  66. def alipay_store_id(self):
  67. return self._alipay_store_id
  68. @alipay_store_id.setter
  69. def alipay_store_id(self, value):
  70. self._alipay_store_id = value
  71. @property
  72. def auth_code(self):
  73. return self._auth_code
  74. @auth_code.setter
  75. def auth_code(self, value):
  76. self._auth_code = value
  77. @property
  78. def auth_confirm_mode(self):
  79. return self._auth_confirm_mode
  80. @auth_confirm_mode.setter
  81. def auth_confirm_mode(self, value):
  82. self._auth_confirm_mode = value
  83. @property
  84. def auth_no(self):
  85. return self._auth_no
  86. @auth_no.setter
  87. def auth_no(self, value):
  88. self._auth_no = value
  89. @property
  90. def body(self):
  91. return self._body
  92. @body.setter
  93. def body(self, value):
  94. self._body = value
  95. @property
  96. def business_params(self):
  97. return self._business_params
  98. @business_params.setter
  99. def business_params(self, value):
  100. if isinstance(value, BusinessParams):
  101. self._business_params = value
  102. else:
  103. self._business_params = BusinessParams.from_alipay_dict(value)
  104. @property
  105. def buyer_id(self):
  106. return self._buyer_id
  107. @buyer_id.setter
  108. def buyer_id(self, value):
  109. self._buyer_id = value
  110. @property
  111. def disable_pay_channels(self):
  112. return self._disable_pay_channels
  113. @disable_pay_channels.setter
  114. def disable_pay_channels(self, value):
  115. self._disable_pay_channels = value
  116. @property
  117. def discountable_amount(self):
  118. return self._discountable_amount
  119. @discountable_amount.setter
  120. def discountable_amount(self, value):
  121. self._discountable_amount = value
  122. @property
  123. def ext_user_info(self):
  124. return self._ext_user_info
  125. @ext_user_info.setter
  126. def ext_user_info(self, value):
  127. if isinstance(value, ExtUserInfo):
  128. self._ext_user_info = value
  129. else:
  130. self._ext_user_info = ExtUserInfo.from_alipay_dict(value)
  131. @property
  132. def extend_params(self):
  133. return self._extend_params
  134. @extend_params.setter
  135. def extend_params(self, value):
  136. if isinstance(value, ExtendParams):
  137. self._extend_params = value
  138. else:
  139. self._extend_params = ExtendParams.from_alipay_dict(value)
  140. @property
  141. def goods_detail(self):
  142. return self._goods_detail
  143. @goods_detail.setter
  144. def goods_detail(self, value):
  145. if isinstance(value, list):
  146. self._goods_detail = list()
  147. for i in value:
  148. if isinstance(i, GoodsDetail):
  149. self._goods_detail.append(i)
  150. else:
  151. self._goods_detail.append(GoodsDetail.from_alipay_dict(i))
  152. @property
  153. def is_async_pay(self):
  154. return self._is_async_pay
  155. @is_async_pay.setter
  156. def is_async_pay(self, value):
  157. self._is_async_pay = value
  158. @property
  159. def merchant_order_no(self):
  160. return self._merchant_order_no
  161. @merchant_order_no.setter
  162. def merchant_order_no(self, value):
  163. self._merchant_order_no = value
  164. @property
  165. def operator_id(self):
  166. return self._operator_id
  167. @operator_id.setter
  168. def operator_id(self, value):
  169. self._operator_id = value
  170. @property
  171. def out_trade_no(self):
  172. return self._out_trade_no
  173. @out_trade_no.setter
  174. def out_trade_no(self, value):
  175. self._out_trade_no = value
  176. @property
  177. def product_code(self):
  178. return self._product_code
  179. @product_code.setter
  180. def product_code(self, value):
  181. self._product_code = value
  182. @property
  183. def promo_params(self):
  184. return self._promo_params
  185. @promo_params.setter
  186. def promo_params(self, value):
  187. if isinstance(value, PromoParam):
  188. self._promo_params = value
  189. else:
  190. self._promo_params = PromoParam.from_alipay_dict(value)
  191. @property
  192. def royalty_info(self):
  193. return self._royalty_info
  194. @royalty_info.setter
  195. def royalty_info(self, value):
  196. if isinstance(value, RoyaltyInfo):
  197. self._royalty_info = value
  198. else:
  199. self._royalty_info = RoyaltyInfo.from_alipay_dict(value)
  200. @property
  201. def scene(self):
  202. return self._scene
  203. @scene.setter
  204. def scene(self, value):
  205. self._scene = value
  206. @property
  207. def seller_id(self):
  208. return self._seller_id
  209. @seller_id.setter
  210. def seller_id(self, value):
  211. self._seller_id = value
  212. @property
  213. def settle_currency(self):
  214. return self._settle_currency
  215. @settle_currency.setter
  216. def settle_currency(self, value):
  217. self._settle_currency = value
  218. @property
  219. def settle_info(self):
  220. return self._settle_info
  221. @settle_info.setter
  222. def settle_info(self, value):
  223. if isinstance(value, SettleInfo):
  224. self._settle_info = value
  225. else:
  226. self._settle_info = SettleInfo.from_alipay_dict(value)
  227. @property
  228. def store_id(self):
  229. return self._store_id
  230. @store_id.setter
  231. def store_id(self, value):
  232. self._store_id = value
  233. @property
  234. def sub_merchant(self):
  235. return self._sub_merchant
  236. @sub_merchant.setter
  237. def sub_merchant(self, value):
  238. if isinstance(value, SubMerchant):
  239. self._sub_merchant = value
  240. else:
  241. self._sub_merchant = SubMerchant.from_alipay_dict(value)
  242. @property
  243. def subject(self):
  244. return self._subject
  245. @subject.setter
  246. def subject(self, value):
  247. self._subject = value
  248. @property
  249. def terminal_id(self):
  250. return self._terminal_id
  251. @terminal_id.setter
  252. def terminal_id(self, value):
  253. self._terminal_id = value
  254. @property
  255. def terminal_params(self):
  256. return self._terminal_params
  257. @terminal_params.setter
  258. def terminal_params(self, value):
  259. self._terminal_params = value
  260. @property
  261. def timeout_express(self):
  262. return self._timeout_express
  263. @timeout_express.setter
  264. def timeout_express(self, value):
  265. self._timeout_express = value
  266. @property
  267. def total_amount(self):
  268. return self._total_amount
  269. @total_amount.setter
  270. def total_amount(self, value):
  271. self._total_amount = value
  272. @property
  273. def trans_currency(self):
  274. return self._trans_currency
  275. @trans_currency.setter
  276. def trans_currency(self, value):
  277. self._trans_currency = value
  278. @property
  279. def undiscountable_amount(self):
  280. return self._undiscountable_amount
  281. @undiscountable_amount.setter
  282. def undiscountable_amount(self, value):
  283. self._undiscountable_amount = value
  284. def to_alipay_dict(self):
  285. params = dict()
  286. if self.advance_payment_type:
  287. if hasattr(self.advance_payment_type, 'to_alipay_dict'):
  288. params['advance_payment_type'] = self.advance_payment_type.to_alipay_dict()
  289. else:
  290. params['advance_payment_type'] = self.advance_payment_type
  291. if self.agreement_params:
  292. if hasattr(self.agreement_params, 'to_alipay_dict'):
  293. params['agreement_params'] = self.agreement_params.to_alipay_dict()
  294. else:
  295. params['agreement_params'] = self.agreement_params
  296. if self.alipay_store_id:
  297. if hasattr(self.alipay_store_id, 'to_alipay_dict'):
  298. params['alipay_store_id'] = self.alipay_store_id.to_alipay_dict()
  299. else:
  300. params['alipay_store_id'] = self.alipay_store_id
  301. if self.auth_code:
  302. if hasattr(self.auth_code, 'to_alipay_dict'):
  303. params['auth_code'] = self.auth_code.to_alipay_dict()
  304. else:
  305. params['auth_code'] = self.auth_code
  306. if self.auth_confirm_mode:
  307. if hasattr(self.auth_confirm_mode, 'to_alipay_dict'):
  308. params['auth_confirm_mode'] = self.auth_confirm_mode.to_alipay_dict()
  309. else:
  310. params['auth_confirm_mode'] = self.auth_confirm_mode
  311. if self.auth_no:
  312. if hasattr(self.auth_no, 'to_alipay_dict'):
  313. params['auth_no'] = self.auth_no.to_alipay_dict()
  314. else:
  315. params['auth_no'] = self.auth_no
  316. if self.body:
  317. if hasattr(self.body, 'to_alipay_dict'):
  318. params['body'] = self.body.to_alipay_dict()
  319. else:
  320. params['body'] = self.body
  321. if self.business_params:
  322. if hasattr(self.business_params, 'to_alipay_dict'):
  323. params['business_params'] = self.business_params.to_alipay_dict()
  324. else:
  325. params['business_params'] = self.business_params
  326. if self.buyer_id:
  327. if hasattr(self.buyer_id, 'to_alipay_dict'):
  328. params['buyer_id'] = self.buyer_id.to_alipay_dict()
  329. else:
  330. params['buyer_id'] = self.buyer_id
  331. if self.disable_pay_channels:
  332. if hasattr(self.disable_pay_channels, 'to_alipay_dict'):
  333. params['disable_pay_channels'] = self.disable_pay_channels.to_alipay_dict()
  334. else:
  335. params['disable_pay_channels'] = self.disable_pay_channels
  336. if self.discountable_amount:
  337. if hasattr(self.discountable_amount, 'to_alipay_dict'):
  338. params['discountable_amount'] = self.discountable_amount.to_alipay_dict()
  339. else:
  340. params['discountable_amount'] = self.discountable_amount
  341. if self.ext_user_info:
  342. if hasattr(self.ext_user_info, 'to_alipay_dict'):
  343. params['ext_user_info'] = self.ext_user_info.to_alipay_dict()
  344. else:
  345. params['ext_user_info'] = self.ext_user_info
  346. if self.extend_params:
  347. if hasattr(self.extend_params, 'to_alipay_dict'):
  348. params['extend_params'] = self.extend_params.to_alipay_dict()
  349. else:
  350. params['extend_params'] = self.extend_params
  351. if self.goods_detail:
  352. if isinstance(self.goods_detail, list):
  353. for i in range(0, len(self.goods_detail)):
  354. element = self.goods_detail[i]
  355. if hasattr(element, 'to_alipay_dict'):
  356. self.goods_detail[i] = element.to_alipay_dict()
  357. if hasattr(self.goods_detail, 'to_alipay_dict'):
  358. params['goods_detail'] = self.goods_detail.to_alipay_dict()
  359. else:
  360. params['goods_detail'] = self.goods_detail
  361. if self.is_async_pay:
  362. if hasattr(self.is_async_pay, 'to_alipay_dict'):
  363. params['is_async_pay'] = self.is_async_pay.to_alipay_dict()
  364. else:
  365. params['is_async_pay'] = self.is_async_pay
  366. if self.merchant_order_no:
  367. if hasattr(self.merchant_order_no, 'to_alipay_dict'):
  368. params['merchant_order_no'] = self.merchant_order_no.to_alipay_dict()
  369. else:
  370. params['merchant_order_no'] = self.merchant_order_no
  371. if self.operator_id:
  372. if hasattr(self.operator_id, 'to_alipay_dict'):
  373. params['operator_id'] = self.operator_id.to_alipay_dict()
  374. else:
  375. params['operator_id'] = self.operator_id
  376. if self.out_trade_no:
  377. if hasattr(self.out_trade_no, 'to_alipay_dict'):
  378. params['out_trade_no'] = self.out_trade_no.to_alipay_dict()
  379. else:
  380. params['out_trade_no'] = self.out_trade_no
  381. if self.product_code:
  382. if hasattr(self.product_code, 'to_alipay_dict'):
  383. params['product_code'] = self.product_code.to_alipay_dict()
  384. else:
  385. params['product_code'] = self.product_code
  386. if self.promo_params:
  387. if hasattr(self.promo_params, 'to_alipay_dict'):
  388. params['promo_params'] = self.promo_params.to_alipay_dict()
  389. else:
  390. params['promo_params'] = self.promo_params
  391. if self.royalty_info:
  392. if hasattr(self.royalty_info, 'to_alipay_dict'):
  393. params['royalty_info'] = self.royalty_info.to_alipay_dict()
  394. else:
  395. params['royalty_info'] = self.royalty_info
  396. if self.scene:
  397. if hasattr(self.scene, 'to_alipay_dict'):
  398. params['scene'] = self.scene.to_alipay_dict()
  399. else:
  400. params['scene'] = self.scene
  401. if self.seller_id:
  402. if hasattr(self.seller_id, 'to_alipay_dict'):
  403. params['seller_id'] = self.seller_id.to_alipay_dict()
  404. else:
  405. params['seller_id'] = self.seller_id
  406. if self.settle_currency:
  407. if hasattr(self.settle_currency, 'to_alipay_dict'):
  408. params['settle_currency'] = self.settle_currency.to_alipay_dict()
  409. else:
  410. params['settle_currency'] = self.settle_currency
  411. if self.settle_info:
  412. if hasattr(self.settle_info, 'to_alipay_dict'):
  413. params['settle_info'] = self.settle_info.to_alipay_dict()
  414. else:
  415. params['settle_info'] = self.settle_info
  416. if self.store_id:
  417. if hasattr(self.store_id, 'to_alipay_dict'):
  418. params['store_id'] = self.store_id.to_alipay_dict()
  419. else:
  420. params['store_id'] = self.store_id
  421. if self.sub_merchant:
  422. if hasattr(self.sub_merchant, 'to_alipay_dict'):
  423. params['sub_merchant'] = self.sub_merchant.to_alipay_dict()
  424. else:
  425. params['sub_merchant'] = self.sub_merchant
  426. if self.subject:
  427. if hasattr(self.subject, 'to_alipay_dict'):
  428. params['subject'] = self.subject.to_alipay_dict()
  429. else:
  430. params['subject'] = self.subject
  431. if self.terminal_id:
  432. if hasattr(self.terminal_id, 'to_alipay_dict'):
  433. params['terminal_id'] = self.terminal_id.to_alipay_dict()
  434. else:
  435. params['terminal_id'] = self.terminal_id
  436. if self.terminal_params:
  437. if hasattr(self.terminal_params, 'to_alipay_dict'):
  438. params['terminal_params'] = self.terminal_params.to_alipay_dict()
  439. else:
  440. params['terminal_params'] = self.terminal_params
  441. if self.timeout_express:
  442. if hasattr(self.timeout_express, 'to_alipay_dict'):
  443. params['timeout_express'] = self.timeout_express.to_alipay_dict()
  444. else:
  445. params['timeout_express'] = self.timeout_express
  446. if self.total_amount:
  447. if hasattr(self.total_amount, 'to_alipay_dict'):
  448. params['total_amount'] = self.total_amount.to_alipay_dict()
  449. else:
  450. params['total_amount'] = self.total_amount
  451. if self.trans_currency:
  452. if hasattr(self.trans_currency, 'to_alipay_dict'):
  453. params['trans_currency'] = self.trans_currency.to_alipay_dict()
  454. else:
  455. params['trans_currency'] = self.trans_currency
  456. if self.undiscountable_amount:
  457. if hasattr(self.undiscountable_amount, 'to_alipay_dict'):
  458. params['undiscountable_amount'] = self.undiscountable_amount.to_alipay_dict()
  459. else:
  460. params['undiscountable_amount'] = self.undiscountable_amount
  461. return params
  462. @staticmethod
  463. def from_alipay_dict(d):
  464. if not d:
  465. return None
  466. o = AlipayTradePayModel()
  467. if 'advance_payment_type' in d:
  468. o.advance_payment_type = d['advance_payment_type']
  469. if 'agreement_params' in d:
  470. o.agreement_params = d['agreement_params']
  471. if 'alipay_store_id' in d:
  472. o.alipay_store_id = d['alipay_store_id']
  473. if 'auth_code' in d:
  474. o.auth_code = d['auth_code']
  475. if 'auth_confirm_mode' in d:
  476. o.auth_confirm_mode = d['auth_confirm_mode']
  477. if 'auth_no' in d:
  478. o.auth_no = d['auth_no']
  479. if 'body' in d:
  480. o.body = d['body']
  481. if 'business_params' in d:
  482. o.business_params = d['business_params']
  483. if 'buyer_id' in d:
  484. o.buyer_id = d['buyer_id']
  485. if 'disable_pay_channels' in d:
  486. o.disable_pay_channels = d['disable_pay_channels']
  487. if 'discountable_amount' in d:
  488. o.discountable_amount = d['discountable_amount']
  489. if 'ext_user_info' in d:
  490. o.ext_user_info = d['ext_user_info']
  491. if 'extend_params' in d:
  492. o.extend_params = d['extend_params']
  493. if 'goods_detail' in d:
  494. o.goods_detail = d['goods_detail']
  495. if 'is_async_pay' in d:
  496. o.is_async_pay = d['is_async_pay']
  497. if 'merchant_order_no' in d:
  498. o.merchant_order_no = d['merchant_order_no']
  499. if 'operator_id' in d:
  500. o.operator_id = d['operator_id']
  501. if 'out_trade_no' in d:
  502. o.out_trade_no = d['out_trade_no']
  503. if 'product_code' in d:
  504. o.product_code = d['product_code']
  505. if 'promo_params' in d:
  506. o.promo_params = d['promo_params']
  507. if 'royalty_info' in d:
  508. o.royalty_info = d['royalty_info']
  509. if 'scene' in d:
  510. o.scene = d['scene']
  511. if 'seller_id' in d:
  512. o.seller_id = d['seller_id']
  513. if 'settle_currency' in d:
  514. o.settle_currency = d['settle_currency']
  515. if 'settle_info' in d:
  516. o.settle_info = d['settle_info']
  517. if 'store_id' in d:
  518. o.store_id = d['store_id']
  519. if 'sub_merchant' in d:
  520. o.sub_merchant = d['sub_merchant']
  521. if 'subject' in d:
  522. o.subject = d['subject']
  523. if 'terminal_id' in d:
  524. o.terminal_id = d['terminal_id']
  525. if 'terminal_params' in d:
  526. o.terminal_params = d['terminal_params']
  527. if 'timeout_express' in d:
  528. o.timeout_express = d['timeout_express']
  529. if 'total_amount' in d:
  530. o.total_amount = d['total_amount']
  531. if 'trans_currency' in d:
  532. o.trans_currency = d['trans_currency']
  533. if 'undiscountable_amount' in d:
  534. o.undiscountable_amount = d['undiscountable_amount']
  535. return o