WxPay.Notify.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. class WxPayNotify extends WxPayNotifyReply
  3. {
  4. final public function Handle($needSign = true)
  5. {
  6. $msg = 'OK';
  7. $result = WxpayApi::notify(array($this, 'NotifyCallBack'), $msg);
  8. if ($result == false) {
  9. $this->SetReturn_code('FAIL');
  10. $this->SetReturn_msg($msg);
  11. $this->ReplyNotify(false);
  12. return NULL;
  13. }
  14. else {
  15. $this->SetReturn_code('SUCCESS');
  16. $this->SetReturn_msg('OK');
  17. }
  18. $this->ReplyNotify($needSign);
  19. }
  20. public function NotifyProcess($data, &$msg)
  21. {
  22. return true;
  23. }
  24. final public function NotifyCallBack($data)
  25. {
  26. $msg = 'OK';
  27. $result = $this->NotifyProcess($data, $msg);
  28. if ($result == true) {
  29. $this->SetReturn_code('SUCCESS');
  30. $this->SetReturn_msg('OK');
  31. }
  32. else {
  33. $this->SetReturn_code('FAIL');
  34. $this->SetReturn_msg($msg);
  35. }
  36. return $result;
  37. }
  38. final private function ReplyNotify($needSign = true)
  39. {
  40. if ($needSign == true && $this->GetReturn_code($return_code) == 'SUCCESS') {
  41. $this->SetSign();
  42. }
  43. WxpayApi::replyNotify($this->ToXml());
  44. }
  45. }
  46. ?>