Skip to content

feat(payments): StoreKit v2 + Google Billing v8 #44

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 34 commits into
base: main
Choose a base branch
from

Conversation

NathanWalker
Copy link
Collaborator

@NathanWalker NathanWalker commented Aug 14, 2025

Reworks the legacy payment setup to be simpler to use while also using all latest SDKs.

Example Usage

import { Payment, Product } from '@nativescript/payments'

const payment = new Payment();
payment.onPurchaseUpdate = (purchases, error) => {
  if (error) {
    console.error(`🛑 Purchase Update Error: ${error} 🛑`);
  } else {
    console.log(`🟢 Purchase Update: ${purchases.length} items 🟢`);
    purchases.forEach((transaction) => {
      switch (transaction.state) {
        case 'pending':
          transaction.finish();
          break;
        case 'purchased':
          console.log(`🟢 Purchase Update: ${JSON.stringify(transaction.receiptToken)} 🟢`);
          break;
      }
    });
  }
};
payment.onReady = async () => {
  try {
    console.log('🟢 Payment System Ready 🟢');
    const purchases = await payment.fetchPurchases();
    console.log(`🟢 Fetched previous ${purchases.length} In App Purchase Items 🟢`);

    const products = await payment.fetchProducts(['io.nstudio.iapdemo.coinsfive', 'io.nstudio.iapdemo.coinsone', 'io.nstudio.iapdemo.coinsonethousand'], 'inapp');

    console.log("here's the products!", products)
  } catch (error) {
    console.error(`🛑 Error: ${error} 🛑`);
  }
};

function buyItem(item: Product) {
  payment.purchaseProduct(item);
}

These changes modernize the payments plugin, simplify its usage, and remove a significant amount of legacy and abstraction code in favor of a more direct and maintainable API.

@NathanWalker NathanWalker changed the title feat: StoreKit v2 + Google Billing v8 feat(payments): StoreKit v2 + Google Billing v8 Aug 14, 2025
@edusperoni
Copy link
Collaborator

edusperoni commented Aug 14, 2025

I have some pending changes for billing 8 because it includes API changes. Let's chat about it this week.

Also I don't understand why move all the logic to native, as it's pretty straightforward in JS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants