Toggle navigation
Toggle navigation
This project
Loading...
Sign in
OnePoem
/
OnePoem-Server
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
李帅
2022-11-12 00:33:45 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
b0d5fb4111b5f53862da68fcf31a5292e345b1c6
b0d5fb41
1 parent
efe8fe60
1.使用谷歌服务账号进行验证
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
40 deletions
app/Payment/GooglePayment.php
app/Payment/GooglePayment.php
View file @
b0d5fb4
...
...
@@ -39,40 +39,6 @@ class GooglePayment implements PaymentInterface
private
function
getGoogleClient
()
{
// // load our config.json that contains our credentials for accessing google's api as a json string
// $configJson = public_path().'/client_secret_724392566830-jv6gqcb7vv8q9vavihhu5siccdit35op.apps.googleusercontent.com.json';
//
// // define an application name
// $applicationName = 'Parlando一言临境';
//
// // create the client
// $client = new \Google_Client();
// $client->setApplicationName($applicationName);
// try{
// $client->setAuthConfig($configJson);
// }catch (\Google\Exception $exception){
// Log::debug('用户授权出错了'.$exception->getMessage());
// }
// $client->setAccessType('offline'); // necessary for getting the refresh token
// $client->setApprovalPrompt ('force'); // necessary for getting the refresh token
// // scopes determine what google endpoints we can access. keep it simple for now.
// $client->setScopes(
// [
// \Google\Service\Oauth2::USERINFO_PROFILE,
// \Google\Service\Oauth2::USERINFO_EMAIL,
// \Google\Service\Oauth2::OPENID,
// \Google_Service_AndroidPublisher::ANDROIDPUBLISHER,
// \Google\Service\Drive::DRIVE_METADATA_READONLY // allows reading of google drive metadata
// ]
// );
// $client->setIncludeGrantedScopes(true);
//
// // google 服务端默认获得受权
// $client->useApplicationDefaultCredentials();
// // 设置 google client_email
// $client->setSubject("client_email");
$credentials_file
=
public_path
()
.
'/pc-api-7482901338487549764-603-566eccf76b91.json'
;
$client
=
new
\Google_Client
();
try
{
...
...
@@ -200,7 +166,45 @@ class GooglePayment implements PaymentInterface
//SUBSCRIPTION_REVOKED - 用户在到期时间之前已撤消订阅。
//SUBSCRIPTION_EXPIRED - 订阅已到期。
// 'acknowledgementState' => 1,
// 'autoRenewing' => false, // 设置是否在订阅到期时自动续订。
// 'autoResumeTimeMillis' => NULL,
// 'cancelReason' => 1, //订阅被取消或未自动续订的原因。可能的值包括:0.用户取消了订阅 1.由于结算问题 2.系统取消了订阅 2. 订阅被新的订阅取代了。3.开发者已取消订阅
// 'cancelSurveyResultType' => 'Google\\Service\\AndroidPublisher\\SubscriptionCancelSurveyResult',
// 'cancelSurveyResultDataType' => '',
// 'countryCode' => 'CA',
// 'developerPayload' => '',
// 'emailAddress' => NULL,
// 'expiryTimeMillis' => '1668023054641', // 订阅的到期时间
// 'externalAccountId' => NULL,
// 'familyName' => NULL,
// 'givenName' => NULL,
// 'introductoryPriceInfoType' => 'Google\\Service\\AndroidPublisher\\IntroductoryPriceInfo',
// 'introductoryPriceInfoDataType' => '',
// 'kind' => 'androidpublisher#subscriptionPurchase',
// 'linkedPurchaseToken' => NULL,
// 'obfuscatedExternalAccountId' => 'osnB10209503106007', //我们系统的订单号
// 'obfuscatedExternalProfileId' => NULL,
// 'orderId' => 'GPA.3390-9999-6519-16223..5',
// 'paymentState' => NULL, //订阅的付款状态。可能的值包括:0=待处理付款,1=付款已收讫,2=免费试用,3=延迟升级/降级.已取消、已过期的订阅不会显示。
// 'priceAmountMicros' => '5490000', // 订阅价格。例如,如果订阅价格为 1.99 欧元,priceAmountMicros 为 1990000。
// 'priceChangeType' => 'Google\\Service\\AndroidPublisher\\SubscriptionPriceChange',
// 'priceChangeDataType' => '',
// 'priceCurrencyCode' => 'CAD',
// 'profileId' => NULL,
// 'profileName' => NULL,
// 'promotionCode' => NULL,
// 'promotionType' => NULL,
// 'purchaseType' => 0, // 订阅的购买类型 0=测试,1=促销,当购买交易不是使用标准的应用内购买结算流程时,系统才会设置此字段。
// 'startTimeMillis' => '1668020958362',
// 'userCancellationTimeMillis' => NULL,
// 'internal_gapi_mappings' =>
$data
=
json_decode
(
base64_decode
(
$string
),
true
);
Log
::
debug
(
'返回的数据:===================='
);
Log
::
debug
(
print_r
(
$data
,
true
));
$packageName
=
$data
[
'packageName'
];
if
(
isset
(
$data
[
'subscriptionNotification'
]))
{
$subscriptionId
=
$data
[
'subscriptionNotification'
][
'subscriptionId'
];
...
...
@@ -224,12 +228,12 @@ class GooglePayment implements PaymentInterface
//请求域名(Post/form)
//https://androidpublisher.googleapis.com/androidpublisher/v3/applications/{packageName}/purchases/subscriptions/{subscriptionId}/tokens/{token}:acknowledge
$acknowledge
=
new
SubscriptionPurchasesAcknowledgeRequest
();
$acknowledge
->
developerPayload
=
''
;
// todo 可以将我们系统的订单号、用户支付金额等存入谷歌订单里
$resp
=
$validator
->
purchases_subscriptions
->
acknowledge
(
$packageName
,
$subscriptionId
,
$purchaseToken
,
$acknowledge
);
Log
::
debug
(
'消耗结果:===================='
);
Log
::
debug
(
var_export
(
$resp
,
true
));
//
$acknowledge = new SubscriptionPurchasesAcknowledgeRequest();
//
$acknowledge->developerPayload = ''; // todo 可以将我们系统的订单号、用户支付金额等存入谷歌订单里
//
$resp = $validator->purchases_subscriptions->acknowledge($packageName, $subscriptionId, $purchaseToken,$acknowledge);
//
//
Log::debug('消耗结果:====================');
//
Log::debug(var_export($resp,true));
// todo 发货
...
...
Please
register
or
login
to post a comment