cordova-plugin-purchase
Advanced tools
Comparing version 13.4.3 to 13.5.0
@@ -22,2 +22,3 @@ # Interface: Options<T\> | ||
- [success](CdvPurchase.Utils.Ajax.Options.md#success) | ||
- [timeout](CdvPurchase.Utils.Ajax.Options.md#timeout) | ||
- [url](CdvPurchase.Utils.Ajax.Options.md#url) | ||
@@ -71,2 +72,10 @@ | ||
### timeout | ||
• `Optional` **timeout**: `number` | ||
Request timeout in milliseconds | ||
___ | ||
### url | ||
@@ -73,0 +82,0 @@ |
@@ -11,2 +11,4 @@ # Interface: Function | ||
Receipt validator as a function. | ||
#### Parameters | ||
@@ -13,0 +15,0 @@ |
@@ -5,2 +5,4 @@ # Interface: Target | ||
Custom definition of the validation request target. | ||
## Table of contents | ||
@@ -11,2 +13,3 @@ | ||
- [headers](CdvPurchase.Validator.Target.md#headers) | ||
- [timeout](CdvPurchase.Validator.Target.md#timeout) | ||
- [url](CdvPurchase.Validator.Target.md#url) | ||
@@ -20,2 +23,4 @@ | ||
Custom headers | ||
#### Index signature | ||
@@ -27,4 +32,14 @@ | ||
### timeout | ||
• `Optional` **timeout**: `number` | ||
Request timeout in millseconds | ||
___ | ||
### url | ||
• **url**: `string` | ||
URL of the receipt validator |
@@ -156,3 +156,3 @@ # Namespace: CdvPurchase | ||
• `Const` **PLUGIN\_VERSION**: ``"13.4.3"`` | ||
• `Const` **PLUGIN\_VERSION**: ``"13.5.0"`` | ||
@@ -159,0 +159,0 @@ Current release number of the plugin. |
@@ -16,2 +16,6 @@ # Namespace: Ajax | ||
### Variables | ||
- [HTTP\_REQUEST\_TIMEOUT](CdvPurchase.Utils.Ajax.md#http_request_timeout) | ||
## Type Aliases | ||
@@ -68,1 +72,9 @@ | ||
`void` | ||
## Variables | ||
### HTTP\_REQUEST\_TIMEOUT | ||
• `Const` **HTTP\_REQUEST\_TIMEOUT**: ``408`` | ||
HTTP status returned when a request times out |
{ | ||
"name": "cordova-plugin-purchase", | ||
"version": "13.4.3", | ||
"version": "13.5.0", | ||
"description": "Cordova Purchase plugin for iOS, Android, Windows (AppStore, Play, UWP)", | ||
@@ -5,0 +5,0 @@ "cordova": { |
@@ -80,3 +80,3 @@ # Cordova Purchase Plugin | ||
Capacitor users can install this new version of the plugin without the help of the awesome-cordova-plugins wrapper. Just install the `cordova-plugin-purchase` module and `import "cordova-plugin-purchase"` in files where it's needed. | ||
Capacitor users can install this new version of the plugin without the help of the awesome-cordova-plugins wrapper. Just install the `cordova-plugin-purchase` module and `import "cordova-plugin-purchase"` in files where it's needed. (some user reported using `import "cordova-plugin-purchase/www/store.d"` to get it working). | ||
@@ -83,0 +83,0 @@ As with other plugins, you should wait for Capacitor `this.platform.ready()` before using the plugin. |
# Release Notes - Cordova Plugin Purchase | ||
## 13.5 | ||
### 13.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: | ||
```ts | ||
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: | ||
```ts | ||
CdvPurchase.store.validator = { | ||
url: 'https://validator.iaptic.com', | ||
timeout: 30000, // in milliseconds | ||
} | ||
``` | ||
## 13.4 | ||
@@ -4,0 +31,0 @@ |
@@ -35,2 +35,7 @@ // | ||
store.validator = { | ||
url: 'https://validator.iaptic.com', | ||
timeout: 30000, | ||
} | ||
store.when() | ||
@@ -37,0 +42,0 @@ .approved(transaction => transaction.verify()) |
@@ -27,3 +27,3 @@ /// <reference path="validator/validator.ts" /> | ||
*/ | ||
export const PLUGIN_VERSION = '13.4.3'; | ||
export const PLUGIN_VERSION = '13.5.0'; | ||
@@ -30,0 +30,0 @@ /** |
@@ -10,2 +10,5 @@ // plugins or browser extensions | ||
/** HTTP status returned when a request times out */ | ||
export const HTTP_REQUEST_TIMEOUT = 408; | ||
/** Success callback for an ajax call */ | ||
@@ -37,2 +40,5 @@ export type SuccessCallback<T> = (body: T) => void; | ||
customHeaders?: { [key: string]: string }; | ||
/** Request timeout in milliseconds */ | ||
timeout?: number; | ||
} | ||
@@ -57,2 +63,9 @@ | ||
var xhr = new XMLHttpRequest(); | ||
if (options.timeout) { | ||
xhr.timeout = options.timeout; | ||
xhr.ontimeout = function (/*event*/) { | ||
log.warn("ajax -> request to " + options.url + " timeout"); | ||
Utils.callExternal(log, 'ajax.error', options.error as Function, Ajax.HTTP_REQUEST_TIMEOUT, "Timeout"); | ||
}; | ||
} | ||
xhr.open(options.method || 'POST', options.url, true); | ||
@@ -59,0 +72,0 @@ xhr.onreadystatechange = function (/*event*/) { |
@@ -10,2 +10,5 @@ namespace CdvPurchase { | ||
/** | ||
* Receipt validator as a function. | ||
*/ | ||
export interface Function { | ||
@@ -15,5 +18,15 @@ (receipt: Validator.Request.Body, callback: Callback<Validator.Response.Payload>): void; | ||
/** | ||
* Custom definition of the validation request target. | ||
*/ | ||
export interface Target { | ||
/** URL of the receipt validator */ | ||
url: string; | ||
/** Custom headers */ | ||
headers?: { [token: string]: string }; | ||
/** Request timeout in millseconds */ | ||
timeout?: number; | ||
} | ||
@@ -20,0 +33,0 @@ |
@@ -132,3 +132,6 @@ namespace CdvPurchase { | ||
const target: Validator.Target = typeof this.controller.validator === 'string' | ||
? { url: this.controller.validator } | ||
? { | ||
url: this.controller.validator, | ||
timeout: 20000, // validation request will timeout after 20 seconds by default | ||
} | ||
: this.controller.validator; | ||
@@ -228,2 +231,3 @@ | ||
customHeaders: target.headers, | ||
timeout: target.timeout, | ||
data: body, | ||
@@ -230,0 +234,0 @@ success: (response) => { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
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
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
1905411
24503