From 21dc8f1d57bde69039ded958ea4698a4d2ecb7a9 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 2 Aug 2023 13:30:09 +0800 Subject: [PATCH] 1 --- webapp/controller/ShopController.class.php | 3 +- webapp/mt/Shop.php | 1 - webapp/services/callback/InAppPurchase.php | 36 +++++++++++----------- 3 files changed, 19 insertions(+), 21 deletions(-) diff --git a/webapp/controller/ShopController.class.php b/webapp/controller/ShopController.class.php index 00eb3131..67b92929 100644 --- a/webapp/controller/ShopController.class.php +++ b/webapp/controller/ShopController.class.php @@ -248,8 +248,7 @@ class ShopController extends BaseAuthedController { } if (!in_array($goodsMeta['shop_id'], array( - mt\Shop::INAPP_SHOP_CEG, - mt\Shop::INAPP_SHOP_DIAMOND + mt\Shop::INAPP_SHOP_CEG ) )) { $this->_rspErr(3, "inapp purchase failed"); diff --git a/webapp/mt/Shop.php b/webapp/mt/Shop.php index 30c82b60..323d797d 100644 --- a/webapp/mt/Shop.php +++ b/webapp/mt/Shop.php @@ -43,7 +43,6 @@ class Shop { const WEEKLY_BUY_LIMIT = 2; const TOTAL_BUY_LIMIT = 3; - const INAPP_SHOP_CEG = 7; const INAPP_SHOP_DIAMOND = 9; const OUTSIDE_SHOP = 100; diff --git a/webapp/services/callback/InAppPurchase.php b/webapp/services/callback/InAppPurchase.php index 5362b1e9..8f3cae19 100644 --- a/webapp/services/callback/InAppPurchase.php +++ b/webapp/services/callback/InAppPurchase.php @@ -16,11 +16,28 @@ use models\ShopBuyRecord; use services\LogService; +// { +// channel: 'google', +// sign: '123456677' // 签名字段 +// records: [{ +// productId: '2999', // 从google play console获取的product id +// gameOrderId: '1231321312', // 开始支付时, 从游戏相关服务那获得的订单id +// orderId: 'GPA.3355-1172-9416-16839', // 从google develope API 获取的订单id +// status: 9, // 订单状态, 上报的订单状态一般只有2种情况, 9: 支付成功, 96: 用户退款 +// }] +// } +// let reportData: any = { +// channel: 'google', +// records, +// } +// const hashSort = '' +// const signStr = 'channel=google&' + records.map(record =>Object.keys(record).sort().map(key => `${key}=${record[key]}`).join('&')).join('&') + class InAppPurchase { public function process() { - error_log('ShopInappPurchaseDiamonds:' . json_encode($_REQUEST, JSON_PRETTY_PRINT)); + error_log('ShopInappPurchaseDiamonds:' . json_encode($_REQUEST)); error_log('----- inappPurchaseDiamonds -----'); $body = json_decode(file_get_contents('php://input'), true); error_log('body:' . json_encode($body)); @@ -28,23 +45,6 @@ class InAppPurchase { $records = $body['records']; $sign = $body['sign']; - // { - // channel: 'google', - // sign: '123456677' // 签名字段 - // records: [{ - // productId: '2999', // 从google play console获取的product id - // gameOrderId: '1231321312', // 开始支付时, 从游戏相关服务那获得的订单id - // orderId: 'GPA.3355-1172-9416-16839', // 从google develope API 获取的订单id - // status: 9, // 订单状态, 上报的订单状态一般只有2种情况, 9: 支付成功, 96: 用户退款 - // }] - // } - // let reportData: any = { - // channel: 'google', - // records, - // } - // const hashSort = '' - // const signStr = 'channel=google&' + records.map(record =>Object.keys(record).sort().map(key => `${key}=${record[key]}`).join('&')).join('&') - // const sign = hmacsha256(signStr, hashSort) // 定义一个空数组,用来存放每个记录的键值对字符串