简体   繁体   English

应用程序购买插件/几个数据库条目中的中央凹

[英]fovea in app purchae plugin/several database entries

I have a problem on the in app purchase cordova plugin by fovea.我对 fovea 的应用内购买 cordova 插件有疑问。

I am kinda confused.我有点困惑。 What I want to do, is that when the user chooses a product (monthly subscription), I do what I need to do, process payment and all that jazz, and when everything is done, I save an entry in my database, to indicate that the user is subscribed (and some more info).我想做的是,当用户选择产品(按月订阅)时,我会做我需要做的事情,处理付款和所有爵士乐,当一切都完成后,我会在我的数据库中保存一个条目,以表明用户已订阅(以及更多信息)。

However, when I use it, I see that I have not one but at least 10 saved entries.但是,当我使用它时,我发现我没有一个但至少有 10 个保存的条目。 For same user, same product.对于相同的用户,相同的产品。

I have no idea why it does that.我不知道为什么会这样。 So I guess something is wrong with my code.所以我猜我的代码有问题。 As I use Sandbox for testing IOS side, sometimes the pop up just doesn't appear (where you need to enter your password and confirm your purchase), and yet I have 10/20 entries saved in my database (I put that bit of code when product is owned, then in the.finished event).当我使用 Sandbox 测试 IOS 端时,有时弹出窗口不会出现(您需要输入密码并确认购买),但我的数据库中保存了 10/20 个条目(我把那一点产品拥有时的代码,然后在 .finished 事件中)。

Can someone help me?有人能帮我吗?

Here is the code这是代码

let produit = null;
if (!(window as any).store) {
    alert('Store indispo');
}

this.store.register({
    id: this.valeurEnvoi.app,
    alias: 'abonnement',
    type: store.PAID_SUBSCRIPTION,
});
console.log(this.valeurEnvoi.app);
this.store.refresh();

this.store.ready( () => {
    produit = this.store.get(this.valeurEnvoi.app);
    this.envoiLogs('récupération du produit', 'NO ID');

    if (produit.canPurchase) {
        this.store.order(produit);
    }
});
this.store.refresh();
// this.store.manageSubscriptions();

this.store.when(produit).updated( (p) =>  {
    if (p.owned) {
    } else {
    }
});
this.store.refresh();
console.log(this.store.log);

this.store.error( error => {
    this.testLog = error.message;
    alert('erreur: ' + error.code + ' message: ' + error.message);
});


this.store.when(produit).approved( (order) => {
    order.finish();
});
this.store.refresh();

this.store.when(produit).finished( (order) => {
    const test = this.store.findInLocalReceipts(produit);
    alert(test.transactionId);
    this.confirmerAchatMobile();
});

Also, If I could have some pointer to get the transactionID, that would be great, Thank you, If you see any strange stuff.另外,如果我能有一些指针来获取 transactionID,那就太好了,谢谢,如果您看到任何奇怪的东西。 let me know, it will help.让我知道,它会有所帮助。

I took a look at the repo.我看了一下回购协议。 refresh() appears to be deprecated: refresh() 似乎已被弃用:

         /**
         * @deprecated - use store.initialize(), store.update() or store.restorePurchases()
         */
        refresh() {
            throw new Error("use store.initialize() or store.update()");
        }

source: https://github.com/j3k0/cordova-plugin-purchase/blob/master/www/store.js来源: https://github.com/j3k0/cordova-plugin-purchase/blob/master/www/store.js

Also, from a comment I infer that the transactions are replayed if you call refresh multiple times, could that cause your issue?: Notice that all previous transactions will be replayed if you call store.refresh() a second time in the lifetime of your app.另外,从评论中我推断,如果您多次调用刷新,交易将被重播,这会导致您的问题吗?: Notice that all previous transactions will be replayed if you call store.refresh() a second time in the lifetime of your app. source: https://github.com/j3k0/cordova-plugin-purchase/issues/1298来源: https://github.com/j3k0/cordova-plugin-purchase/issues/1298

There are quite a few (109) issues on the git repo. git repo 上有很多(109)个问题。 So I think you might find your answer there.所以我想你可能会在那里找到答案。 If not, I'd create an issue there, the maintainers are probably more likely to have an answer for you.如果没有,我会在那里创建一个问题,维护人员可能更有可能为您提供答案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM