李帅

1.使用谷歌服务账号进行验证

...@@ -39,40 +39,6 @@ class GooglePayment implements PaymentInterface ...@@ -39,40 +39,6 @@ class GooglePayment implements PaymentInterface
39 39
40 private function getGoogleClient() 40 private function getGoogleClient()
41 { 41 {
42 -// // load our config.json that contains our credentials for accessing google's api as a json string
43 -// $configJson = public_path().'/client_secret_724392566830-jv6gqcb7vv8q9vavihhu5siccdit35op.apps.googleusercontent.com.json';
44 -//
45 -// // define an application name
46 -// $applicationName = 'Parlando一言临境';
47 -//
48 -// // create the client
49 -// $client = new \Google_Client();
50 -// $client->setApplicationName($applicationName);
51 -// try{
52 -// $client->setAuthConfig($configJson);
53 -// }catch (\Google\Exception $exception){
54 -// Log::debug('用户授权出错了'.$exception->getMessage());
55 -// }
56 -// $client->setAccessType('offline'); // necessary for getting the refresh token
57 -// $client->setApprovalPrompt ('force'); // necessary for getting the refresh token
58 -// // scopes determine what google endpoints we can access. keep it simple for now.
59 -// $client->setScopes(
60 -// [
61 -// \Google\Service\Oauth2::USERINFO_PROFILE,
62 -// \Google\Service\Oauth2::USERINFO_EMAIL,
63 -// \Google\Service\Oauth2::OPENID,
64 -// \Google_Service_AndroidPublisher::ANDROIDPUBLISHER,
65 -// \Google\Service\Drive::DRIVE_METADATA_READONLY // allows reading of google drive metadata
66 -// ]
67 -// );
68 -// $client->setIncludeGrantedScopes(true);
69 -//
70 -// // google 服务端默认获得受权
71 -// $client->useApplicationDefaultCredentials();
72 -// // 设置 google client_email
73 -// $client->setSubject("client_email");
74 -
75 -
76 $credentials_file = public_path().'/pc-api-7482901338487549764-603-566eccf76b91.json'; 42 $credentials_file = public_path().'/pc-api-7482901338487549764-603-566eccf76b91.json';
77 $client = new \Google_Client(); 43 $client = new \Google_Client();
78 try{ 44 try{
...@@ -200,7 +166,45 @@ class GooglePayment implements PaymentInterface ...@@ -200,7 +166,45 @@ class GooglePayment implements PaymentInterface
200 //SUBSCRIPTION_REVOKED - 用户在到期时间之前已撤消订阅。 166 //SUBSCRIPTION_REVOKED - 用户在到期时间之前已撤消订阅。
201 //SUBSCRIPTION_EXPIRED - 订阅已到期。 167 //SUBSCRIPTION_EXPIRED - 订阅已到期。
202 168
169 +
170 + // 'acknowledgementState' => 1,
171 + // 'autoRenewing' => false, // 设置是否在订阅到期时自动续订。
172 + // 'autoResumeTimeMillis' => NULL,
173 + // 'cancelReason' => 1, //订阅被取消或未自动续订的原因。可能的值包括:0.用户取消了订阅 1.由于结算问题 2.系统取消了订阅 2. 订阅被新的订阅取代了。3.开发者已取消订阅
174 + // 'cancelSurveyResultType' => 'Google\\Service\\AndroidPublisher\\SubscriptionCancelSurveyResult',
175 + // 'cancelSurveyResultDataType' => '',
176 + // 'countryCode' => 'CA',
177 + // 'developerPayload' => '',
178 + // 'emailAddress' => NULL,
179 + // 'expiryTimeMillis' => '1668023054641', // 订阅的到期时间
180 + // 'externalAccountId' => NULL,
181 + // 'familyName' => NULL,
182 + // 'givenName' => NULL,
183 + // 'introductoryPriceInfoType' => 'Google\\Service\\AndroidPublisher\\IntroductoryPriceInfo',
184 + // 'introductoryPriceInfoDataType' => '',
185 + // 'kind' => 'androidpublisher#subscriptionPurchase',
186 + // 'linkedPurchaseToken' => NULL,
187 + // 'obfuscatedExternalAccountId' => 'osnB10209503106007', //我们系统的订单号
188 + // 'obfuscatedExternalProfileId' => NULL,
189 + // 'orderId' => 'GPA.3390-9999-6519-16223..5',
190 + // 'paymentState' => NULL, //订阅的付款状态。可能的值包括:0=待处理付款,1=付款已收讫,2=免费试用,3=延迟升级/降级.已取消、已过期的订阅不会显示。
191 + // 'priceAmountMicros' => '5490000', // 订阅价格。例如,如果订阅价格为 1.99 欧元,priceAmountMicros 为 1990000。
192 + // 'priceChangeType' => 'Google\\Service\\AndroidPublisher\\SubscriptionPriceChange',
193 + // 'priceChangeDataType' => '',
194 + // 'priceCurrencyCode' => 'CAD',
195 + // 'profileId' => NULL,
196 + // 'profileName' => NULL,
197 + // 'promotionCode' => NULL,
198 + // 'promotionType' => NULL,
199 + // 'purchaseType' => 0, // 订阅的购买类型 0=测试,1=促销,当购买交易不是使用标准的应用内购买结算流程时,系统才会设置此字段。
200 + // 'startTimeMillis' => '1668020958362',
201 + // 'userCancellationTimeMillis' => NULL,
202 + // 'internal_gapi_mappings' =>
203 +
204 +
203 $data = json_decode(base64_decode($string),true); 205 $data = json_decode(base64_decode($string),true);
206 + Log::debug('返回的数据:====================');
207 + Log::debug(print_r($data,true));
204 $packageName = $data['packageName']; 208 $packageName = $data['packageName'];
205 if (isset($data['subscriptionNotification'])) { 209 if (isset($data['subscriptionNotification'])) {
206 $subscriptionId = $data['subscriptionNotification']['subscriptionId']; 210 $subscriptionId = $data['subscriptionNotification']['subscriptionId'];
...@@ -224,12 +228,12 @@ class GooglePayment implements PaymentInterface ...@@ -224,12 +228,12 @@ class GooglePayment implements PaymentInterface
224 //请求域名(Post/form) 228 //请求域名(Post/form)
225 //https://androidpublisher.googleapis.com/androidpublisher/v3/applications/{packageName}/purchases/subscriptions/{subscriptionId}/tokens/{token}:acknowledge 229 //https://androidpublisher.googleapis.com/androidpublisher/v3/applications/{packageName}/purchases/subscriptions/{subscriptionId}/tokens/{token}:acknowledge
226 230
227 - $acknowledge = new SubscriptionPurchasesAcknowledgeRequest(); 231 +// $acknowledge = new SubscriptionPurchasesAcknowledgeRequest();
228 - $acknowledge->developerPayload = ''; // todo 可以将我们系统的订单号、用户支付金额等存入谷歌订单里 232 +// $acknowledge->developerPayload = ''; // todo 可以将我们系统的订单号、用户支付金额等存入谷歌订单里
229 - $resp = $validator->purchases_subscriptions->acknowledge($packageName, $subscriptionId, $purchaseToken,$acknowledge); 233 +// $resp = $validator->purchases_subscriptions->acknowledge($packageName, $subscriptionId, $purchaseToken,$acknowledge);
230 - 234 +//
231 - Log::debug('消耗结果:===================='); 235 +// Log::debug('消耗结果:====================');
232 - Log::debug(var_export($resp,true)); 236 +// Log::debug(var_export($resp,true));
233 237
234 // todo 发货 238 // todo 发货
235 239
......