apps-sdk 1.0.43 → 1.0.44
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.
- package/package.json +1 -1
- package/src/libraries/PayWallLogic.js +47 -37
package/package.json
CHANGED
|
@@ -16,46 +16,55 @@ class PayWallLogic {
|
|
|
16
16
|
purchaseErrorSubscription;
|
|
17
17
|
|
|
18
18
|
async initializePayWall() {
|
|
19
|
-
|
|
19
|
+
try {
|
|
20
|
+
await initConnection();
|
|
20
21
|
|
|
21
22
|
if(Platform.OS === 'android'){
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
23
|
+
try {
|
|
24
|
+
await flushFailedPurchasesCachedAsPendingAndroid();
|
|
25
|
+
} catch (error) {
|
|
26
|
+
console.log('Error en flushFailedPurchasesCachedAsPendingAndroid', error);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
this.purchaseUpdateSubscription = purchaseUpdatedListener(
|
|
30
|
+
async (purchase) => {
|
|
31
|
+
try {
|
|
32
|
+
console.log('purchaseUpdatedListener', purchase);
|
|
33
|
+
const receipt = purchase.transactionReceipt;
|
|
34
|
+
if (receipt) {
|
|
35
|
+
const subscription = await getSubscriptions({skus: [purchase.productId]})
|
|
36
|
+
const s = subscription[0];
|
|
37
|
+
await finishTransaction({purchase: purchase});
|
|
38
|
+
let data = this.purchaseResp(s,purchase.purchaseToken)
|
|
39
|
+
const purchaseResponse = await Networking.createSubscription(data);
|
|
40
|
+
if(purchaseResponse.success){
|
|
41
|
+
Session.setIsSubscribed(true);
|
|
42
|
+
Session.setSubscriptionData(purchaseResponse.data);
|
|
41
43
|
}
|
|
42
|
-
}
|
|
43
|
-
)
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
}
|
|
45
|
+
} catch (error) {
|
|
46
|
+
console.log('Error en purchaseUpdatedListener', error);
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
);
|
|
50
|
+
} else {
|
|
46
51
|
this.purchaseUpdateSubscription = purchaseUpdatedListener(
|
|
47
52
|
async (purchase) => {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
53
|
+
try {
|
|
54
|
+
console.log('SDK purchaseUpdatedListener purchase',purchase)
|
|
55
|
+
const subscription = await getSubscriptions({skus: [purchase.productId]})
|
|
56
|
+
const s = subscription[0];
|
|
57
|
+
await finishTransaction({purchase: purchase,isConsumable:true});
|
|
58
|
+
let data = this.purchaseResp(s,(purchase.originalTransactionIdentifierIOS ? purchase.originalTransactionIdentifierIOS : purchase.transactionId))
|
|
59
|
+
const purchaseResponse = await Networking.createSubscription(data);
|
|
60
|
+
if(purchaseResponse.success){
|
|
61
|
+
Session.setIsSubscribed(true);
|
|
62
|
+
Session.setSubscriptionData(purchaseResponse.data);
|
|
63
|
+
} else {
|
|
64
|
+
console.log('SDK checkSubscription fail')
|
|
65
|
+
}
|
|
66
|
+
} catch (error) {
|
|
67
|
+
console.log('Error en SDK purchaseUpdatedListener', error);
|
|
59
68
|
}
|
|
60
69
|
},
|
|
61
70
|
);
|
|
@@ -66,8 +75,9 @@ class PayWallLogic {
|
|
|
66
75
|
console.log('purchaseErrorListener', error);
|
|
67
76
|
},
|
|
68
77
|
);
|
|
69
|
-
|
|
70
|
-
|
|
78
|
+
} catch (error) {
|
|
79
|
+
console.log('Error en initializePayWall', error);
|
|
80
|
+
}
|
|
71
81
|
}
|
|
72
82
|
|
|
73
83
|
purchaseResp = (subscription, purchaseToken) => {
|