![](/img/trans.png)
[英]Ionic 3 BUILD FAILED with Cordova: cordova\node_modules\cordova-common\src\superspawn.js:169:23
[英]Invalid Value at Gaxios._request (/srv/node_modules/googleapis-common/node_modules/gaxios/build/src/gaxios.js:89:23)
我正在尝试向 google 发出请求以验证我的 IAP 购买,但我不断收到错误消息
Invalid Value at Gaxios._request (/srv/node_modules/googleapis-common/node_modules/gaxios/build/src/gaxios.js:89:23)
我记录了这些值,它们似乎是正确的值。 购买本身在我的应用程序中有效,只是我无法在服务器上验证它。 如何查看无效值?
async function verifySubscriptionAndroid(purchase: InAppPurchaseModel): Promise<boolean> {
let status;
console.log(packageName); //com.company.my_app_name but then it is my actual app name in that format
console.log(purchase.id); //7162541432 which is the id I provided to the subscription in the google play console
console.log(purchase.token); //fdlidklhmmfggackclaedklj.AO-J1Ozu3HBDHN3BqTconVT8pMfvVIi_Iw9nIaY6t5Datphb62ehBJuHwFYXKmAw2VZafChN1fmrbY6_6bdh_-Fzq0Is3-e3u829-ckImdMT9gijDVCkC4mL1kWxqtJ5pWHVNbAIzGz_
try {
await authClient.authorize();
const subscription = await playDeveloperApiClient.purchases.subscriptions.get({
packageName: packageName,
subscriptionId: purchase.id,
token: purchase.token
});
status = subscription.status;
} catch (error) {
console.log(error)
}
return status === 200;
};
这是我的模型
export class IAPReceiptModel {
source: string;
id:string;
token: string;
isSubscription: boolean;
constructor(source: string, productId:string, token: string, isSubscription: boolean) {
this.source = source;
this.id = productId;
this.token= token;
this.isSubscription = isSubscription;
}
static fromJSON(data: any): IAPReceiptModel {
console.log(data);
const source: string = data?.source ?? '';
const productId: string = data?.id ?? '';
const token: string = data?.token ?? '';
const isSubscription:boolean = data?.isSubscription ?? false;
return new IAPReceiptModel(source, productId, verificationData, isSubscription);
}
}
我正在使用 google Auth api
import { google } from 'googleapis';
import * as key from './keys/service_account_key.json';
const authClient = new google.auth.JWT({
email: key.client_email,
key: key.private_key,
scopes: ["https://www.googleapis.com/auth/androidpublisher"]
});
const playDeveloperApiClient = google.androidpublisher({
version: 'v3',
auth: authClient
});
我有一个服务帐户设置。
它正在向以下网址发出请求
https://www.googleapis.com/androidpublisher/v3/applications/com.company.my_app_name/purchases/products/7162541432/tokens/fdlidklhmmfggackclaedklj.AO-J1Ozu3HBDHN3BqTconVT8pMfvVIi_Iw9nIaY6t5Datphb62ehBJuHwFYXKmAw2VZafChN1fmrbY6_6bdh_-Fzq0Is3-e3u829-ckImdMT9gijDVCkC4mL1kWxqtJ5pWHVNbAIzGz_
注意:我在我的问题中更改了包名、sku_id 和令牌,但他们检查了
我在看
供参考,并尝试将 authclient 直接注入到对象中,例如
const response = await playDeveloperApiClient.purchases.subscriptions.get({
auth: authClient,
packageName: packageName,
subscriptionId: receipt.productId,
token: receipt.verificationData
});
也许您想尝试像这样初始化 Google API:
const playDeveloperApiClient = google.androidpublisher('v3');
并将auth
添加到:
const subscription = await playDeveloperApiClient.purchases.subscriptions.get({
auth: authClient,
packageName: packageName,
subscriptionId: purchase.id,
token: purchase.token
});
对于purchase.id
我发现您使用数字作为ID 很奇怪,理想情况下,您希望输入我在评论中提到的字符串,以防万一,它应该是您订阅部分中的产品ID Play Console 如下图突出显示:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.