Releases: j3k0/cordova-plugin-purchase
v13.8.4
Trim product titles on Google Play
Google Play returns the app name in parenthesis in product titles. The plugin
now automatically trims it from the app name.
This behavior can be disabled by setting:
CdvPurchase.GooglePlay.Adapter.trimProductTitles = false
Automatically re-validate just-expired subscriptions
The plugin will now monitor active subscripion purchases (as returned by a
receipt validation service) and re-validate the receipt automatically when the
subscription expires or renews.
You can customize the expiry monitor (which should rarely be needed):
// interval between checks in milliseconds
CdvPurchase.Internal.ExpiryMonitor.INTERVAL_MS = 10000; // default: 10s
// extra time before a subscription is considered expired (when re-validating
// too early, sometime the new transaction isn't available yet).
CdvPurchase.Internal.ExpiryMonitor.GRACE_PERIOD_MS = 10000; // default: 10s
Add expiry date to Test Adapter's subscription
The expiry date was missing from the test product:
CdvPurchase.Test.testProducts.PAID_SUBSCRIPTION
v13.8.2
store.applicationUsername can return undefined
If no user is logged in, you applicationUsername
function can return
undefined.
Add "productId" and "platform" to Error objects
All errors now include the "platform" and "productId" field (when applicable),
to get more context.
v13.8.1
v13.8.0
Upgrade to Google Play Billing library 5.2.1
Adds access to offer and base plan identifiers.
Handle validator answer with code VALIDATOR_SUBSCRIPTION_EXPIRED
For backward compatibility, the validator also support responses with a 6778003
error code (expired) when the validated transaction is expired.
Fix: AppStore adapter should only return a localReceipt on iOS
A dummy appstore receipt was listed on other platforms, this is fixed.
Prevent various issues
Prevent double calls to approved callbacks
Make sure .approved()
is only called once during a small time frame.
Skip quick successive calls to store.update()
The update will be performed only if store.update()
or store.initialize()
was called less than store.minTimeBetweenUpdates
milliseconds.
This make it safer to always call store.update()
when entering the app's
Store screen.
Block double callback registrations
Throw an error when attempting the re-register an existing callback for a given
event handler. This is indicative of initialization code being run more than
once.
v13.7.0
Fix AppStore introctory prices
Fix a regression with introctory prices on iOS. Unclear when this happened,
according to Apple documentation, the "discounts" array should contain the
introctory prices, but it turns out it does not anymore.
Set ES6 as minimal javascript version
Down from ES2015, for broader compatibility.
Ensure verify() resolves even if there's no validator
Some user do not specify a receipt validator but want to call
"transaction.verify()" (for example app building frameworks).
This changes makes sure the behavior gets back like it used to be in earlier
versions of the plugin.
v13.6.0
Add store.when().receiptsReady(cb)
The "receiptsReady" event is triggered only once, as soon as all platforms are
done loading the receipts from the SDK.
It can be used by applications that do not rely on receipt validation, in order
to wait for the list of purchases reported by the native SDK to have been
processed. For example, before running some code that check products ownership
statuses at startup.
// at startup
CdvPurchase.store.when().receiptsReady(() => {
console.log('All platforms have loaded their local receipts');
console.log('Feature X: ' + CdvPurchase.store.get('unlock-feature-x').owned);
});
If the receipts have already been loaded before you setup this event handler,
it will be called immediately.
Users using a receipt validation server should rely on receiptsVerified()
instead (see below).
Add store.when().receiptsVerified(cb)
Similarly to "receiptsReady", "receiptsVerified" is triggered only once: after
all platforms have loaded their receipts and those have been verified by the
receipt validation server.
It can be used by applications that DO rely on receipt validation, in order to
wait for all receipts to have been processed by the receipt validation service.
A good use case is to encapsulate startup code that check products ownership
status.
// at startup
CdvPurchase.store.when().receiptsVerified(() => {
console.log('Receipts have been validated');
if (CdvPurchase.store.get('monthly').owned) {
openMainScreen();
}
else {
openSubscriptionScreen();
}
});
If the receipts have already been verified before you setup this event handler,
it will be called immediately.
Add store.when().pending(cb)
This event handler can be notified when a transaction enters the "PENDING"
state, which happens when a user has "Ask to Buy" enabled, or in country where
cash payment is an option.
store.when().pending(transaction => {
// Transaction is pending (waiting for parent approval, cash payment, ...)
});
Remove autogrouping of products
Starting at version 13.4.0, products were automatically added to the "default"
group. This created more issues than it solved, because it let the plugin
automatically try to replace potentially unrelated products.
People willing to rely on automatic subscription replacement on Android should
explicitely set those product's group
property when registering them. Or
should use the oldPurchaseToken
property when making an order.
Examples:
// Replace an old purchase when finalizing the new one on google play.
store.order(product, {
googlePlay: {
oldPurchaseToken: 'abcdefghijkl',
prorationMode: CdvPurchase.GooglePlay.ProrationMode.IMMEDIATE_AND_CHARGE_PRORATED_PRICE,
}
});
// For those 2 subscription products, the plugin will automatically replace
// the currently owned one (if any) when placing a new order.
store.register([{
id: 'no_ads_yearly',
type: ProductType.PAID_SUBSCRIPTION,
platform: Platform.GOOGLE_PLAY,
group: 'noAds'
}, {
id: 'no_ads_monthly',
type: ProductType.PAID_SUBSCRIPTION,
platform: Platform.GOOGLE_PLAY,
group: 'noAds'
}]);
v13.5.0
Add timeout to validation requests
By default, the plugin will now setup a 20 seconds timeout for receipt validation requests.
Receipt validation timeout can be detected using the following code:
CdvPurchase.store.when().unverified(function(response) {
if (response.payload.code === CdvPurchase.ErrorCode.COMMUNICATION) {
if (response.payload.status === CdvPurchase.Utils.Ajax.HTTP_REQUEST_TIMEOUT) {
// request timeout
}
}
});
The value for timeout can be customized by specifying the validator this way:
CdvPurchase.store.validator = {
url: 'https://validator.iaptic.com',
timeout: 30000, // in milliseconds
}
v13.4.3
Add HTTP status to receipt validation error payload
Let the app know the HTTP status for a failed receipt validation call, in "response.payload.status".
CdvPurchase.store.when().unverified(response => {
if (response.payload.code === CdvPurchase.ErrorCode.COMMUNICATION) {
console.log("HTTP ERROR: " + response.payload.status);
}
});
v13.4.2
Fix "owned" status when validator returns "isExpired"
Attempt to fix issue #1406 on iOS, with Ionic v6: applicationUsername
isn't attached to purchase, it seems like this is due to strings passed as a subclass of NSString on this platform.
Issue #1408 fixed. If the validator returns isExpired
, the owned()
method was returning an incorrect result.
v13.4.0
Product groups and Google Play
Products are now part of the "default"
group when none is provided, as per the documentation. This is used on Google Play to automatically replace existing subscription by the newly ordered one.
This update can break your app if you have multiple independent subscription products on Google Play, as purchasing a subscription product will now cancel any existing one by default.
Use the group
property in store.register
to force legacy subscription products to be part of different groups.