RefillCallBack.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace refill\shuoruan;
  3. require_once(BASE_HELPER_RAPI_PATH . '/shuoruan/config.php');
  4. use refill;
  5. class RefillCallBack implements refill\IRefillCallBack
  6. {
  7. public function verify($params): bool
  8. {
  9. $sign = $this->sign($params);
  10. if ($params['Sign'] == $sign) {
  11. return true;
  12. } else {
  13. return false;
  14. }
  15. }
  16. private function sign($params)
  17. {
  18. $key = config::KEY;
  19. $content = "Orderid={$params['Orderid']}&Chargeid={$params['Chargeid']}&Orderstatu_int={$params['Orderstatu_int']}&Errorcode={$params['Errorcode']}&Password={$key}";
  20. return md5($content);
  21. }
  22. public function notify($params)
  23. {
  24. $status = intval($params['Orderstatu_int']);
  25. $order_sn = $params['Orderid'];
  26. $order_info = Model('vr_order')->getOrderInfo(['order_sn' => $order_sn]);
  27. if (empty($order_info)) {
  28. return [false, false, false,false];
  29. }
  30. $order_id = $order_info['order_id'];
  31. if (in_array($status, [11, 16])) {
  32. return [$order_id, true, false,true];
  33. }
  34. elseif (in_array($status, [20, 21, 26])) {
  35. return [$order_id, false, true,true];
  36. }
  37. else {
  38. return [$order_id, false, false,false];
  39. }
  40. }
  41. }