pwa-builder / PWABuilder

The simplest way to create progressive web apps across platforms and devices. Start here. This repo is home to several projects in the PWABuilder family of tools.
https://docs.pwabuilder.com
Other
2.66k stars 279 forks source link

How to acknowledge Subscription for the Digital Goods API in a PWA? #4593

Closed leblzdenek closed 7 months ago

leblzdenek commented 7 months ago

Hello, Has anybody managed to acknowledge Subscription for the Google's Digital Goods API in their PWA?

I am using the code below to "acknowledge" / consume In-app purchase, but I am unable to find a way to acknowledge a subscription.

                if ('getDigitalGoodsService' in window) {
                    // Digital Goods API is supported!
                    try {
                        const service = await window.getDigitalGoodsService('https://play.google.com/billing');

                        const paymentMethodData = [
                            {
                                supportedMethods: 'https://play.google.com/billing',
                                data: {
                                    sku: productid,
                                },
                            },
                        ];

                        const request = new PaymentRequest(paymentMethodData);
                        const paymentResponse = await request.show();

                        const { purchaseToken } = paymentResponse.details;

                        const purchasedToken = paymentResponse.details.purchaseToken;

                        let paymentComplete;

                        paymentComplete = await paymentResponse.complete('success');

                        service.consume(purchasedToken);
                    }
                    catch (error) {
                    }
                }

I have followed this PWA tutorial, but it does not show how to acknowledge a subscription https://chromeos.dev/en/publish/pwa-play-billing#acknowledge-a-purchase

A link in the tutorial leads to this document with an example, but I have not succeeded with its implementation yet. Google OAuth 2.0 is neccessary. https://developers.google.com/android-publisher/api-ref/rest/v3/purchases.subscriptions/acknowledge

Am I on the right track and/or is there an easier solution to this please?

Thank you for any feedback Zdenek

jgw96 commented 7 months ago

Hello! I am not completely up to date on this, but Im 99% sure that the acknowledge of the purchase has to be done on the server . image

However, I bet there is some folx in our Discord that could provide more direct help on this, you can join here https://aka.ms/pwabuilderdiscord

leblzdenek commented 7 months ago

Hello jgw96, when I tried to join the group Discord banned me because of suspicious behaviour (I probably have not recognized picture of polar bear from a pinguin and Discord now thinks I am a robot lol)

I tried multiple times...

Is there any other way how to join the folx please?

Thank you very much for your time I greatly appreciate it Zdenek

Hello! I am not completely up to date on this, but Im 99% sure that the acknowledge of the purchase has to be done on the server . However, I bet there is some folx in our Discord that could provide more direct help on this, you can join here https://aka.ms/pwabuilderdiscord