From ce13373ea2ea13de4b006abe58f7fdce9c62cb3d Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 2 Aug 2023 15:22:26 +0800 Subject: [PATCH] 1 --- webapp/controller/ShopController.class.php | 2 +- webapp/models/InAppOrder.php | 2 +- webapp/services/callback/InAppPurchase.php | 13 +++++++------ 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/webapp/controller/ShopController.class.php b/webapp/controller/ShopController.class.php index d8f124fe..77e830d7 100644 --- a/webapp/controller/ShopController.class.php +++ b/webapp/controller/ShopController.class.php @@ -247,7 +247,7 @@ class ShopController extends BaseAuthedController { } if (!in_array($goodsMeta['shop_id'], array( - mt\Shop::INAPP_SHOP_CEG + mt\Shop::INAPP_SHOP_DIAMOND ) )) { $this->_rspErr(3, "inapp purchase failed"); diff --git a/webapp/models/InAppOrder.php b/webapp/models/InAppOrder.php index 94d6aead..c346327c 100644 --- a/webapp/models/InAppOrder.php +++ b/webapp/models/InAppOrder.php @@ -43,7 +43,7 @@ class InAppOrder extends BaseModel { ); } - public static function update($order, $fieldsKv) + public static function update($orderId, $fieldsKv) { SqlHelper::update( myself()->_getMysql(''), diff --git a/webapp/services/callback/InAppPurchase.php b/webapp/services/callback/InAppPurchase.php index e0d5cd30..7f863a4b 100644 --- a/webapp/services/callback/InAppPurchase.php +++ b/webapp/services/callback/InAppPurchase.php @@ -14,6 +14,7 @@ require_once("ShopAddItemService.php"); use phpcommon\SqlHelper; +use mt; use mt\ShopGoods; use mt\Item; @@ -49,7 +50,7 @@ class InAppPurchase { $data = json_decode(file_get_contents('php://input'), true); if (!$this->verifySign($data)) { - $this->_rspErr(1, "signature error"); + myself()->_rspErr(1, "signature error"); return; } @@ -57,17 +58,17 @@ class InAppPurchase { // 1. 从商城购买钻石,有订单号 // 2. 站外充值钻石,没有订单号 // 3. appstore 退款,没有订单号 - $records = $data['records']; for ($i = 0; $i < count($records); $i++) { - $this->processOneOrder($records[i]); + $this->processOneOrder($records[$i]); } - $this->_rspOk(); + myself()->_rspOk(); } private function verifySign($data) { + return true; $channel = $data['channel']; $records = $data['records']; $sign = $data['sign']; @@ -82,7 +83,7 @@ class InAppPurchase { $signStr = 'channel=' . $channel . '&' . implode("&", $strings); error_log('InAppPurchase verify ' . $signStr); - $signature = hash_hmac('sha256', $singStr, BUY_SERVER_PKEY); + $signature = hash_hmac('sha256', $sign, BUY_SERVER_PKEY); return $sign == $signature; } @@ -95,7 +96,7 @@ class InAppPurchase { $orderDb = InAppOrder::find($orderId); if (!$orderDb) { - error_log('InAppPurchase: not found order ' . json_encode($_REQUEST)); + error_log('InAppPurchase: not found order ' . $orderId . ' ' . json_encode($_REQUEST)); return; } if ($orderDb['status'] == InAppOrder::FINISHED_STATE) {