UnifiedOrder.php 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. namespace Cmbc\Api;
  3. class UnifiedOrder extends Core
  4. {
  5. protected function init()
  6. {
  7. $this->api = 'https://ipaynow.acquire.cmbchina.com/';
  8. $this->param['funcode'] = 'WP001';
  9. $this->param['version'] = '1.0.0';
  10. }
  11. /**
  12. * mhtOrderNo 订单号
  13. * mhtOrderName 商品名
  14. * mhtOrderType 交易类型:01普通消费 05代理消费
  15. * mhtCurrencyType 156人民币
  16. * mhtOrderAmt 用户实付金额 单位(人民币):分 整数,无小数点
  17. * oriMhtOrderAmt 订单原始金额
  18. * discountAmt 订单优惠金额
  19. * mhtOrderDetail 商户订单详情
  20. * mhtOrderTimeOut 商户订单超时时间
  21. * mhtOrderStartTime 商户订单开始时间
  22. * notifyUrl 商户后台通知URL HTTP协议或者HTTPS协议,POST方式提交报文。
  23. * frontNotifyUrl 商户前台通知URL HTTP协议或者HTTPS协议,POST方式提交报文。outputType=0时必填
  24. * mhtCharset 商户字符编码
  25. * deviceType 设备类型 14小程序
  26. * payChannelType 用户所选渠道类型 13微信
  27. * mhtReserved 商户保留域
  28. * outputType 输出格式 0 直接调起支付 1 返回支付凭证
  29. * mhtSubAppId 商户appId
  30. * consumerId 消费者ID
  31. * mhtLimitPay 是否支持信用卡支付 定值:
  32. 0表示支付不限制卡类型
  33. 1表示不能使用信用卡支付
  34. * mhtGoodsTag 商户签名方法
  35. * mhtSignType 商户保留域
  36. */
  37. public function request($request, $tool = false)
  38. {
  39. $this->data = $request;
  40. $this->setParam('mhtOrderNo');
  41. $this->setParam('mhtOrderName');
  42. $this->setParam('mhtOrderType', '01');
  43. $this->setParam('mhtCurrencyType', '156');
  44. $this->setParam('mhtOrderAmt');
  45. $this->setParam('oriMhtOrderAmt', false, false);
  46. $this->setParam('discountAmt', false, false);
  47. if (!isset($this->param['oriMhtOrderAmt']) && isset($this->param['mhtOrderAmt'])) {
  48. $this->param['oriMhtOrderAmt'] = $this->param['mhtOrderAmt'];
  49. }
  50. if (!isset($this->param['discountAmt']) && isset($this->param['mhtOrderAmt'])) {
  51. $this->param['discountAmt'] = $this->param['mhtOrderAmt'];
  52. }
  53. $this->setParam('mhtOrderDetail');
  54. $this->setParam('mhtOrderTimeOut', $this->setting->getTimeOut());
  55. $this->setParam('mhtOrderStartTime', date("YmdHis"));
  56. $this->setParam('notifyUrl');
  57. $this->setParam('frontNotifyUrl', false, false);
  58. $this->setParam('mhtCharset', 'UTF-8');
  59. $this->setParam('deviceType', 14);
  60. $this->setParam('payChannelType', 13);
  61. $this->setParam('mhtReserved', false, false);
  62. $this->setParam('outputType', 0);
  63. if (isset($this->param['outputType']) && $this->param['outputType'] == 1 && $this->param['payChannelType'] == 13) {
  64. $this->setParam('mhtSubAppId');
  65. } else {
  66. $this->setParam('mhtSubAppId', false, false);
  67. }
  68. if (isset($this->param['outputType']) && $this->param['outputType'] == 1) {
  69. $this->setParam('consumerId');
  70. } else {
  71. $this->setParam('consumerId', false, false);
  72. }
  73. $this->setParam('mhtLimitPay', 1);
  74. $this->setParam('mhtGoodsTag', false, false);
  75. $this->setParam('mhtSignType', 'MD5');
  76. $error = $this->getError();
  77. if ($error) {
  78. return $error;
  79. }
  80. $this->param['mhtSignature'] = $this->createSignature($this->param['mhtSignType']);
  81. $response = $this->curl();
  82. return $this->response($response);
  83. }
  84. public function response($response)
  85. {
  86. return $response;
  87. }
  88. }