ylsj.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. require_once dirname(__FILE__) . '/../../config_360.php';
  3. /**
  4. * Description of PayApp_ylsj
  5. * @version
  6. * 1.0.0 Created at 2018-3-3. by --gwang
  7. * @author gwang (mail@wanggangzero.cn)
  8. * @copyright ? 2018-3-3, SJZ LoyalSoft Corporation & gwang. All rights reserved.
  9. */
  10. class PayApp_ylsj implements PayApp_Interface
  11. {
  12. //需要修改为应用自身的app_key
  13. private $_appKey;
  14. //需要修改为应用自身的app_secret(服务器之间通讯使用)
  15. private $_appSecret;
  16. //人民币-游戏货币的兑换比例
  17. private $_cashRate = 10;
  18. public function __construct($appKey, $appSecret)
  19. {
  20. $this->_appKey = $appKey;
  21. $this->_appSecret = $appSecret;
  22. }
  23. public function getAppKey()
  24. {
  25. return $this->_appKey;
  26. }
  27. public function getAppSecret()
  28. {
  29. return $this->_appSecret;
  30. }
  31. public function isValidOrder(array $orderParams)
  32. {
  33. $order = $this->_getOrder($orderParams);
  34. if (empty($order)) {
  35. return false;
  36. }
  37. return $order->Check();
  38. }
  39. private function _getOrder($orderParams)
  40. {
  41. return \loyalsoft\pay\OrderNotice::Parse_360Order($orderParams);
  42. //应该根据360支付返回的订单号或者应用自身的订单号($order['app_order_id'])查询应用订单数据表
  43. }
  44. public function processOrder(array $orderParams)
  45. {
  46. $order = $this->_getOrder($orderParams);
  47. if (empty($order)) {
  48. return false;
  49. }
  50. return $order->UpdateOrderStatus();
  51. //更新订单,标识为已经处理,避免重复处理
  52. //如果更新订单状态失败,记录异常,以便再次处理。再次处理的逻辑需应用自己处理
  53. }
  54. }