cordova-plugin-purchase
Advanced tools
Comparing version 13.1.3 to 13.1.4
@@ -24,2 +24,3 @@ # Class: Adapter | ||
- [discountEligibilityDeterminer](CdvPurchase.AppleAppStore.Adapter.md#discounteligibilitydeterminer) | ||
- [forceReceiptRefresh](CdvPurchase.AppleAppStore.Adapter.md#forcereceiptrefresh) | ||
- [id](CdvPurchase.AppleAppStore.Adapter.md#id) | ||
@@ -106,2 +107,12 @@ - [log](CdvPurchase.AppleAppStore.Adapter.md#log) | ||
### forceReceiptRefresh | ||
• **forceReceiptRefresh**: `boolean` = `false` | ||
Set to true to force a full refresh of the receipt when preparing a receipt validation call. | ||
This is typically done when placing an order and restoring purchases. | ||
___ | ||
### id | ||
@@ -108,0 +119,0 @@ |
@@ -138,3 +138,3 @@ # Class: Bridge | ||
| `success` | () => `void` | | ||
| `error` | () => `void` | | ||
| `error` | (`msg`: `string`) => `void` | | ||
@@ -141,0 +141,0 @@ #### Returns |
@@ -155,3 +155,3 @@ # Namespace: CdvPurchase | ||
• `Const` **PLUGIN\_VERSION**: ``"13.1.3"`` | ||
• `Const` **PLUGIN\_VERSION**: ``"13.1.4"`` | ||
@@ -158,0 +158,0 @@ Current release number of the plugin. |
{ | ||
"name": "cordova-plugin-purchase", | ||
"version": "13.1.3", | ||
"version": "13.1.4", | ||
"description": "Cordova Purchase plugin for iOS, Android, Windows (AppStore, Play, UWP)", | ||
@@ -5,0 +5,0 @@ "cordova": { |
@@ -69,2 +69,9 @@ /// <reference path="../../types.ts" /> | ||
/** | ||
* Set to true to force a full refresh of the receipt when preparing a receipt validation call. | ||
* | ||
* This is typically done when placing an order and restoring purchases. | ||
*/ | ||
forceReceiptRefresh = false; | ||
/** List of products loaded from AppStore */ | ||
@@ -381,2 +388,5 @@ _products: SKProduct[] = []; | ||
} | ||
// When we switch AppStore user, the cached receipt isn't from the new user. | ||
// so after a purchase, we want to make sure we're using the receipt from the logged in user. | ||
this.forceReceiptRefresh = true; | ||
this.bridge.purchase(offer.productId, 1, this.context.getApplicationUsername(), discountId, success, error); | ||
@@ -401,4 +411,10 @@ }); | ||
} | ||
const error = () => { | ||
resolve(storeError(ErrorCode.FINISH, 'Failed to finish transaction')); | ||
const error = (msg: string) => { | ||
if (msg?.includes('[#CdvPurchase:100]')) { | ||
// already finished | ||
success(); | ||
} | ||
else { | ||
resolve(storeError(ErrorCode.FINISH, 'Failed to finish transaction')); | ||
} | ||
} | ||
@@ -426,3 +442,4 @@ this.bridge.finish(transaction.transactionId, success, error); | ||
let applicationReceipt = skReceipt.nativeData; | ||
if (!skReceipt.nativeData.appStoreReceipt) { | ||
if (this.forceReceiptRefresh || !skReceipt.nativeData.appStoreReceipt) { | ||
this.forceReceiptRefresh = false; | ||
this.log.info('Cannot prepare the receipt validation body, because appStoreReceipt is missing. Refreshing...'); | ||
@@ -494,2 +511,3 @@ const result = await this.refreshReceipt(); | ||
return new Promise(resolve => { | ||
this.forceReceiptRefresh = true; | ||
this.bridge.restore(); | ||
@@ -496,0 +514,0 @@ this.bridge.refreshReceipts(obj => { |
@@ -480,3 +480,3 @@ namespace CdvPurchase { | ||
*/ | ||
finish(transactionId: string, success: () => void, error: () => void) { | ||
finish(transactionId: string, success: () => void, error: (msg: string) => void) { | ||
exec('finishTransaction', [transactionId], success, error); | ||
@@ -483,0 +483,0 @@ } |
@@ -27,3 +27,3 @@ /// <reference path="validator/validator.ts" /> | ||
*/ | ||
export const PLUGIN_VERSION = '13.1.3'; | ||
export const PLUGIN_VERSION = '13.1.4'; | ||
@@ -30,0 +30,0 @@ /** |
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 too big to display
Sorry, the diff of this file is too big to display
1860078
23928