RefillCallBack.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace refill\feimingyu;
  3. require_once(BASE_HELPER_RAPI_PATH . '/feimingyu/config.php');
  4. use refill;
  5. class RefillCallBack implements refill\IRefillCallBack
  6. {
  7. public function verify($params): bool
  8. {
  9. $input = $params;
  10. unset($input['sign']);
  11. $sign = config::sign($input);
  12. if ($params['sign'] == $sign) {
  13. return true;
  14. } else {
  15. return false;
  16. }
  17. }
  18. public function notify($params)
  19. {
  20. $status = $params['orderStatus'];
  21. $order_sn = $params['applyNo'];
  22. $order_info = Model('vr_order')->getOrderInfoForNotify(['order_sn' => $order_sn]);
  23. if (empty($order_info)) {
  24. return [false, false, false, false, ''];
  25. }
  26. $order_id = $order_info['order_id'];
  27. if ($status === 'SUCCESS') {
  28. $official_sn = strtolower($params['ext1']) == 'null' ? '' : $params['ext1'];
  29. $data['official_sn'] = $official_sn;
  30. Model('refill_order')->edit($order_id, $data);
  31. return [$order_id, true, false, true, $official_sn];
  32. } elseif ($status === 'FAILED') {
  33. return [$order_id, false, true, true, ''];
  34. } else {
  35. return [$order_id, false, false, false, ''];
  36. }
  37. }
  38. }