Skip to content

Subscriptions not verifying nor binding #209

Description

@timolino13

After purchasing a subscription I verify the purchase with IAPKit, and on success i try to bind the user to the subscription.
The problem is that, even though verification is successfull, on the dashboard the purchase status is still Pending Aknowledgment, and the bind does not work.

Code

onPurchaseSuccess: async (purchase: Purchase) => {
            try {
                const purchaseToken = purchase.purchaseToken;
                console.log("Purchase token:", purchaseToken);
                if (!purchaseToken) {
                    throw new Error("Purchase token is missing");
                }

                const result = await verifyPurchaseWithProvider({
                    provider: "iapkit",
                    iapkit: {
                        apiKey: process.env.EXPO_PUBLIC_IAPKIT_API_KEY,
                        ...(Platform.OS === "ios"
                            ? { apple: { jws: purchaseToken } }
                            : { google: { purchaseToken: purchaseToken } }),
                    },
                });

                console.log("Verification result:", result);

                if (result.iapkit?.isValid) {
                    const r = await kitApi({ apiKey: process.env.EXPO_PUBLIC_IAPKIT_API_KEY || "" }).bindUser(purchaseToken, userId);
                    console.log("Bind result:", r);

                    await finishTransaction({ purchase });

                    await getActiveSubscriptions();
                }
            } catch (error) {
               ...
            } finally {
                ...
            }
        },

Logs

Verification result: {"__typename": "VerifyPurchaseWithProviderResult", "errors": null, "iapkit": {"__typename": "RequestVerifyPurchaseWithIapkitResult", "isValid": true, "state": "pending-acknowledgment", "store": "google"}, "provider": "iapkit"}
Bind result: {"bound": false, "ok": true}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    cross-platformCross-platform (both Android & iOS)kitIAPKit (receipt-validation SaaS)🐛 bugSomething isn't working📱 iOSRelated to iOS🤖 androidRelated to android

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions