cordova-plugin-purchase
Advanced tools
Comparing version 11.0.0 to 13.0.0
{ | ||
"name": "cordova-plugin-purchase", | ||
"version": "11.0.0", | ||
"version": "13.0.0", | ||
"description": "Cordova Purchase plugin for iOS, Android, Windows (AppStore, Play, UWP)", | ||
@@ -29,7 +29,9 @@ "cordova": { | ||
"play", | ||
"appstore" | ||
"appstore", | ||
"iaptic", | ||
"fovea" | ||
], | ||
"scripts": { | ||
"test": "make test-js", | ||
"coverage": "make test-js-coverage" | ||
"typedoc": "typedoc --hideGenerator --excludePrivate --excludeProtected --excludeInternal --disableSources --readme src/ts/README.md --hideBreadcrumbs true --hideInPageTOC false --out api --pretty --plugin typedoc-plugin-markdown --theme markdown --basePath src/ts src/ts/store.ts", | ||
"typedoc-dev": "typedoc --hideGenerator --readme src/ts/README.md --out api-dev --pretty --plugin typedoc-plugin-markdown --theme markdown --basePath src/ts src/ts/store.ts" | ||
}, | ||
@@ -45,3 +47,2 @@ "author": "Jean-Christophe Hoelt <hoelt@fovea.cc>", | ||
"babel-eslint": "^10.0.3", | ||
"coveralls": "^3.0.6", | ||
"eslint": "^5.16.0", | ||
@@ -55,5 +56,10 @@ "eslint-config-defaults": "^9.0.0", | ||
"preprocessor": "^1.4.0", | ||
"typedoc": "^0.23.15", | ||
"typedoc-github-wiki-theme": "^1.0.1", | ||
"typedoc-plugin-markdown": "^3.13.6", | ||
"typescript": "^4.7.4", | ||
"uglify-js": "^3.6.0" | ||
}, | ||
"types": "./src/js/index.d.ts" | ||
"main": "./www/store.js", | ||
"types": "./www/store.d.ts" | ||
} |
@@ -5,4 +5,2 @@ # Cordova Purchase Plugin | ||
[![Build Status](https://travis-ci.org/j3k0/cordova-plugin-purchase.svg)](https://travis-ci.org/j3k0/cordova-plugin-purchase) | ||
--- | ||
@@ -26,3 +24,3 @@ | ||
This plugin allows **In-App Purchases** to be made from **Cordova, PhoneGap and Ionic** applications. | ||
This plugin allows **In-App Purchases** to be made from **Cordova, Ionic and Capacitor** applications. | ||
@@ -33,11 +31,10 @@ It lets you handle in-app purchases on many platforms with a single codebase. | ||
| | ios | android | win-8 | win-10/uwp | mac | | ||
| | AppStore (iOS / macOS) | Google Play | Windows 8 | Windows 10 / UWP | Braintree (iOS / Android) | | ||
|--|--|--|--|--|--| | ||
| consumables | ✅ | ✅ | ✅ | ✅ | ✅ | | ||
| non consumables | ✅ | ✅ | ✅ | ✅ | ✅ | | ||
| subscriptions | ✅ | ✅ | ✅ | ✅ | ✅ | | ||
| restore purchases | ✅ | ✅ | ✅ | ✅ | ✅ | | ||
| [receipt validations](https://billing.fovea.cc) | ✅ | ✅ | | ✅ | ✅ | | ||
| downloadable content | ✅ | | | | ✅ | | ||
| introductory prices | ✅ | ✅ | | ✅ | ✅ | | ||
| consumables | | ✅ | | | ✅ | | ||
| non consumables | | ✅ | | | | | ||
| subscriptions | | ✅ | | | | | ||
| restore purchases | | ✅ | | | ✅ | | ||
| [receipt validations](https://www.iaptic.com) | | ✅ | | | ✅ | | ||
| custom payments | | | | | ✅ | | ||
@@ -47,4 +44,7 @@ ### Supported platforms | ||
- **iOS** version 6.0 or higher. | ||
- with Braintree | ||
- **Android** version 2.2 (API level 8) or higher | ||
- with Google Play client version 3.9.16 or higher | ||
- with Braintree | ||
<!-- | ||
- **Windows** Store/Phone 8.1 or higher | ||
@@ -55,2 +55,3 @@ - **Windows 10 Mobile** | ||
- (and any platform supporting Microsoft's UWP) | ||
--> | ||
@@ -63,15 +64,8 @@ | ||
```sh | ||
cordova plugin add cordova-plugin-purchase | ||
cordova plugin add "https://github.com/j3k0/cordova-plugin-purchase.git#v13" | ||
``` | ||
### Install the plugin (PhoneGap) | ||
Add the following to your `config.xml` file: | ||
### Recommended plugins | ||
```xml | ||
<gap:plugin name="cordova-plugin-purchase" source="npm" version="9.0.0"></gap:plugin> | ||
``` | ||
### Install recommended plugins | ||
<details> | ||
@@ -98,3 +92,3 @@ <summary> | ||
When making receipt validation requests, the purchase plugin uses by default the browser's ajax capabilities. This sometime causes issues with CORS restriction. CORS also imposes an extra back-and-forth with the server (the CORS preflight request) to ensure the server allows for such request to be made. By installing the [advanced-http plugin](https://github.com/silkimen/cordova-plugin-advanced-http), you get rid of those issue and benefit from the extra feature of this plugin (like advanced authentication option). Read the [advanced-http](https://github.com/silkimen/cordova-plugin-advanced-http) plugin documentation for details. | ||
When making receipt validation requests, the purchase plugin uses, by default, the browser's ajax capabilities. This sometime causes issues with CORS restriction. CORS also imposes an extra back-and-forth with the server (the CORS preflight request) to ensure the server allows for such request to be made. By installing the [advanced-http plugin](https://github.com/silkimen/cordova-plugin-advanced-http), you get rid of those issue and benefit from the extra feature of the the plugin, like advanced authentication option. Read the [advanced-http](https://github.com/silkimen/cordova-plugin-advanced-http) plugin documentation for details. | ||
</details> | ||
@@ -108,4 +102,3 @@ | ||
If you don't know much about In-App Purchases, you'll find a good overview | ||
on the subject from those guys: | ||
If you wish to learn more about In-App Purchases (IAP), you'll find a good overview on the subject from the various platforms documentation: | ||
@@ -121,5 +114,5 @@ * Apple: | ||
They all share the same concepts, so they are a good reads in all cases, with some advice that apply to all platforms. | ||
All platforms share the same concepts, so they are a good reads in all cases. | ||
To ease the beggining of your journey into the intimidating world of In-App Purchase with Cordova, we wrote a guide which hopefully will help you get things done: https://purchase.cordova.fovea.cc/ | ||
To ease the beginning of your journey into the intimidating world of In-App Purchase with Cordova, we wrote a guide which hopefully will help you get things done: [Guide: Cordova In-App Purchase Plugin - v13.0](https://purchase.cordova.fovea.cc/v/v13.0/) | ||
@@ -131,14 +124,5 @@ In short, you'll have two main tasks to accomplish: | ||
For platform setup, the [wiki](https://github.com/j3k0/cordova-plugin-purchase/wiki/Home) contains good information. | ||
For platform setup, the [wiki](https://github.com/j3k0/cordova-plugin-purchase/wiki/Home) is a good starting point. | ||
There's a specific page for the [version 13] release(./wiki/Version-13). | ||
For the code itself, the [API Documentation](doc/api.md) is a definitely a recommended read. | ||
## Documentation | ||
- [Guide](https://purchase.cordova.fovea.cc/) | ||
- [API Documentation](doc/api.md) | ||
- [Documentation for iOS](doc/ios.md) | ||
- [Documentation for Android](doc/android.md) | ||
- [Documentation for Windows](doc/windows.md) | ||
## Extra Resources | ||
@@ -153,4 +137,4 @@ | ||
Have a very simple need? Maybe this will help. | ||
- [Braintree SDK](https://github.com/j3k0/cordova-plugin-purchase-braintree) | ||
- Add the Braintree SDK to your application, enable Braintree on iOS and Android. | ||
- [Simple Non-Renewing Subscriptions](https://github.com/j3k0/cordova-non-renewing-subscription) | ||
@@ -162,8 +146,6 @@ - The easiest way to integrate purchase into an app that only needs a non-renewing subscription. | ||
For proper subscription support, you need a receipt validation server. You can | ||
implement your own or use [Fovea's receipt validation service](https://billing.fovea.cc). | ||
implement your own or use [Iaptic's receipt validation service](https://www.iaptic.com). | ||
# Contribute | ||
- [Contributor Guide](doc/contributor-guide.md) | ||
### Contributors: | ||
@@ -191,3 +173,3 @@ | ||
Copyright (c) 2014-2019, Jean-Christophe Hoelt and contributors | ||
Copyright (c) 2014-, Jean-Christophe HOELT and contributors | ||
@@ -194,0 +176,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy |
# Release Notes - Cordova Plugin Purchase | ||
## 13.0.0 | ||
- [Migration guide](https://github.com/j3k0/cordova-plugin-purchase/wiki/HOWTO:-Migrate-to-v13) | ||
## 12.0.0 | ||
### Upgrade to Google Play Billing library v5.0 | ||
With the upgrade to Google Play Billing library v5.0, many things will changes related to subscriptions, most importantly with the introduction of "subscription offers" and "pricing phases". | ||
**Receipt validations** | ||
Note that, at the time of writing this, validating purchases made with the Google Play Billing library v5.0 required the use the the SubscriptionV2 API. This API is already supported by [iaptic](https://www.iaptic.com/), the successor to Fovea's receipt validation service, so it might be a good option if you do not want to implement this new API. | ||
### (Google Play) `store.launchPriceChangeConfirmationFlow` - Update | ||
With Google Play, `store.launchPriceChangeConfirmationFlow(productId, callback)` is now the same as calling `store.manageSubscription()`. The underlying method provided by Google has been removed: https://developer.android.com/reference/com/android/billingclient/api/PriceChangeFlowParams - A deep link to the subscription management page on Google Play is now the newly recommended method. | ||
### NEW: `product.offers` - Subscription Offers support | ||
A single subscription product can now be purchased with different offers. See https://developer.android.com/google/play/billing/subscriptions | ||
To enable this new feature in a backward compatible way, the plugin will generate one product for each offer. | ||
The generated products will have all the attributes of a legacy subscription product, with those noticeable values: | ||
* `id`: `PARENT_PRODUCT_ID@OFFER_TOKEN`. | ||
* `group`: `PARENT_PRODUCT_ID`. | ||
The parent product will have an `offers` attributes. It's an array of strings containing the identifiers for all offers available to the user. | ||
You can get the information for those offers with `store.get(offerId)`, they are represented as virtual products. | ||
### NEW: `product.pricingPhases` - Flexible Pricing Phases support | ||
Google now allows more flexible pricing in multiple phases. While it's currently limited to 2 phases, the API doesn't really impose that limitation. | ||
To reflect this, the plugin now include prices in the `product.pricingPhases` attribute. It's an array of phases, with various costs, durations and recurrence modes. When present, this supersedes the legacy way of including prices and durations. | ||
Here is the newly defined type: | ||
```typescript | ||
/** Description of a phase for the pricing of a purchase. */ | ||
export interface IPricingPhase { | ||
/** Price formatted for humans */ | ||
price: string; | ||
/** Price in micro-units (divide by 1000000 to get numeric price) */ | ||
priceMicros: number; | ||
/** Currency code */ | ||
currency?: string; | ||
/** ISO 8601 duration of the period (https://en.wikipedia.org/wiki/ISO_8601#Durations) */ | ||
billingPeriod?: string; | ||
/** Number of recurrence cycles (if recurrenceMode is FINITE_RECURRING) */ | ||
billingCycles?: number; | ||
/** Type of recurring payment */ | ||
recurrenceMode?: RecurrenceMode; | ||
/** Payment mode for the pricing phase ("PayAsYouGo", "UpFront", or "FreeTrial") */ | ||
paymentMode?: IPaymentMode; | ||
} | ||
/** | ||
* Type of recurring payment | ||
* | ||
* - FINITE_RECURRING: Payment recurs for a fixed number of billing period set in `paymentPhase.cycles`. | ||
* - INFINITE_RECURRING: Payment recurs for infinite billing periods unless cancelled. | ||
* - NON_RECURRING: A one time charge that does not repeat. | ||
*/ | ||
export type RecurrenceMode = "NON_RECURRING" | "FINITE_RECURRING" | "INFINITE_RECURRING"; | ||
``` | ||
You can also keep the plugin in `v11` compatibility mode using `store.compatibility = 11` (or lower), in which case the legacy "introPrice", "billingPeriod" and such will be filled using the content of the pricingPhases array. Notice that this legacy mode can only support **at most** 2 pricing phases. | ||
When in `v11` compatibility mode: | ||
- prices and billing periods will be set using values from the last of the pricing phases. | ||
- intro prices and billing periods will be set with the values from the first pricing phase (if there are more than one) | ||
- product prices and billing periods will be set using values from the first offer for that product. | ||
### NEW: `store.compatibility` - Legacy compatibility | ||
Let the plugin operate in compatibility mode by filling in deprecated fields. By default, the plugin does not attempt to work in compatibility mode. | ||
* Anything lower than `12` will use the legacy product price definition instead of the more generic `offers` property. | ||
* Anything lower than `10` will use the old names for intro period period definitions. | ||
**NOTE**: the plugin might not be able to describe all Google Play subscription plans in compatibility mode (when non backward-compatible pricing modes are being used, for instance if there are more than 2 pricing phases). | ||
## 11.0.0 | ||
@@ -8,18 +94,30 @@ | ||
With the upgrade to the Billing Library v4, the main change was the way | ||
subscriptions are upgraded / downgraded. However, as this plugin offers a more | ||
high level interface, we were able to implement this migration in a non | ||
breaking way. | ||
With the upgrade to the Billing Library v4, the main change was the way subscriptions are upgraded / downgraded. However, as this plugin offers a more high level interface, we were able to implement this migration in a non breaking way. | ||
There are 2 noticeable additions to the API: | ||
#### Add `store.launchPriceChangeConfirmationFlow(productId, callback)` | ||
#### `store.launchPriceChangeConfirmationFlow(productId, callback)` | ||
Android only: display a generic dialog notifying the user of a subscription price change. | ||
See https://developer.android.com/google/play/billing/subscriptions#price-change-communicate | ||
* This call does nothing on iOS and Microsoft UWP. | ||
##### example usage | ||
```js | ||
store.launchPriceChangeConfirmationFlow('my_product_id', function(status) { | ||
if (status === "OK") { /* approved */ } | ||
if (status === "UserCanceled") { /* dialog canceled by user */ } | ||
if (status === "UnknownProduct") { /* trying to update price of an unregistered product */ } | ||
})); | ||
``` | ||
#### `"IMMEDIATE_AND_CHARGE_FULL_PRICE"` proration mode | ||
New proration mode that can be used when upgrading / downgrading a subscription. | ||
The proration mode is passed to `store.order()`, in the `additionalData.prorationMode` field. | ||
The replacement takes effect immediately, and the user is charged full price of | ||
new plan and is given a full billing cycle of subscription, plus remaining | ||
prorated time from the old plan. | ||
If `IMMEDIATE_AND_CHARGE_FULL_PRICE` proration mode is used when upgrading / downgrading a subscription, the replacement takes effect immediately, and the user is charged full price of new plan and is given a full billing cycle of subscription, plus remaining prorated time from the old plan. | ||
@@ -51,2 +149,42 @@ | ||
## 10.5.4 | ||
#### Add support for custom headers to validator call | ||
`store.validatorCustomHeaders` can be set to an object containing keys and values of headers to be sent to the receipt validation server. | ||
See 256a10e baae021 | ||
#### Minor changes | ||
* fb249b6 Adjust validator retry delay | ||
* When the request to the receipt validator fails, we now increase the retry delay to less agressive values. | ||
* 91489a4 (android) Query purchase on start every 24h only | ||
* The plugin used to query for purchases each time the app was sent to foreground. | ||
* No need to query more often than every 24h, to frequent calls used to causes issues (especially overlapping calls). | ||
* Ref #1110 | ||
#### Chores | ||
* 7be2fe6 Upgrade Google Billing Library to v3.0.3 | ||
* eda72d7 (typescript) Integrate the documentation | ||
* f8bd21d (typescript) Add typings for refresh() return value | ||
#### Bug fixes | ||
* ad70db7 (android) Fix #1126 - DEFERRED prorationMode typo | ||
## 10.5.2 | ||
* 7e9d58b (ios) Fix #1142 - Wrong references to `storekit.ERR_*` | ||
## 10.5.1 | ||
* c98817e Fix type chek error on tsc `^4.0.5` | ||
* Contributed by @caiiiycuk | ||
* 08e271d Minor improvement to `store.order()` | ||
## 10.5.0 | ||
@@ -53,0 +191,0 @@ |
@@ -228,4 +228,4 @@ /* global Windows */ | ||
fail("Your purchase has been reverted..", fulfillmentResult.purchaseReverted); | ||
// Since the user's purchase was revoked, they got their money back. | ||
// You may want to revoke the user's access to the consumable content that was granted. | ||
// Since the user's purchase was revoked, they got their money back. | ||
// You may want to revoke the user's access to the consumable content that was granted. | ||
break; | ||
@@ -232,0 +232,0 @@ case fulfillmentResult.serverError: |
# Note for plugin developers | ||
This folder contains minified version of the javascript file for each platform. | ||
This folder contains the generated version of the javascript file. | ||
They are assembled and minified from files located in `src/js`. | ||
They are assembled and minified from files located in `src/ts`. | ||
@@ -7,0 +7,0 @@ Compilation is done using the following command: |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1796164
283
21869
15
182
1