Skip to content

Releases: j3k0/cordova-plugin-purchase

v13.3.3

07 Sep 14:08
a94199e
Compare
Choose a tag to compare

Use canMakePayments on Apple AppStore

offer.canPurchase will be false if the platform reports that it doesn't support the "order" functionality.

When you check if the offer can be purchased, the plugin will now use the value from canMakePurchases (for Apple AppStore).

if (!offer.canPurchase) {
  // the given offer cannot be purchased. hide it or hide the buy button.
}

If none of the offers can be purchased, you can choose to hide the whole store.

There are 2 reasons why an offer cannot be purchased:

  1. Product is already owned (see product.owned)
  2. The adapter don't support "order()"

If you really want to access the low-level value of canMakePurchases you can do it like so:

const appStore = store.getAdapter(CdvPurchase.Platform.APPLE_APPSTORE);
if (appStore && appStore.checkSupport('order')) {
  // user can make payments
}

Ref #1378

v13.3.2

07 Sep 14:08
69b17b3
Compare
Choose a tag to compare

Add support for promotional offers on Apple AppStore

You can order a discount offer by providing additional data to "offer.order()" like so:

offer.order({
  appStore: {
    discount: {
      id: "discount-id",
      key: "...",
      nonce: "...",
      signature: "...",
      timestamp: "...",
    }
  }
});

Check Apple documentation about the meaning of those fields and how to fill them. https://developer.apple.com/documentation/storekit/in-app_purchase/original_api_for_in-app_purchase/subscriptions_and_offers/setting_up_promotional_offers?language=objc

You can check this old example server here: https://github.com/j3k0/nodejs-suboffer-signature-server

v13.3.1

07 Sep 14:07
26a39b5
Compare
Choose a tag to compare

Fix "store.order" promise resolution

Wait for the transaction to be purchased or the purchase cancelled before resolving.

Example usage:

store.order(offer)
  .then((result) => {
    if (result && result.isError) {
      if (result.code === CdvPurchase.ErrorCode.PAYMENT_CANCELLED) {
        // Payment cancelled: window closed by user
      }
      else {
        // Payment failed: check result.message
      }
    }
    else {
      // Success
    }
  });

v13.3.0

07 Sep 14:07
45e17d5
Compare
Choose a tag to compare

Add the AppStore autoFinish option

Use this if the transaction queue is filled with unwanted transactions (in development).
It's safe to keep this option to "true" when using a receipt validation server and you only sell subscriptions

Example:

store.initialize([
  {
    platform: Platform.APPLE_APPSTORE,
    options: { autoFinish: true }
  },
  Platform.GOOGLE_PLAY
]);

Optimize AppStore receipt loaded multiple times in parallel

When the Apple appStoreReceipt is loaded from multiple source, it resulted in a lot of duplicate calls. 13.3.0 optimizes this use case.

Add transactionId and purchaseId to VerifiedPurchase

It's just a TypeScript definition since the plugin doesn't do much with it, but it has been requested by a few users.

v13.2.1

07 Sep 14:06
3895ed5
Compare
Choose a tag to compare

Fixing parsing of incorrectly formatted validator response

v13.2.0

07 Sep 14:06
52906a8
Compare
Choose a tag to compare

Adding store.when().unverified()

unverified will be called when receipt validation failed.

Fixing Product.pricing

Issue #1368 fixed: product.pricing was always undefined.

v13.1.6

07 Sep 14:05
daab2bb
Compare
Choose a tag to compare

Fixing appStoreReceipt null on first launch

Bug hasn't been reproduced, but the fix should handle the error case that happened to this user (based on the provided logs).

v13.1.5

07 Sep 14:05
544e99a
Compare
Choose a tag to compare

AppStore fixes

  • 51400ab Adding in-progress transaction to a pseudo receipt
  • c0e47b3 Reloading receipt from native side before receipt validation
  • 5a8542b Improved error reporting
  • 7a80a6d Do not call "finished" for failed transactions
  • 348431e Report success/failure of purchase
  • e53017c Fix crash when logged out of iCloud (#1354)

v13.1.4

07 Sep 14:04
199511a
Compare
Choose a tag to compare

AppStore fixes

  • b692e21 Don't error if finishing already finished transaction
  • 49c0508 Force receipt refresh after order() and restorePurchases()

v13.1.3

07 Sep 14:04
a326912
Compare
Choose a tag to compare

Fixing some receipt validation use cases on Apple devices.

  • 9cfce2d Load missing iOS appStoreReceipt when validation call is requested
  • 2569147 Update validator functions to include the receipts
  • f03a751 Refresh appStoreReceipt if empty at validation stage

Update to requestPayment()

In the payment request, the items array now replace the productIds array. Use this array to define the list of items the user is paying for. For example:

CdvPurchase.store.requestPayment({
  platform: CdvPurchase.Platform.BRAINTREE,
  amountMicros: 11000000,
  currency: 'USD',
  items: [{
    id: 'margherita_large',
    title: 'Pizza Margherita Large',
    pricing: {
      priceMicros: 10000000,
    }
  }, {
    id: 'delivery_standard',
    title: 'Delivery',
    pricing: {
      priceMicros: 1000000,
    }
  }]
});

The format for items makes them compatible with products loaded from the stores. You can then manage your inventory on Google Play but allow payment for those Google Play products using Braintree:

store.register([{
  id: 'five_tokens',
  type: ProductType.CONSUMABLE
  platform: Platform.GOOGLE_PLAY,
}]);

// Later on...
store.requestPayment({
  platform: CdvPurchase.Platform.BRAINTREE,
  amountMicros: 11000000,
  currency: 'USD',
  items: [store.get('five_tokens')],
});

See PaymentRequest and PaymentRequestItem for details.

Fixes for Braintree.requestPayment()

Bug fixes:

  • Properly using the provided applePayOptions
  • Detecting payment request cancellations by user

requestPayment() amount computed from items

If the amount is not provided in a payment request, it will be computed as the sum of all items.

Currency will also be retrieved from the items when missing.