RevenueCat / purchases-capacitor

Capacitor in-app purchases and subscriptions made easy.
MIT License
154 stars 14 forks source link

ios purchase not working #321

Closed HEAVYPOLY closed 2 months ago

HEAVYPOLY commented 2 months ago

Hi,

Is purchasePackage() supposed to bring up iOS in app purchase flow? I can see the prnt('PURCHASE PACKAGE ', package) in my console with the package object data looking correct, but never see the ios purchase overlay / flow. Am I missing something else?

Also not seeing any errors in try catch of purchasePackage...just the prnt and nothing else happens.

Testing on M1 ipad pro physical device. In app purchase capability added to project in xcode

const products = vanX.reactive([])
const packages = vanX.reactive([])

let Purchases
async function setupIap () {
  Purchases = Capacitor.Plugins.Purchases
  await Purchases.configure({
    apiKey: 'apple_keyBlahBlah',
    appUserID: 'tester'
  })
  try {
    const offerings = await Purchases.getOfferings()
    if (offerings.current !== null && offerings.current.availablePackages.length !== 0) {
      for (const package of offerings.current.availablePackages) {
        packages.push(package)
        products.push(package.product)
      }
    }
  } catch (error) {
  }
}
async function purchasePackage (package) {
  prnt('PURCHASE PACKAGE ', package)
  try {
    const purchaseResult = await Purchases.purchasePackage({ aPackage: package })
    if (typeof purchaseResult.customerInfo.entitlements.active['pro'] !== 'undefined') {
      prnt('unlock pro')
    }
  } catch (error) {
    if (error.code === PURCHASES_ERROR_CODE.PURCHASE_CANCELLED_ERROR) {
      prnt('purchase cancelled')
    } else {
      prnt('purchase error', error)
    }
  }
}

const TestPurchases = () => {
  return vanX.list(div({ class: 'abs gap ', style: 'text-transform:none;left:50%;top:50%;' }), packages, ({ val: package }) => div({
    class: 'col uiCol paddingLg button radiusLg',
    style: 'padding:5rem;',
    onclk: () => purchasePackage(package)
  },
  div(package.product.identifier),
  div(package.product.description),
  () => package.product.pricePerMonthString ? div(package.product.pricePerMonthString + ' per month') : div(package.product.price),
  )
  )
}
RCGitBot commented 2 months ago

👀 We've just linked this issue to our internal tracker and notified the team. Thank you for reporting, we're checking this out!

HEAVYPOLY commented 2 months ago

Update: I think adding screenshot and localization for the subscription group in app store connect fixed it.

rglanz-rc commented 2 months ago

@HEAVYPOLY yes, that likely got the products into the 'Ready to Submit' state, which is what you need for testing. I'll close this issue, but feel free to re-open if you're still having trouble.