暫無描述
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

AlipayTradePagePayContentBuilder.php 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <?php
  2. /* *
  3. * 功能:支付宝电脑网站支付(alipay.trade.page.pay)接口业务参数封装
  4. * 版本:2.0
  5. * 修改日期:2017-05-01
  6. * 说明:
  7. * 以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。
  8. */
  9. class AlipayTradePagePayContentBuilder
  10. {
  11. // 订单描述,可以对交易或商品进行一个详细地描述,比如填写"购买商品2件共15.00元"
  12. private $body;
  13. // 订单标题,粗略描述用户的支付目的。
  14. private $subject;
  15. // 商户订单号.
  16. private $outTradeNo;
  17. // (推荐使用,相对时间) 该笔订单允许的最晚付款时间,逾期将关闭交易。取值范围:1m~15d。m-分钟,h-小时,d-天,1c-当天(1c-当天的情况下,无论交易何时创建,都在0点关闭)。 该参数数值不接受小数点, 如 1.5h,可转换为 90m
  18. private $timeExpress;
  19. // 订单总金额,整形,此处单位为元,精确到小数点后2位,不能超过1亿元
  20. private $totalAmount;
  21. // 产品标示码,固定值:QUICK_WAP_PAY
  22. private $productCode;
  23. private $bizContentarr = array();
  24. private $bizContent = NULL;
  25. public function getBizContent()
  26. {
  27. if(!empty($this->bizContentarr)){
  28. $this->bizContent = json_encode($this->bizContentarr,JSON_UNESCAPED_UNICODE);
  29. }
  30. return $this->bizContent;
  31. }
  32. public function __construct($PayTerminal, $isMobile)
  33. {
  34. if (!empty($isMobile) && !empty($PayTerminal['mobile'])) {
  35. // 支付宝手机端支付调用
  36. $this->bizContentarr['product_code'] = "QUICK_WAP_WAY";
  37. } else if (!empty($PayTerminal['computer']) || !empty($PayTerminal[0])) {
  38. // 支付宝电脑端支付调用
  39. $this->bizContentarr['product_code'] = "FAST_INSTANT_TRADE_PAY";
  40. }
  41. }
  42. public function AlipayTradeWapPayContentBuilder()
  43. {
  44. $this->__construct();
  45. }
  46. public function getBody()
  47. {
  48. return $this->body;
  49. }
  50. public function setBody($body)
  51. {
  52. $this->body = $body;
  53. $this->bizContentarr['body'] = $body;
  54. }
  55. public function setSubject($subject)
  56. {
  57. $this->subject = $subject;
  58. $this->bizContentarr['subject'] = $subject;
  59. }
  60. public function getSubject()
  61. {
  62. return $this->subject;
  63. }
  64. public function getOutTradeNo()
  65. {
  66. return $this->outTradeNo;
  67. }
  68. public function setOutTradeNo($outTradeNo)
  69. {
  70. $this->outTradeNo = $outTradeNo;
  71. $this->bizContentarr['out_trade_no'] = $outTradeNo;
  72. }
  73. public function setTimeExpress($timeExpress)
  74. {
  75. $this->timeExpress = $timeExpress;
  76. $this->bizContentarr['timeout_express'] = $timeExpress;
  77. }
  78. public function getTimeExpress()
  79. {
  80. return $this->timeExpress;
  81. }
  82. public function setTotalAmount($totalAmount)
  83. {
  84. $this->totalAmount = $totalAmount;
  85. $this->bizContentarr['total_amount'] = $totalAmount;
  86. }
  87. public function getTotalAmount()
  88. {
  89. return $this->totalAmount;
  90. }
  91. }
  92. ?>