ShuiyifuPayment.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Administrator
  5. * Date: 2019/3/1
  6. * Time: 16:14
  7. */
  8. namespace Biz\Pay\Payment;
  9. use Biz\Pay\NewBasePayment;
  10. class ShuiyifuPayment extends NewBasePayment
  11. {
  12. private $paySign = false;
  13. /**
  14. * 接收通知
  15. * @param array $data
  16. * @return void
  17. */
  18. function notify(array $data)
  19. {
  20. $arr['orderid'] = trim(strip_tags($data['orderid']));
  21. $arr['opstate'] = trim(strip_tags($data['opstate']));
  22. $arr['ovalue'] = trim(strip_tags($data['ovalue']));
  23. $arr['systime'] = trim(strip_tags($data['systime']));
  24. $arr['sign'] = trim(strip_tags($data['sign']));
  25. $arr['type'] = trim(strip_tags($data['type']));
  26. $arr['sysorderid'] = trim(strip_tags($data['sysorderid']));
  27. $arr['completiontime'] = trim(strip_tags($data['completiontime']));
  28. $arr['attach'] = trim(strip_tags($data['attach']));
  29. $arr['msg'] = trim(strip_tags($data['msg']));
  30. $order_no = $arr['orderid'];
  31. $price = $arr['ovalue']; //支付价格
  32. $bill_no = $arr['sysorderid']; //内部订单号
  33. $sign = trim(strip_tags($data['sign']));
  34. $this->checkSign($arr, $sign, $order_no, $price, $real_price = 0, $is_bill_no = 0, $bill_no);
  35. }
  36. /**
  37. * 返回跳转
  38. * @param array $data
  39. * @return void [type] [description]
  40. */
  41. function redirect(array $data)
  42. {
  43. // TODO: Implement redirect() method.
  44. }
  45. /**
  46. * 检查支付信息
  47. * @return void [type] 0=失败,1=成功
  48. */
  49. function check()
  50. {
  51. // TODO: Implement check() method.
  52. }
  53. /**
  54. * 构建订单提交数组
  55. * @return array
  56. */
  57. function buildOrder(): array
  58. {
  59. $orderInfo = [
  60. 'parter' => $this->paymentConfig['merchant_id'],
  61. 'value' => $this->dataAccess->money,
  62. 'orderid' => $this->dataAccess->orderSn,
  63. 'type' => $this->dataAccess->payType,
  64. 'attach' => $this->dataAccess->extra ?? 'testGoods',
  65. 'callbackurl' => $this->notifyUrl,
  66. 'hrefbackurl' => $this->redirectUrl,
  67. ];
  68. $this->paySign = true;
  69. $sign = $this->buildSign($orderInfo, $this->paymentConfig['merchant_md5_secret']);
  70. $orderInfo['sign'] = $sign;
  71. return $orderInfo;
  72. }
  73. /**
  74. * 生成签名函数
  75. * @param array $param
  76. * @param string $merchantSecret
  77. * @return mixed
  78. */
  79. function buildSign(array $param, $merchantSecret)
  80. {
  81. $signValue = "orderid={$param['orderid']}&opstate={$param['opstate']}&ovalue={$param['ovalue']}{$merchantSecret}";//异步签名串
  82. $signStr = "parter={$param['parter']}&type={$param['type']}&value={$param['value']}&orderid={$param['orderid']}&callbackurl={$param['callbackurl']}{$merchantSecret}";
  83. return $this->paySign ? md5($signStr) : md5($signValue);
  84. }
  85. /**
  86. * 基础配置
  87. * @return void
  88. */
  89. function config()
  90. {
  91. $this->apiUrl = 'https://gateway.easyipay.com/interface/AutoBank/index.aspx';
  92. $this->success = 'opstate=0';
  93. }
  94. /**
  95. * 设置返回类型
  96. * @param string $type
  97. */
  98. function setReturnType($type = 'HTML')
  99. {
  100. // TODO: Implement setReturnType() method.
  101. }
  102. /**
  103. * 发起支付函数
  104. * @return mixed
  105. */
  106. function goPay()
  107. {
  108. $this->debug = 0;
  109. $this->method = "POST";
  110. $this->prePay();
  111. }
  112. }