@purchasely/cordova-plugin-purchasely 5.1.0 → 5.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -33,7 +33,7 @@
33
33
  },
34
34
  "../../purchasely-google": {
35
35
  "name": "@purchasely/cordova-plugin-puchasely-google",
36
- "version": "5.1.0",
36
+ "version": "5.3.0",
37
37
  "dev": true,
38
38
  "license": "ISC"
39
39
  },
@@ -204,9 +204,9 @@
204
204
  }
205
205
  },
206
206
  "node_modules/brace-expansion": {
207
- "version": "1.1.11",
208
- "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
209
- "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
207
+ "version": "1.1.12",
208
+ "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.12.tgz",
209
+ "integrity": "sha512-9T9UjW3r0UW5c1Q7GTwllptXwhvYmEzFhzMfZ9H7FQWt+uZePjZPjBP/W1ZEyZ1twGWom5/56TF4lPcqjnDHcg==",
210
210
  "dev": true,
211
211
  "license": "MIT",
212
212
  "dependencies": {
@@ -259,21 +259,6 @@
259
259
  "node": ">=16.13.0"
260
260
  }
261
261
  },
262
- "node_modules/cordova-android/node_modules/dedent": {
263
- "version": "1.5.3",
264
- "resolved": "https://registry.npmjs.org/dedent/-/dedent-1.5.3.tgz",
265
- "integrity": "sha512-NHQtfOOW68WD8lgypbLA5oT+Bt0xXJhiYvoR6SmmNXZfpzOGXwdKWmcwG8N7PwVVWV3eF/68nmD9BaJSsTBhyQ==",
266
- "dev": true,
267
- "license": "MIT",
268
- "peerDependencies": {
269
- "babel-plugin-macros": "^3.1.0"
270
- },
271
- "peerDependenciesMeta": {
272
- "babel-plugin-macros": {
273
- "optional": true
274
- }
275
- }
276
- },
277
262
  "node_modules/cordova-common": {
278
263
  "version": "5.0.1",
279
264
  "resolved": "https://registry.npmjs.org/cordova-common/-/cordova-common-5.0.1.tgz",
@@ -390,6 +375,21 @@
390
375
  "node": ">= 8"
391
376
  }
392
377
  },
378
+ "node_modules/dedent": {
379
+ "version": "1.6.0",
380
+ "resolved": "https://registry.npmjs.org/dedent/-/dedent-1.6.0.tgz",
381
+ "integrity": "sha512-F1Z+5UCFpmQUzJa11agbyPVMbpgT/qA3/SKyJ1jyBgm7dUcUEa8v9JwDkerSQXfakBwFljIxhOJqGkjUwZ9FSA==",
382
+ "dev": true,
383
+ "license": "MIT",
384
+ "peerDependencies": {
385
+ "babel-plugin-macros": "^3.1.0"
386
+ },
387
+ "peerDependenciesMeta": {
388
+ "babel-plugin-macros": {
389
+ "optional": true
390
+ }
391
+ }
392
+ },
393
393
  "node_modules/elementtree": {
394
394
  "version": "0.1.7",
395
395
  "resolved": "https://registry.npmjs.org/elementtree/-/elementtree-0.1.7.tgz",
@@ -22,11 +22,12 @@
22
22
  },
23
23
  "cordova": {
24
24
  "plugins": {
25
- "@purchasely/cordova-plugin-puchasely-google": {}
25
+ "@purchasely/cordova-plugin-puchasely-google": {},
26
+ "@purchasely/cordova-plugin-purchasely": {}
26
27
  },
27
28
  "platforms": [
28
29
  "android",
29
30
  "ios"
30
31
  ]
31
32
  }
32
- }
33
+ }
@@ -17,6 +17,18 @@
17
17
  * under the License.
18
18
  */
19
19
 
20
+ function safeStringify(obj, space = 2) {
21
+ const seen = new WeakSet();
22
+ return JSON.stringify(obj, (key, value) => {
23
+ if (typeof value === 'object' && value !== null) {
24
+ if (seen.has(value)) {
25
+ return '[Circular Reference]';
26
+ }
27
+ seen.add(value);
28
+ }
29
+ return value;
30
+ }, space);
31
+ }
20
32
 
21
33
  // Wait for the deviceready event before using any of Cordova's device APIs.
22
34
  // See https://cordova.apache.org/docs/en/latest/cordova/events/events.html#deviceready
@@ -69,8 +81,8 @@ function onPuchaselySdkReady() {
69
81
 
70
82
  Purchasely.addEventsListener((event) => {
71
83
  console.log("Event Name " + event.name);
72
- console.log(event.properties);
73
- console.log(event);
84
+ console.log(safeStringify(event.properties));
85
+ console.log(safeStringify(event));
74
86
  }, (error) => {
75
87
  console.log(error);
76
88
  });
@@ -288,7 +300,7 @@ function fetchPresentation() {
288
300
  'onboarding', //placementId
289
301
  null, //contentId
290
302
  (presentation) => {
291
- console.log(presentation);
303
+ console.log(safeStringify(presentation));
292
304
  Purchasely.presentPresentation(presentation, false, null,
293
305
  (callback) => {
294
306
  console.log(callback);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@purchasely/cordova-plugin-purchasely",
3
- "version": "5.1.0",
3
+ "version": "5.3.0",
4
4
  "description": "Purchasely is a solution to ease the integration and boost your In-App Purchases & Subscriptions on the App Store, Google Play Store, Amazon Appstore and Huawei App Gallery.",
5
5
  "cordova": {
6
6
  "id": "@purchasely/cordova-plugin-purchasely",
package/plugin.xml CHANGED
@@ -1,5 +1,5 @@
1
1
  <?xml version='1.0' encoding='utf-8'?>
2
- <plugin id="@purchasely/cordova-plugin-purchasely" version="5.1.0" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
2
+ <plugin id="@purchasely/cordova-plugin-purchasely" version="5.3.0" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
3
3
  <name>Purchasely</name>
4
4
  <js-module name="Purchasely" src="www/Purchasely.js">
5
5
  <clobbers target="Purchasely" />
@@ -38,7 +38,7 @@
38
38
  <source url="https://github.com/CocoaPods/Specs.git"/>
39
39
  </config>
40
40
  <pods use-frameworks="true">
41
- <pod name="Purchasely" spec="5.1.0"/>
41
+ <pod name="Purchasely" spec="5.3.7"/>
42
42
  </pods>
43
43
  </podspec>
44
44
  </platform>
@@ -63,7 +63,7 @@
63
63
  android:theme="@style/Theme.AppCompat.Light.NoActionBar">
64
64
  </activity>
65
65
  </config-file>
66
- <framework src="io.purchasely:core:5.1.0" />
66
+ <framework src="io.purchasely:core:5.3.7" />
67
67
  <source-file src="src/android/PurchaselyPlugin.kt" target-dir="java/cordova/plugin/purchasely" />
68
68
  <source-file src="src/android/PLYProductActivity.kt" target-dir="java/cordova/plugin/purchasely" />
69
69
  <source-file src="src/android/PLYSubscriptionsActivity.java" target-dir="src/cordova/plugin/purchasely" />
@@ -562,10 +562,17 @@ class PurchaselyPlugin : CordovaPlugin() {
562
562
  purchaseCallback = callbackContext
563
563
 
564
564
  cordova.activity.let { activity ->
565
- val intent = PLYProductActivity.newIntent(activity, PLYPresentationProperties(), isFullScreen, loadingBackgroundColor).apply {
566
- putExtra("presentation", presentation)
565
+ if (presentation.flowId != null) {
566
+ presentation.display(activity) { result, plan ->
567
+ sendPurchaseResult(result, plan)
568
+ }
569
+ } else {
570
+ // Open legacy Activity for now if not a flow
571
+ val intent = PLYProductActivity.newIntent(activity, PLYPresentationProperties(), isFullScreen, loadingBackgroundColor).apply {
572
+ putExtra("presentation", presentation)
573
+ }
574
+ activity.startActivity(intent)
567
575
  }
568
- activity.startActivity(intent)
569
576
  }
570
577
 
571
578
  }
@@ -550,6 +550,9 @@
550
550
  case PLYPresentationActionClose:
551
551
  actionString = @"close";
552
552
  break;
553
+ case PLYPresentationActionCloseAll:
554
+ actionString = @"close_all";
555
+ break;
553
556
  case PLYPresentationActionRestore:
554
557
  actionString = @"restore";
555
558
  break;
@@ -562,6 +565,12 @@
562
565
  case PLYPresentationActionOpenPresentation:
563
566
  actionString = @"open_presentation";
564
567
  break;
568
+ case PLYPresentationActionOpenPlacement:
569
+ actionString = @"open_placement";
570
+ break;
571
+ case PLYPresentationActionWebCheckout:
572
+ actionString = @"web_checkout";
573
+ break;
565
574
  }
566
575
 
567
576
  [actionInterceptorResult setObject:actionString forKey:@"action"];
@@ -606,12 +615,31 @@
606
615
  [promoOffer setObject:params.promoOffer.storeOfferId forKey:@"storeOfferId"];
607
616
  [paramsResult setObject:promoOffer forKey:@"offer"];
608
617
  }
618
+ NSString *webCheckoutProviderString = PLYWebCheckoutProviderToString(params.webCheckoutProvider);
619
+ [paramsResult setObject:webCheckoutProviderString forKey:@"webCheckoutProvider"];
620
+ if (params.queryParameterKey != nil) {
621
+ [paramsResult setObject:params.queryParameterKey forKey:@"queryParameterKey"];
622
+ }
623
+ if (params.clientReferenceId != nil) {
624
+ [paramsResult setObject:params.clientReferenceId forKey:@"clientReferenceId"];
625
+ }
609
626
  [actionInterceptorResult setObject:paramsResult forKey:@"parameters"];
610
627
  }
611
-
628
+
612
629
  return actionInterceptorResult;
613
630
  }
614
631
 
632
+ static NSString * PLYWebCheckoutProviderToString(PLYWebCheckoutProvider provider) {
633
+ switch (provider) {
634
+ case PLYWebCheckoutProviderStripe:
635
+ return @"stripe";
636
+ case PLYWebCheckoutProviderOther:
637
+ return @"other";
638
+ default:
639
+ return @"unknown";
640
+ }
641
+ }
642
+
615
643
  - (void)setPaywallActionInterceptor:(CDVInvokedUrlCommand*)command {
616
644
  self.paywallActionInterceptorCommand = command;
617
645
  [Purchasely setPaywallActionsInterceptor:^(enum PLYPresentationAction action, PLYPresentationActionParameters * _Nullable parameters, PLYPresentationInfo * _Nullable infos, void (^ _Nonnull onProcessActionHandler)(BOOL)) {
@@ -860,7 +888,11 @@
860
888
  [Purchasely closeDisplayedPresentation];
861
889
  self.presentedPresentationViewController = presentationLoaded.controller;
862
890
  dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.5 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
863
- [Purchasely showController:presentationLoaded.controller type: PLYUIControllerTypeProductPage from:nil];
891
+ if (presentationLoaded.isFlow) {
892
+ [presentationLoaded displayFrom:nil];
893
+ } else {
894
+ [Purchasely showController:presentationLoaded.controller type: PLYUIControllerTypeProductPage from:nil];
895
+ }
864
896
  });
865
897
  }
866
898
  });
package/www/Purchasely.js CHANGED
@@ -5,7 +5,7 @@ var defaultError = (e) => { console.log(e); }
5
5
  exports.start = function (apiKey, stores, storekit1, userId, logLevel, runningMode, success, error) {
6
6
  var cordovaSdkVersion = cordova.define.moduleMap['cordova/plugin_list'].exports['metadata']['cordova-plugin-purchasely']
7
7
  if(!cordovaSdkVersion) {
8
- cordovaSdkVersion = "5.1.0";
8
+ cordovaSdkVersion = "5.3.0";
9
9
  }
10
10
  exec(success, error, 'Purchasely', 'start', [apiKey, stores, storekit1, userId, logLevel, runningMode, cordovaSdkVersion]);
11
11
  };