I am trying to make a request to the google to verify my IAP purchase but I keep getting the error
Invalid Value at Gaxios._request (/srv/node_modules/googleapis-common/node_modules/gaxios/build/src/gaxios.js:89:23)
I logged the values and they seem to be the correct values. The purchase itself is working in my app it's just that I can't verify it on the server. How can I see what the invalid value is?
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;
};
This is my model
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);
}
}
I am using the 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
});
And I have a service account setup.
It is making a request to the following url
https://www.googleapis.com/androidpublisher/v3/applications/com.company.my_app_name/purchases/products/7162541432/tokens/fdlidklhmmfggackclaedklj.AO-J1Ozu3HBDHN3BqTconVT8pMfvVIi_Iw9nIaY6t5Datphb62ehBJuHwFYXKmAw2VZafChN1fmrbY6_6bdh_-Fzq0Is3-e3u829-ckImdMT9gijDVCkC4mL1kWxqtJ5pWHVNbAIzGz_
Note: I changed the packagename, sku_id and token in my question but they check out
I looked at
Verify a Purchase using Firebase Functions
for reference and also tried to inject the authclient directly into the object like
const response = await playDeveloperApiClient.purchases.subscriptions.get({
auth: authClient,
packageName: packageName,
subscriptionId: receipt.productId,
token: receipt.verificationData
});