RefillCallBack.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. namespace refill\suhctm;
  3. use refill;
  4. class RefillCallBack implements refill\IRefillCallBack
  5. {
  6. public function verify($params): bool
  7. {
  8. $input = $params;
  9. unset($input['sign']);
  10. $sign = $this->sign($input);
  11. if ($params['sign'] == $sign) {
  12. return true;
  13. } else {
  14. return false;
  15. }
  16. }
  17. private function check_empty($value)
  18. {
  19. if (!isset($value))
  20. return true;
  21. if ($value === null)
  22. return true;
  23. if (trim($value) === "")
  24. return true;
  25. return false;
  26. }
  27. private function sign($params)
  28. {
  29. ksort($params);
  30. $body = "";
  31. $i = 0;
  32. foreach ($params as $k => $v) {
  33. if (false === $this->check_empty($v) && "@" != substr($v, 0, 1)) {
  34. if ($i == 0) {
  35. $body .= "{$k}" . "=" . urldecode($v);
  36. } else {
  37. $body .= "&" . "{$k}" . "=" . urldecode($v);
  38. }
  39. $i++;
  40. }
  41. }
  42. $body .= "&key=" . config::KEY;
  43. return md5($body);
  44. }
  45. public function notify($params)
  46. {
  47. $status = intval($params['status']);
  48. $order_sn = $params['onlystr'];
  49. $order_info = Model('vr_order')->getOrderInfo(['order_sn' => $order_sn]);
  50. if (empty($order_info)) {
  51. return [false, false, false,false];
  52. }
  53. $order_id = $order_info['order_id'];
  54. if ($status === 2) {
  55. return [$order_id, true, false,true];
  56. } else {
  57. //速汇充反馈此时可以提交多次.
  58. return [$order_id, false, true,true];
  59. }
  60. }
  61. }