You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For android , it is working okay on both cases, whenever the user have already subscribed and clicked on "the button" the popup will appear telling you are subscribed. if not, it will also allow him to subscribe again .
for IOS , is that correct that i am trying to validate ios receipt on server by calling calling my server on .receiptUpdated(async receipt => {
and not on "finished" ?
but for android i am calling it on .finished(async (transaction) => {}
since APPLE told me I must verify "receipt" and NOT "transaction".
in IOS , the popup appears only if the user "didn't yet subscribe" , but if the user has already subscribed ( even if it is expired and inactive ). and click the purchase button i get undefined. here next in the 3rd line.
this.store?.get(productId, platformToUse)?.getOffer()?.order()
.then(error => {
// alert(JSON.stringify('here i get undefined')); ( here is the problem ) why i get undefined and not the popup again?
if (error) {
// console.log('isProcessingOrder error')
// alert('isProcessingOrder error')
// alert(JSON.stringify(error))
}
if (error?.code === CdvPurchase.ErrorCode.PAYMENT_CANCELLED) {
// payment cancelled by the user
}
});
I can confirm the iOS behavior. If a user has already subscribed, even if the subscription has been canceled or has expired, the store.get function returns undefined.
2 Problems !
For android , it is working okay on both cases, whenever the user have already subscribed and clicked on "the button" the popup will appear telling you are subscribed. if not, it will also allow him to subscribe again .
and not on "finished" ?
but for android i am calling it on .finished(async (transaction) => {}
since APPLE told me I must verify "receipt" and NOT "transaction".
this.store?.get(productId, platformToUse)?.getOffer()?.order()
.then(error => {
// alert(JSON.stringify('here i get undefined')); ( here is the problem ) why i get undefined and not the popup again?
if (error) {
// console.log('isProcessingOrder error')
// alert('isProcessingOrder error')
// alert(JSON.stringify(error))
}
if (error?.code === CdvPurchase.ErrorCode.PAYMENT_CANCELLED) {
// payment cancelled by the user
}
});
this is the whole code
async setStore() {
if (this.ProductType && this.store && this.ProductTypeIos) {
if (this.androidPlatform) {
this.store?.register([
{
id: "goldsubscription",
type: this.ProductType,
platform: this.androidPlatform,
},
{
id: "silversubscription",
type: this.ProductType,
platform: this.androidPlatform,
},
{
id: "bronzesubscription",
type: this.ProductType,
platform: this.androidPlatform,
},
]);
}
if (this.iosPlatform) {
this.store?.register([
{
id: "goldsubscription",
type: this.ProductTypeIos,
platform: this.iosPlatform,
},
{
id: "silversubscription",
type: this.ProductTypeIos,
platform: this.iosPlatform,
},
{
id: "bronzesubscriptions",
type: this.ProductTypeIos,
platform: this.iosPlatform,
}
]);
}
}
async setupEventHandlers() {
if (this.store) {
this.store.when()
.productUpdated(() => {
})
.receiptsReady(() => {
// alert('receipt updated')
})
.receiptUpdated(async receipt => {
// alert('receipt')
// alert(JSON.stringify(receipt));
if (this.iosPlatform && this.counter === 0) {
if (receipt?.transactions?.length > 0) {
// alert('receipt')
// alert(JSON.stringify(receipt));
try {
const platform = this.platformIs === 'ios' ? 'ios' : 'android'
await this.dataService.addSubscription(this.userEmail, receipt, platform);
this.isCallingServer = false;
}
catch (e: any) {
this.isCallingServer = false;
// alert(JSON.stringify(e));
}
}
this.counter++;
}
})
.approved(async (transaction) => {
// alert('transaction')
// alert(JSON.stringify(transaction));
// if (this.androidPlatform && this.counter < 2)
// transaction.verify();
})
.verified(async receipt => {
this.verifiedCallback.forEach(callback => callback());
})
.unverified(unverified => {
})
.finished(async (transaction) => {
if (this.androidPlatform) {
// alert('.finished');
// alert(JSON.stringify(transaction));
try {
const platform = this.platformIs === 'ios' ? 'ios' : 'android'
await this.dataService.addSubscription(this.userEmail, transaction, platform);
this.isCallingServer = false;
}
catch (e: any) {
this.isCallingServer = false;
// alert(JSON.stringify(e));
}
}
});
}
The text was updated successfully, but these errors were encountered: