RefillCallBack.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. namespace refill\weisanhuo;
  3. require_once(BASE_HELPER_RAPI_PATH . '/weisanhuo/config.php');
  4. use refill;
  5. class RefillCallBack implements refill\IRefillCallBack
  6. {
  7. public function verify($params): bool
  8. {
  9. $sign = config::sign($params, ['sign']);
  10. if ($params['sign'] == $sign) {
  11. return true;
  12. } else {
  13. return false;
  14. }
  15. }
  16. public function notify($params): array
  17. {
  18. $status = $params['status'];
  19. $order_sn = $params['outTradeNo'];
  20. $order_info = Model('vr_order')->getOrderInfoForNotify(['order_sn' => $order_sn]);
  21. if (empty($order_info)) {
  22. return [false, false, false, false, ''];
  23. }
  24. $order_id = $order_info['order_id'];
  25. if ($status == 'success') {
  26. $official_sn = $params['inTradeNo'];
  27. Model('refill_order')->edit($order_id, ['official_sn' => $official_sn, 'ch_trade_no' => $params['orderId']]);
  28. return [$order_id, true, false, true, $official_sn];
  29. } elseif ($status == 'failed') {
  30. return [$order_id, false, true, true, ''];
  31. } else {
  32. return [$order_id, false, false, false, ''];
  33. }
  34. }
  35. }