react-native-iap 11.0.0-rc.2 → 11.0.0-rc.4
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/ios/IapSerializationUtils.swift +50 -11
- package/ios/IapTypes.swift +1 -6
- package/ios/RNIapIos.m +3 -0
- package/ios/RNIapIos.swift +12 -3
- package/ios/RNIapIosSk2.m +6 -1
- package/ios/RNIapIosSk2.swift +37 -16
- package/lib/commonjs/eventEmitter.js +145 -2
- package/lib/commonjs/eventEmitter.js.map +1 -1
- package/lib/commonjs/hooks/withIAPContext.js +8 -1
- package/lib/commonjs/hooks/withIAPContext.js.map +1 -1
- package/lib/commonjs/iap.js +81 -37
- package/lib/commonjs/iap.js.map +1 -1
- package/lib/commonjs/internal/platform.js +33 -4
- package/lib/commonjs/internal/platform.js.map +1 -1
- package/lib/commonjs/modules/ios.js +5 -2
- package/lib/commonjs/modules/ios.js.map +1 -1
- package/lib/commonjs/modules/iosSk2.js.map +1 -1
- package/lib/commonjs/types/apple.js +24 -0
- package/lib/commonjs/types/apple.js.map +1 -1
- package/lib/commonjs/types/appleSk2.js +3 -3
- package/lib/commonjs/types/appleSk2.js.map +1 -1
- package/lib/commonjs/types/index.js.map +1 -1
- package/lib/module/eventEmitter.js +141 -1
- package/lib/module/eventEmitter.js.map +1 -1
- package/lib/module/hooks/withIAPContext.js +9 -2
- package/lib/module/hooks/withIAPContext.js.map +1 -1
- package/lib/module/iap.js +77 -30
- package/lib/module/iap.js.map +1 -1
- package/lib/module/internal/platform.js +25 -2
- package/lib/module/internal/platform.js.map +1 -1
- package/lib/module/modules/ios.js +5 -2
- package/lib/module/modules/ios.js.map +1 -1
- package/lib/module/modules/iosSk2.js.map +1 -1
- package/lib/module/types/apple.js +15 -0
- package/lib/module/types/apple.js.map +1 -1
- package/lib/module/types/appleSk2.js +3 -3
- package/lib/module/types/appleSk2.js.map +1 -1
- package/lib/module/types/index.js.map +1 -1
- package/lib/typescript/eventEmitter.d.ts +133 -0
- package/lib/typescript/hooks/withIAPContext.d.ts +2 -0
- package/lib/typescript/iap.d.ts +25 -4
- package/lib/typescript/internal/platform.d.ts +3 -1
- package/lib/typescript/modules/ios.d.ts +2 -1
- package/lib/typescript/modules/iosSk2.d.ts +3 -2
- package/lib/typescript/types/apple.d.ts +1 -0
- package/lib/typescript/types/appleSk2.d.ts +31 -2
- package/lib/typescript/types/index.d.ts +1 -0
- package/package.json +1 -1
- package/src/eventEmitter.ts +144 -2
- package/src/hooks/withIAPContext.tsx +15 -0
- package/src/iap.ts +55 -17
- package/src/internal/platform.ts +24 -2
- package/src/modules/ios.ts +7 -3
- package/src/modules/iosSk2.ts +5 -2
- package/src/types/apple.ts +15 -0
- package/src/types/appleSk2.ts +42 -5
- package/src/types/index.ts +1 -0
package/src/types/apple.ts
CHANGED
|
@@ -27,3 +27,18 @@ export interface PaymentDiscount {
|
|
|
27
27
|
*/
|
|
28
28
|
timestamp: number;
|
|
29
29
|
}
|
|
30
|
+
|
|
31
|
+
export const offerToRecord = (
|
|
32
|
+
offer: PaymentDiscount | undefined,
|
|
33
|
+
): Record<keyof PaymentDiscount, string> | undefined => {
|
|
34
|
+
if (!offer) {
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
identifier: offer.identifier,
|
|
39
|
+
keyIdentifier: offer.keyIdentifier,
|
|
40
|
+
nonce: offer.nonce,
|
|
41
|
+
signature: offer.signature,
|
|
42
|
+
timestamp: offer.timestamp.toString(),
|
|
43
|
+
};
|
|
44
|
+
};
|
package/src/types/appleSk2.ts
CHANGED
|
@@ -1,5 +1,32 @@
|
|
|
1
|
+
import type {PurchaseError} from '../purchaseError';
|
|
2
|
+
|
|
1
3
|
import type {ProductIOS, Purchase, SubscriptionIOS} from '.';
|
|
2
4
|
import type * as Apple from './apple';
|
|
5
|
+
|
|
6
|
+
export type SubscriptionPeriod = {
|
|
7
|
+
unit: 'day' | 'week' | 'month' | 'year';
|
|
8
|
+
value: number;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export type PaymentMode = 'freeTrial' | 'payAsYouGo' | 'payUpFront';
|
|
12
|
+
|
|
13
|
+
export type SubscriptionOffer = {
|
|
14
|
+
displayPrice: string;
|
|
15
|
+
id: string;
|
|
16
|
+
paymentMode: PaymentMode;
|
|
17
|
+
period: SubscriptionPeriod;
|
|
18
|
+
periodCount: number;
|
|
19
|
+
price: number;
|
|
20
|
+
type: 'introductory' | 'promotional';
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export type SubscriptionInfo = {
|
|
24
|
+
introductoryOffer?: SubscriptionOffer;
|
|
25
|
+
promotionalOffers?: SubscriptionOffer[];
|
|
26
|
+
subscriptionGroupID: string;
|
|
27
|
+
subscriptionPeriod: SubscriptionPeriod;
|
|
28
|
+
};
|
|
29
|
+
|
|
3
30
|
export type ProductSk2 = {
|
|
4
31
|
description: string;
|
|
5
32
|
displayName: string;
|
|
@@ -8,7 +35,7 @@ export type ProductSk2 = {
|
|
|
8
35
|
isFamilyShareable: boolean;
|
|
9
36
|
jsonRepresentation: string;
|
|
10
37
|
price: number;
|
|
11
|
-
subscription:
|
|
38
|
+
subscription: SubscriptionInfo;
|
|
12
39
|
type: 'autoRenewable' | 'consumable' | 'nonConsumable' | 'nonRenewable';
|
|
13
40
|
};
|
|
14
41
|
export const productSk2Map = ({
|
|
@@ -25,7 +52,7 @@ export const productSk2Map = ({
|
|
|
25
52
|
type: 'iap',
|
|
26
53
|
price: String(price),
|
|
27
54
|
localizedPrice: displayPrice,
|
|
28
|
-
currency: '', //
|
|
55
|
+
currency: '', // Not avaiable on new API, use localizedPrice instead
|
|
29
56
|
};
|
|
30
57
|
return prod;
|
|
31
58
|
};
|
|
@@ -44,7 +71,7 @@ export const subscriptionSk2Map = ({
|
|
|
44
71
|
type: 'subs',
|
|
45
72
|
price: String(price),
|
|
46
73
|
localizedPrice: displayPrice,
|
|
47
|
-
currency: '', //
|
|
74
|
+
currency: '', // Not avaiable on new API, use localizedPrice instead
|
|
48
75
|
};
|
|
49
76
|
return prod;
|
|
50
77
|
};
|
|
@@ -75,6 +102,16 @@ export type TransactionSk2 = {
|
|
|
75
102
|
webOrderLineItemID: number;
|
|
76
103
|
};
|
|
77
104
|
|
|
105
|
+
export type TransactionError = PurchaseError;
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Only one of `transaction` and `error` is not undefined at the time
|
|
109
|
+
*/
|
|
110
|
+
export type TransactionEvent = {
|
|
111
|
+
transaction?: TransactionSk2;
|
|
112
|
+
error?: TransactionError;
|
|
113
|
+
};
|
|
114
|
+
|
|
78
115
|
export type SubscriptionStatus =
|
|
79
116
|
| 'expired'
|
|
80
117
|
| 'inBillingRetryPeriod'
|
|
@@ -138,7 +175,7 @@ export interface PaymentDiscountSk2 {
|
|
|
138
175
|
|
|
139
176
|
export const offerSk2Map = (
|
|
140
177
|
offer: Apple.PaymentDiscount | undefined,
|
|
141
|
-
): PaymentDiscountSk2 | undefined => {
|
|
178
|
+
): Record<keyof PaymentDiscountSk2, string> | undefined => {
|
|
142
179
|
if (!offer) {
|
|
143
180
|
return undefined;
|
|
144
181
|
}
|
|
@@ -147,6 +184,6 @@ export const offerSk2Map = (
|
|
|
147
184
|
keyID: offer.keyIdentifier,
|
|
148
185
|
nonce: offer.nonce,
|
|
149
186
|
signature: offer.signature,
|
|
150
|
-
timestamp: offer.timestamp,
|
|
187
|
+
timestamp: offer.timestamp.toString(),
|
|
151
188
|
};
|
|
152
189
|
};
|