@dicty/payment 2.0.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.
- package/DictyPayment.podspec +17 -0
- package/README.md +249 -0
- package/android/build.gradle +66 -0
- package/android/src/main/AndroidManifest.xml +9 -0
- package/android/src/main/java/app/dicty/plugins/stripe/GooglePayEvents.java +21 -0
- package/android/src/main/java/app/dicty/plugins/stripe/MetaData.java +38 -0
- package/android/src/main/java/app/dicty/plugins/stripe/PaymentPlugin.java +90 -0
- package/android/src/main/res/.gitkeep +0 -0
- package/dist/docs.json +425 -0
- package/dist/esm/definitions.d.ts +98 -0
- package/dist/esm/definitions.js +2 -0
- package/dist/esm/definitions.js.map +1 -0
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/provider/react/PaymentPluginProvider.d.ts +7 -0
- package/dist/esm/provider/react/PaymentPluginProvider.js +52 -0
- package/dist/esm/provider/react/PaymentPluginProvider.js.map +1 -0
- package/dist/esm/web.d.ts +17 -0
- package/dist/esm/web.js +31 -0
- package/dist/esm/web.js.map +1 -0
- package/dist/plugin.cjs.js +45 -0
- package/dist/plugin.cjs.js.map +1 -0
- package/dist/plugin.js +48 -0
- package/dist/plugin.js.map +1 -0
- package/ios/Sources/PaymentPlugin/InAppPurchaseStatus.swift +6 -0
- package/ios/Sources/PaymentPlugin/Info.plist +24 -0
- package/ios/Sources/PaymentPlugin/PaymentPlugin.swift +256 -0
- package/package.json +93 -0
package/dist/docs.json
ADDED
|
@@ -0,0 +1,425 @@
|
|
|
1
|
+
{
|
|
2
|
+
"api": {
|
|
3
|
+
"name": "PaymentPlugin",
|
|
4
|
+
"slug": "paymentplugin",
|
|
5
|
+
"docs": "",
|
|
6
|
+
"tags": [],
|
|
7
|
+
"methods": [
|
|
8
|
+
{
|
|
9
|
+
"name": "isAppleInAppPurchaseAvailable",
|
|
10
|
+
"signature": "() => Promise<void>",
|
|
11
|
+
"parameters": [],
|
|
12
|
+
"returns": "Promise<void>",
|
|
13
|
+
"tags": [],
|
|
14
|
+
"docs": "Check if Apple In-App Purchases are available on this device",
|
|
15
|
+
"complexTypes": [],
|
|
16
|
+
"slug": "isappleinapppurchaseavailable"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"name": "getAppleInAppPurchaseProducts",
|
|
20
|
+
"signature": "(opts: GetAppleInAppPurchaseProductsOptions) => Promise<GetAppleInAppPurchaseProductsResult>",
|
|
21
|
+
"parameters": [
|
|
22
|
+
{
|
|
23
|
+
"name": "opts",
|
|
24
|
+
"docs": "",
|
|
25
|
+
"type": "GetAppleInAppPurchaseProductsOptions"
|
|
26
|
+
}
|
|
27
|
+
],
|
|
28
|
+
"returns": "Promise<GetAppleInAppPurchaseProductsResult>",
|
|
29
|
+
"tags": [],
|
|
30
|
+
"docs": "Get Apple In-App Purchase products by their identifiers",
|
|
31
|
+
"complexTypes": [
|
|
32
|
+
"GetAppleInAppPurchaseProductsResult",
|
|
33
|
+
"GetAppleInAppPurchaseProductsOptions"
|
|
34
|
+
],
|
|
35
|
+
"slug": "getappleinapppurchaseproducts"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"name": "buyAppleInAppPurchase",
|
|
39
|
+
"signature": "(opts: BuyAppleInAppPurchaseOptions) => Promise<BuyAppleInAppPurchaseResult>",
|
|
40
|
+
"parameters": [
|
|
41
|
+
{
|
|
42
|
+
"name": "opts",
|
|
43
|
+
"docs": "",
|
|
44
|
+
"type": "BuyAppleInAppPurchaseOptions"
|
|
45
|
+
}
|
|
46
|
+
],
|
|
47
|
+
"returns": "Promise<BuyAppleInAppPurchaseResult>",
|
|
48
|
+
"tags": [],
|
|
49
|
+
"docs": "Purchase an Apple In-App Purchase product",
|
|
50
|
+
"complexTypes": [
|
|
51
|
+
"BuyAppleInAppPurchaseResult",
|
|
52
|
+
"BuyAppleInAppPurchaseOptions"
|
|
53
|
+
],
|
|
54
|
+
"slug": "buyappleinapppurchase"
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"name": "restoreAppleInAppPurchase",
|
|
58
|
+
"signature": "() => Promise<RestoreAppleInAppPurchaseResult>",
|
|
59
|
+
"parameters": [],
|
|
60
|
+
"returns": "Promise<BuyAppleInAppPurchaseResult>",
|
|
61
|
+
"tags": [],
|
|
62
|
+
"docs": "Restore Apple In-App Purchase transactions",
|
|
63
|
+
"complexTypes": [
|
|
64
|
+
"BuyAppleInAppPurchaseResult",
|
|
65
|
+
"RestoreAppleInAppPurchaseResult"
|
|
66
|
+
],
|
|
67
|
+
"slug": "restoreappleinapppurchase"
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"name": "getAppleInAppPurchaseReceipt",
|
|
71
|
+
"signature": "() => Promise<GetAppleInAppPurchaseReceiptResult>",
|
|
72
|
+
"parameters": [],
|
|
73
|
+
"returns": "Promise<GetAppleInAppPurchaseReceiptResult>",
|
|
74
|
+
"tags": [],
|
|
75
|
+
"docs": "Get Apple In-App Purchase receipt data",
|
|
76
|
+
"complexTypes": [
|
|
77
|
+
"GetAppleInAppPurchaseReceiptResult"
|
|
78
|
+
],
|
|
79
|
+
"slug": "getappleinapppurchasereceipt"
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
"name": "isGooglePayAvailable",
|
|
83
|
+
"signature": "() => Promise<void>",
|
|
84
|
+
"parameters": [],
|
|
85
|
+
"returns": "Promise<void>",
|
|
86
|
+
"tags": [],
|
|
87
|
+
"docs": "Check if Google Pay is available on this device",
|
|
88
|
+
"complexTypes": [],
|
|
89
|
+
"slug": "isgooglepayavailable"
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
"name": "handleGooglePay",
|
|
93
|
+
"signature": "(opts: GooglePayOptions) => Promise<GooglePayResult>",
|
|
94
|
+
"parameters": [
|
|
95
|
+
{
|
|
96
|
+
"name": "opts",
|
|
97
|
+
"docs": "",
|
|
98
|
+
"type": "GooglePayOptions"
|
|
99
|
+
}
|
|
100
|
+
],
|
|
101
|
+
"returns": "Promise<GooglePayResult>",
|
|
102
|
+
"tags": [],
|
|
103
|
+
"docs": "Handle Google Pay payment flow",
|
|
104
|
+
"complexTypes": [
|
|
105
|
+
"GooglePayResult",
|
|
106
|
+
"GooglePayOptions"
|
|
107
|
+
],
|
|
108
|
+
"slug": "handlegooglepay"
|
|
109
|
+
}
|
|
110
|
+
],
|
|
111
|
+
"properties": []
|
|
112
|
+
},
|
|
113
|
+
"interfaces": [],
|
|
114
|
+
"enums": [
|
|
115
|
+
{
|
|
116
|
+
"name": "AppleSubscriptionPeriodUnit",
|
|
117
|
+
"slug": "applesubscriptionperiodunit",
|
|
118
|
+
"members": [
|
|
119
|
+
{
|
|
120
|
+
"name": "Day",
|
|
121
|
+
"value": "0",
|
|
122
|
+
"tags": [],
|
|
123
|
+
"docs": ""
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
"name": "Week",
|
|
127
|
+
"value": "1",
|
|
128
|
+
"tags": [],
|
|
129
|
+
"docs": ""
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
"name": "Month",
|
|
133
|
+
"value": "2",
|
|
134
|
+
"tags": [],
|
|
135
|
+
"docs": ""
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
"name": "Year",
|
|
139
|
+
"value": "3",
|
|
140
|
+
"tags": [],
|
|
141
|
+
"docs": ""
|
|
142
|
+
}
|
|
143
|
+
]
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
"name": "AppleInAppPurchaseStatus",
|
|
147
|
+
"slug": "appleinapppurchasestatus",
|
|
148
|
+
"members": [
|
|
149
|
+
{
|
|
150
|
+
"name": "Completed",
|
|
151
|
+
"value": "'completed'",
|
|
152
|
+
"tags": [],
|
|
153
|
+
"docs": ""
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
"name": "Restored",
|
|
157
|
+
"value": "'restored'",
|
|
158
|
+
"tags": [],
|
|
159
|
+
"docs": ""
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
"name": "Cancelled",
|
|
163
|
+
"value": "'cancelled'",
|
|
164
|
+
"tags": [],
|
|
165
|
+
"docs": ""
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
"name": "Failed",
|
|
169
|
+
"value": "'failed'",
|
|
170
|
+
"tags": [],
|
|
171
|
+
"docs": ""
|
|
172
|
+
}
|
|
173
|
+
]
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
"name": "GooglePayResults",
|
|
177
|
+
"slug": "googlepayresults",
|
|
178
|
+
"members": [
|
|
179
|
+
{
|
|
180
|
+
"name": "Completed",
|
|
181
|
+
"value": "'completed'",
|
|
182
|
+
"tags": [],
|
|
183
|
+
"docs": ""
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
"name": "Failed",
|
|
187
|
+
"value": "'failed'",
|
|
188
|
+
"tags": [],
|
|
189
|
+
"docs": ""
|
|
190
|
+
}
|
|
191
|
+
]
|
|
192
|
+
}
|
|
193
|
+
],
|
|
194
|
+
"typeAliases": [
|
|
195
|
+
{
|
|
196
|
+
"name": "GetAppleInAppPurchaseProductsResult",
|
|
197
|
+
"slug": "getappleinapppurchaseproductsresult",
|
|
198
|
+
"docs": "",
|
|
199
|
+
"types": [
|
|
200
|
+
{
|
|
201
|
+
"text": "{\n products: AppleInAppPurchaseProduct[];\n}",
|
|
202
|
+
"complexTypes": [
|
|
203
|
+
"AppleInAppPurchaseProduct"
|
|
204
|
+
]
|
|
205
|
+
}
|
|
206
|
+
]
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
"name": "AppleInAppPurchaseProduct",
|
|
210
|
+
"slug": "appleinapppurchaseproduct",
|
|
211
|
+
"docs": "",
|
|
212
|
+
"types": [
|
|
213
|
+
{
|
|
214
|
+
"text": "{\n id: string;\n title: string;\n description: string;\n price: number;\n localizedPrice: string;\n subscriptionPeriod?: {\n value: number;\n unit: AppleSubscriptionPeriodUnit;\n };\n}",
|
|
215
|
+
"complexTypes": [
|
|
216
|
+
"AppleSubscriptionPeriodUnit"
|
|
217
|
+
]
|
|
218
|
+
}
|
|
219
|
+
]
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
"name": "GetAppleInAppPurchaseProductsOptions",
|
|
223
|
+
"slug": "getappleinapppurchaseproductsoptions",
|
|
224
|
+
"docs": "",
|
|
225
|
+
"types": [
|
|
226
|
+
{
|
|
227
|
+
"text": "{\n id: string[];\n}",
|
|
228
|
+
"complexTypes": []
|
|
229
|
+
}
|
|
230
|
+
]
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
"name": "BuyAppleInAppPurchaseResult",
|
|
234
|
+
"slug": "buyappleinapppurchaseresult",
|
|
235
|
+
"docs": "",
|
|
236
|
+
"types": [
|
|
237
|
+
{
|
|
238
|
+
"text": "CompletedAppleInAppPurchaseResult",
|
|
239
|
+
"complexTypes": [
|
|
240
|
+
"CompletedAppleInAppPurchaseResult"
|
|
241
|
+
]
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
"text": "RestoredAppleInAppPurchaseResult",
|
|
245
|
+
"complexTypes": [
|
|
246
|
+
"RestoredAppleInAppPurchaseResult"
|
|
247
|
+
]
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
"text": "FailedAppleInAppPurchaseResult",
|
|
251
|
+
"complexTypes": [
|
|
252
|
+
"FailedAppleInAppPurchaseResult"
|
|
253
|
+
]
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
"text": "CancelledAppleInAppPurchaseResult",
|
|
257
|
+
"complexTypes": [
|
|
258
|
+
"CancelledAppleInAppPurchaseResult"
|
|
259
|
+
]
|
|
260
|
+
}
|
|
261
|
+
]
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
"name": "CompletedAppleInAppPurchaseResult",
|
|
265
|
+
"slug": "completedappleinapppurchaseresult",
|
|
266
|
+
"docs": "",
|
|
267
|
+
"types": [
|
|
268
|
+
{
|
|
269
|
+
"text": "{\n status: AppleInAppPurchaseStatus.Completed;\n productIdentifier: string;\n transactionIdentifier: string;\n}",
|
|
270
|
+
"complexTypes": [
|
|
271
|
+
"AppleInAppPurchaseStatus"
|
|
272
|
+
]
|
|
273
|
+
}
|
|
274
|
+
]
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
"name": "RestoredAppleInAppPurchaseResult",
|
|
278
|
+
"slug": "restoredappleinapppurchaseresult",
|
|
279
|
+
"docs": "",
|
|
280
|
+
"types": [
|
|
281
|
+
{
|
|
282
|
+
"text": "{\n status: AppleInAppPurchaseStatus.Restored;\n} & Omit<CompletedAppleInAppPurchaseResult, 'status'>",
|
|
283
|
+
"complexTypes": [
|
|
284
|
+
"AppleInAppPurchaseStatus",
|
|
285
|
+
"Omit",
|
|
286
|
+
"CompletedAppleInAppPurchaseResult"
|
|
287
|
+
]
|
|
288
|
+
}
|
|
289
|
+
]
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
"name": "Omit",
|
|
293
|
+
"slug": "omit",
|
|
294
|
+
"docs": "Construct a type with the properties of T except for those in type K.",
|
|
295
|
+
"types": [
|
|
296
|
+
{
|
|
297
|
+
"text": "Pick<T, Exclude<keyof T, K>>",
|
|
298
|
+
"complexTypes": [
|
|
299
|
+
"Pick",
|
|
300
|
+
"T",
|
|
301
|
+
"Exclude",
|
|
302
|
+
"K"
|
|
303
|
+
]
|
|
304
|
+
}
|
|
305
|
+
]
|
|
306
|
+
},
|
|
307
|
+
{
|
|
308
|
+
"name": "Pick",
|
|
309
|
+
"slug": "pick",
|
|
310
|
+
"docs": "From T, pick a set of properties whose keys are in the union K",
|
|
311
|
+
"types": [
|
|
312
|
+
{
|
|
313
|
+
"text": "{\r\n [P in K]: T[P];\r\n}",
|
|
314
|
+
"complexTypes": [
|
|
315
|
+
"K",
|
|
316
|
+
"T",
|
|
317
|
+
"P"
|
|
318
|
+
]
|
|
319
|
+
}
|
|
320
|
+
]
|
|
321
|
+
},
|
|
322
|
+
{
|
|
323
|
+
"name": "Exclude",
|
|
324
|
+
"slug": "exclude",
|
|
325
|
+
"docs": "Exclude from T those types that are assignable to U",
|
|
326
|
+
"types": [
|
|
327
|
+
{
|
|
328
|
+
"text": "T extends U ? never : T",
|
|
329
|
+
"complexTypes": [
|
|
330
|
+
"T",
|
|
331
|
+
"U"
|
|
332
|
+
]
|
|
333
|
+
}
|
|
334
|
+
]
|
|
335
|
+
},
|
|
336
|
+
{
|
|
337
|
+
"name": "FailedAppleInAppPurchaseResult",
|
|
338
|
+
"slug": "failedappleinapppurchaseresult",
|
|
339
|
+
"docs": "",
|
|
340
|
+
"types": [
|
|
341
|
+
{
|
|
342
|
+
"text": "{\n status: AppleInAppPurchaseStatus.Failed;\n productIdentifier?: string;\n transactionIdentifier?: string;\n}",
|
|
343
|
+
"complexTypes": [
|
|
344
|
+
"AppleInAppPurchaseStatus"
|
|
345
|
+
]
|
|
346
|
+
}
|
|
347
|
+
]
|
|
348
|
+
},
|
|
349
|
+
{
|
|
350
|
+
"name": "CancelledAppleInAppPurchaseResult",
|
|
351
|
+
"slug": "cancelledappleinapppurchaseresult",
|
|
352
|
+
"docs": "",
|
|
353
|
+
"types": [
|
|
354
|
+
{
|
|
355
|
+
"text": "{\n status: AppleInAppPurchaseStatus.Cancelled;\n} & Omit<FailedAppleInAppPurchaseResult, 'status'>",
|
|
356
|
+
"complexTypes": [
|
|
357
|
+
"AppleInAppPurchaseStatus",
|
|
358
|
+
"Omit",
|
|
359
|
+
"FailedAppleInAppPurchaseResult"
|
|
360
|
+
]
|
|
361
|
+
}
|
|
362
|
+
]
|
|
363
|
+
},
|
|
364
|
+
{
|
|
365
|
+
"name": "BuyAppleInAppPurchaseOptions",
|
|
366
|
+
"slug": "buyappleinapppurchaseoptions",
|
|
367
|
+
"docs": "",
|
|
368
|
+
"types": [
|
|
369
|
+
{
|
|
370
|
+
"text": "{\n id: string;\n}",
|
|
371
|
+
"complexTypes": []
|
|
372
|
+
}
|
|
373
|
+
]
|
|
374
|
+
},
|
|
375
|
+
{
|
|
376
|
+
"name": "RestoreAppleInAppPurchaseResult",
|
|
377
|
+
"slug": "restoreappleinapppurchaseresult",
|
|
378
|
+
"docs": "",
|
|
379
|
+
"types": [
|
|
380
|
+
{
|
|
381
|
+
"text": "BuyAppleInAppPurchaseResult",
|
|
382
|
+
"complexTypes": [
|
|
383
|
+
"BuyAppleInAppPurchaseResult"
|
|
384
|
+
]
|
|
385
|
+
}
|
|
386
|
+
]
|
|
387
|
+
},
|
|
388
|
+
{
|
|
389
|
+
"name": "GetAppleInAppPurchaseReceiptResult",
|
|
390
|
+
"slug": "getappleinapppurchasereceiptresult",
|
|
391
|
+
"docs": "",
|
|
392
|
+
"types": [
|
|
393
|
+
{
|
|
394
|
+
"text": "{\n receiptData: string;\n}",
|
|
395
|
+
"complexTypes": []
|
|
396
|
+
}
|
|
397
|
+
]
|
|
398
|
+
},
|
|
399
|
+
{
|
|
400
|
+
"name": "GooglePayResult",
|
|
401
|
+
"slug": "googlepayresult",
|
|
402
|
+
"docs": "",
|
|
403
|
+
"types": [
|
|
404
|
+
{
|
|
405
|
+
"text": "{\n result: GooglePayResults;\n}",
|
|
406
|
+
"complexTypes": [
|
|
407
|
+
"GooglePayResults"
|
|
408
|
+
]
|
|
409
|
+
}
|
|
410
|
+
]
|
|
411
|
+
},
|
|
412
|
+
{
|
|
413
|
+
"name": "GooglePayOptions",
|
|
414
|
+
"slug": "googlepayoptions",
|
|
415
|
+
"docs": "",
|
|
416
|
+
"types": [
|
|
417
|
+
{
|
|
418
|
+
"text": "{\n clientSecret: string;\n}",
|
|
419
|
+
"complexTypes": []
|
|
420
|
+
}
|
|
421
|
+
]
|
|
422
|
+
}
|
|
423
|
+
],
|
|
424
|
+
"pluginConfigs": []
|
|
425
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
export interface PaymentPlugin {
|
|
2
|
+
/**
|
|
3
|
+
* Check if Apple In-App Purchases are available on this device
|
|
4
|
+
*/
|
|
5
|
+
isAppleInAppPurchaseAvailable(): Promise<void>;
|
|
6
|
+
/**
|
|
7
|
+
* Get Apple In-App Purchase products by their identifiers
|
|
8
|
+
*/
|
|
9
|
+
getAppleInAppPurchaseProducts(opts: GetAppleInAppPurchaseProductsOptions): Promise<GetAppleInAppPurchaseProductsResult>;
|
|
10
|
+
/**
|
|
11
|
+
* Purchase an Apple In-App Purchase product
|
|
12
|
+
*/
|
|
13
|
+
buyAppleInAppPurchase(opts: BuyAppleInAppPurchaseOptions): Promise<BuyAppleInAppPurchaseResult>;
|
|
14
|
+
/**
|
|
15
|
+
* Restore Apple In-App Purchase transactions
|
|
16
|
+
*/
|
|
17
|
+
restoreAppleInAppPurchase(): Promise<RestoreAppleInAppPurchaseResult>;
|
|
18
|
+
/**
|
|
19
|
+
* Get Apple In-App Purchase receipt data
|
|
20
|
+
*/
|
|
21
|
+
getAppleInAppPurchaseReceipt(): Promise<GetAppleInAppPurchaseReceiptResult>;
|
|
22
|
+
/**
|
|
23
|
+
* Check if Google Pay is available on this device
|
|
24
|
+
*/
|
|
25
|
+
isGooglePayAvailable(): Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* Handle Google Pay payment flow
|
|
28
|
+
*/
|
|
29
|
+
handleGooglePay(opts: GooglePayOptions): Promise<GooglePayResult>;
|
|
30
|
+
}
|
|
31
|
+
export declare enum AppleInAppPurchaseStatus {
|
|
32
|
+
Completed = "completed",
|
|
33
|
+
Restored = "restored",
|
|
34
|
+
Cancelled = "cancelled",
|
|
35
|
+
Failed = "failed"
|
|
36
|
+
}
|
|
37
|
+
export declare enum AppleSubscriptionPeriodUnit {
|
|
38
|
+
Day = 0,
|
|
39
|
+
Week = 1,
|
|
40
|
+
Month = 2,
|
|
41
|
+
Year = 3
|
|
42
|
+
}
|
|
43
|
+
export declare type GetAppleInAppPurchaseProductsOptions = {
|
|
44
|
+
id: string[];
|
|
45
|
+
};
|
|
46
|
+
export declare type AppleInAppPurchaseProduct = {
|
|
47
|
+
id: string;
|
|
48
|
+
title: string;
|
|
49
|
+
description: string;
|
|
50
|
+
price: number;
|
|
51
|
+
localizedPrice: string;
|
|
52
|
+
subscriptionPeriod?: {
|
|
53
|
+
value: number;
|
|
54
|
+
unit: AppleSubscriptionPeriodUnit;
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
export declare type GetAppleInAppPurchaseProductsResult = {
|
|
58
|
+
products: AppleInAppPurchaseProduct[];
|
|
59
|
+
};
|
|
60
|
+
export declare type BuyAppleInAppPurchaseOptions = {
|
|
61
|
+
id: string;
|
|
62
|
+
};
|
|
63
|
+
export declare type BuyAppleInAppPurchaseResult = CompletedAppleInAppPurchaseResult | RestoredAppleInAppPurchaseResult | FailedAppleInAppPurchaseResult | CancelledAppleInAppPurchaseResult;
|
|
64
|
+
export declare type CompletedAppleInAppPurchaseResult = {
|
|
65
|
+
status: AppleInAppPurchaseStatus.Completed;
|
|
66
|
+
productIdentifier: string;
|
|
67
|
+
transactionIdentifier: string;
|
|
68
|
+
};
|
|
69
|
+
export declare type RestoredAppleInAppPurchaseResult = {
|
|
70
|
+
status: AppleInAppPurchaseStatus.Restored;
|
|
71
|
+
} & Omit<CompletedAppleInAppPurchaseResult, 'status'>;
|
|
72
|
+
export declare type FailedAppleInAppPurchaseResult = {
|
|
73
|
+
status: AppleInAppPurchaseStatus.Failed;
|
|
74
|
+
productIdentifier?: string;
|
|
75
|
+
transactionIdentifier?: string;
|
|
76
|
+
};
|
|
77
|
+
export declare type CancelledAppleInAppPurchaseResult = {
|
|
78
|
+
status: AppleInAppPurchaseStatus.Cancelled;
|
|
79
|
+
} & Omit<FailedAppleInAppPurchaseResult, 'status'>;
|
|
80
|
+
export declare type RestoreAppleInAppPurchaseResult = BuyAppleInAppPurchaseResult;
|
|
81
|
+
export declare type GetAppleInAppPurchaseReceiptResult = {
|
|
82
|
+
receiptData: string;
|
|
83
|
+
};
|
|
84
|
+
export declare enum GooglePayResults {
|
|
85
|
+
Completed = "completed",
|
|
86
|
+
Failed = "failed"
|
|
87
|
+
}
|
|
88
|
+
export declare type GooglePayOptions = {
|
|
89
|
+
clientSecret: string;
|
|
90
|
+
};
|
|
91
|
+
export declare type GooglePayResult = {
|
|
92
|
+
result: GooglePayResults;
|
|
93
|
+
};
|
|
94
|
+
export declare type PaymentPluginContext = {
|
|
95
|
+
plugin: PaymentPlugin;
|
|
96
|
+
isAppleInAppPurchaseAvailable: boolean;
|
|
97
|
+
isGooglePayAvailable: boolean;
|
|
98
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export interface PaymentPlugin {\n /**\n * Check if Apple In-App Purchases are available on this device\n */\n isAppleInAppPurchaseAvailable(): Promise<void>;\n \n /**\n * Get Apple In-App Purchase products by their identifiers\n */\n getAppleInAppPurchaseProducts(opts: GetAppleInAppPurchaseProductsOptions): Promise<GetAppleInAppPurchaseProductsResult>;\n \n /**\n * Purchase an Apple In-App Purchase product\n */\n buyAppleInAppPurchase(opts: BuyAppleInAppPurchaseOptions): Promise<BuyAppleInAppPurchaseResult>;\n \n /**\n * Restore Apple In-App Purchase transactions\n */\n restoreAppleInAppPurchase(): Promise<RestoreAppleInAppPurchaseResult>;\n \n /**\n * Get Apple In-App Purchase receipt data\n */\n getAppleInAppPurchaseReceipt(): Promise<GetAppleInAppPurchaseReceiptResult>;\n \n /**\n * Check if Google Pay is available on this device\n */\n isGooglePayAvailable(): Promise<void>;\n \n /**\n * Handle Google Pay payment flow\n */\n handleGooglePay(opts: GooglePayOptions): Promise<GooglePayResult>;\n}\nexport declare enum AppleInAppPurchaseStatus {\n Completed = 'completed',\n Restored = 'restored',\n Cancelled = 'cancelled',\n Failed = 'failed',\n}\nexport declare enum AppleSubscriptionPeriodUnit {\n Day = 0,\n Week = 1,\n Month = 2,\n Year = 3,\n}\n\nexport declare type GetAppleInAppPurchaseProductsOptions = {\n id: string[];\n};\n\nexport declare type AppleInAppPurchaseProduct = {\n id: string;\n title: string;\n description: string;\n price: number;\n localizedPrice: string;\n subscriptionPeriod?: {\n value: number;\n unit: AppleSubscriptionPeriodUnit;\n };\n};\n\nexport declare type GetAppleInAppPurchaseProductsResult = {\n products: AppleInAppPurchaseProduct[];\n};\n\nexport declare type BuyAppleInAppPurchaseOptions = {\n id: string;\n};\n\nexport declare type BuyAppleInAppPurchaseResult =\n | CompletedAppleInAppPurchaseResult\n | RestoredAppleInAppPurchaseResult\n | FailedAppleInAppPurchaseResult\n | CancelledAppleInAppPurchaseResult;\n\nexport declare type CompletedAppleInAppPurchaseResult = {\n status: AppleInAppPurchaseStatus.Completed;\n productIdentifier: string;\n transactionIdentifier: string;\n};\n\nexport declare type RestoredAppleInAppPurchaseResult = {\n status: AppleInAppPurchaseStatus.Restored;\n} & Omit<CompletedAppleInAppPurchaseResult, 'status'>;\n\nexport declare type FailedAppleInAppPurchaseResult = {\n status: AppleInAppPurchaseStatus.Failed;\n productIdentifier?: string;\n transactionIdentifier?: string;\n};\n\nexport declare type CancelledAppleInAppPurchaseResult = {\n status: AppleInAppPurchaseStatus.Cancelled;\n} & Omit<FailedAppleInAppPurchaseResult, 'status'>;\n\nexport declare type RestoreAppleInAppPurchaseResult = BuyAppleInAppPurchaseResult;\n\nexport declare type GetAppleInAppPurchaseReceiptResult = {\n receiptData: string;\n};\nexport declare enum GooglePayResults {\n Completed = 'completed',\n Failed = 'failed',\n}\nexport declare type GooglePayOptions = {\n clientSecret: string;\n};\nexport declare type GooglePayResult = {\n result: GooglePayResults;\n};\nexport declare type PaymentPluginContext = {\n plugin: PaymentPlugin;\n isAppleInAppPurchaseAvailable: boolean;\n isGooglePayAvailable: boolean;\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,OAAO,GAAG,cAAc,CAAgB,SAAS,EAAE;IACrD,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,CAAC;CAC7D,CAAC,CAAC;AAEH,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,OAAO,EAAE,CAAC","sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nimport type { PaymentPlugin } from './definitions';\n\nconst Payment = registerPlugin<PaymentPlugin>('Payment', {\n web: () => import('./web').then((m) => new m.PaymentWeb()),\n});\n\nexport * from './definitions';\nexport { Payment };\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { FC, PropsWithChildren, ReactNode } from 'react';
|
|
2
|
+
import type { PaymentPluginContext as PaymentPluginContextType } from '../../definitions';
|
|
3
|
+
export declare const usePaymentPlugin: () => PaymentPluginContextType;
|
|
4
|
+
export type PaymentPluginProviderType = PropsWithChildren<{
|
|
5
|
+
fallback?: ReactNode;
|
|
6
|
+
}>;
|
|
7
|
+
export declare const PaymentPluginProvider: FC<PaymentPluginProviderType>;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import React, { createContext, useContext, useEffect, useState } from 'react';
|
|
2
|
+
import { Payment } from '../../index';
|
|
3
|
+
const PaymentPluginContext = createContext({
|
|
4
|
+
plugin: undefined,
|
|
5
|
+
isAppleInAppPurchaseAvailable: false,
|
|
6
|
+
isGooglePayAvailable: false,
|
|
7
|
+
});
|
|
8
|
+
export const usePaymentPlugin = () => {
|
|
9
|
+
return useContext(PaymentPluginContext);
|
|
10
|
+
};
|
|
11
|
+
export const PaymentPluginProvider = ({ fallback, children }) => {
|
|
12
|
+
const [isAppleInAppPurchaseAvailable, setAppleInAppPurchaseAvailable] = useState(false);
|
|
13
|
+
const [isGooglePayAvailable, setGooglePayAvailableStatus] = useState(false);
|
|
14
|
+
const [plugin, setPlugin] = useState();
|
|
15
|
+
const [initialized, setInitialized] = useState(false);
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
async function initialize() {
|
|
18
|
+
let appleInAppPurchasesAvailable;
|
|
19
|
+
let googlePayAvailable;
|
|
20
|
+
try {
|
|
21
|
+
await Payment.isAppleInAppPurchaseAvailable();
|
|
22
|
+
appleInAppPurchasesAvailable = true;
|
|
23
|
+
}
|
|
24
|
+
catch (e) {
|
|
25
|
+
appleInAppPurchasesAvailable = false;
|
|
26
|
+
}
|
|
27
|
+
try {
|
|
28
|
+
await Payment.isGooglePayAvailable();
|
|
29
|
+
googlePayAvailable = true;
|
|
30
|
+
}
|
|
31
|
+
catch (e) {
|
|
32
|
+
googlePayAvailable = false;
|
|
33
|
+
}
|
|
34
|
+
setAppleInAppPurchaseAvailable(appleInAppPurchasesAvailable);
|
|
35
|
+
setGooglePayAvailableStatus(googlePayAvailable);
|
|
36
|
+
setPlugin(Payment);
|
|
37
|
+
}
|
|
38
|
+
if (!initialized) {
|
|
39
|
+
setInitialized(true);
|
|
40
|
+
initialize();
|
|
41
|
+
}
|
|
42
|
+
}, [initialized]);
|
|
43
|
+
if (!plugin) {
|
|
44
|
+
return React.createElement(React.Fragment, null, fallback);
|
|
45
|
+
}
|
|
46
|
+
return (React.createElement(PaymentPluginContext.Provider, { value: {
|
|
47
|
+
plugin,
|
|
48
|
+
isGooglePayAvailable,
|
|
49
|
+
isAppleInAppPurchaseAvailable,
|
|
50
|
+
} }, children));
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=PaymentPluginProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PaymentPluginProvider.js","sourceRoot":"","sources":["../../../../src/provider/react/PaymentPluginProvider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,aAAa,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAG9E,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,MAAM,oBAAoB,GAAG,aAAa,CAA2B;IACjE,MAAM,EAAE,SAAgB;IACxB,6BAA6B,EAAE,KAAK;IACpC,oBAAoB,EAAE,KAAK;CAC9B,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAA6B,EAAE;IAC3D,OAAO,UAAU,CAAC,oBAAoB,CAAC,CAAC;AAC5C,CAAC,CAAC;AAMF,MAAM,CAAC,MAAM,qBAAqB,GAAkC,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,EAAE;IAC3F,MAAM,CAAC,6BAA6B,EAAE,8BAA8B,CAAC,GAAG,QAAQ,CAAU,KAAK,CAAC,CAAC;IACjG,MAAM,CAAC,oBAAoB,EAAE,2BAA2B,CAAC,GAAG,QAAQ,CAAU,KAAK,CAAC,CAAC;IACrF,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,EAAiB,CAAC;IACtD,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAU,KAAK,CAAC,CAAC;IAE/D,SAAS,CAAC,GAAG,EAAE;QACX,KAAK,UAAU,UAAU;YACrB,IAAI,4BAA4B,CAAC;YACjC,IAAI,kBAAkB,CAAC;YACvB,IAAI,CAAC;gBACD,MAAM,OAAO,CAAC,6BAA6B,EAAE,CAAC;gBAC9C,4BAA4B,GAAG,IAAI,CAAC;YACxC,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACT,4BAA4B,GAAG,KAAK,CAAC;YACzC,CAAC;YACD,IAAI,CAAC;gBACD,MAAM,OAAO,CAAC,oBAAoB,EAAE,CAAC;gBACrC,kBAAkB,GAAG,IAAI,CAAC;YAC9B,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACT,kBAAkB,GAAG,KAAK,CAAC;YAC/B,CAAC;YACD,8BAA8B,CAAC,4BAA4B,CAAC,CAAC;YAC7D,2BAA2B,CAAC,kBAAkB,CAAC,CAAC;YAChD,SAAS,CAAC,OAAO,CAAC,CAAC;QACvB,CAAC;QACD,IAAI,CAAC,WAAW,EAAE,CAAC;YACf,cAAc,CAAC,IAAI,CAAC,CAAC;YACrB,UAAU,EAAE,CAAC;QACjB,CAAC;IACL,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC;IAElB,IAAI,CAAC,MAAM,EAAE,CAAC;QACV,OAAO,0CAAG,QAAQ,CAAI,CAAC;IAC3B,CAAC;IACD,OAAO,CACH,oBAAC,oBAAoB,CAAC,QAAQ,IAC1B,KAAK,EAAE;YACH,MAAM;YACN,oBAAoB;YACpB,6BAA6B;SAChC,IAEA,QAAQ,CACmB,CACnC,CAAC;AACN,CAAC,CAAC","sourcesContent":["import type { FC, PropsWithChildren, ReactNode } from 'react';\nimport React, { createContext, useContext, useEffect, useState } from 'react';\n\nimport type { PaymentPlugin, PaymentPluginContext as PaymentPluginContextType } from '../../definitions';\nimport { Payment } from '../../index';\n\nconst PaymentPluginContext = createContext<PaymentPluginContextType>({\n plugin: undefined as any,\n isAppleInAppPurchaseAvailable: false,\n isGooglePayAvailable: false,\n});\n\nexport const usePaymentPlugin = (): PaymentPluginContextType => {\n return useContext(PaymentPluginContext);\n};\n\nexport type PaymentPluginProviderType = PropsWithChildren<{\n fallback?: ReactNode;\n}>;\n\nexport const PaymentPluginProvider: FC<PaymentPluginProviderType> = ({ fallback, children }) => {\n const [isAppleInAppPurchaseAvailable, setAppleInAppPurchaseAvailable] = useState<boolean>(false);\n const [isGooglePayAvailable, setGooglePayAvailableStatus] = useState<boolean>(false);\n const [plugin, setPlugin] = useState<PaymentPlugin>();\n const [initialized, setInitialized] = useState<boolean>(false);\n\n useEffect(() => {\n async function initialize() {\n let appleInAppPurchasesAvailable;\n let googlePayAvailable;\n try {\n await Payment.isAppleInAppPurchaseAvailable();\n appleInAppPurchasesAvailable = true;\n } catch (e) {\n appleInAppPurchasesAvailable = false;\n }\n try {\n await Payment.isGooglePayAvailable();\n googlePayAvailable = true;\n } catch (e) {\n googlePayAvailable = false;\n }\n setAppleInAppPurchaseAvailable(appleInAppPurchasesAvailable);\n setGooglePayAvailableStatus(googlePayAvailable);\n setPlugin(Payment);\n }\n if (!initialized) {\n setInitialized(true);\n initialize();\n }\n }, [initialized]);\n\n if (!plugin) {\n return <>{fallback}</>;\n }\n return (\n <PaymentPluginContext.Provider\n value={{\n plugin,\n isGooglePayAvailable,\n isAppleInAppPurchaseAvailable,\n }}\n >\n {children}\n </PaymentPluginContext.Provider>\n );\n};\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { WebPlugin } from '@capacitor/core';
|
|
2
|
+
import { BuyAppleInAppPurchaseOptions, BuyAppleInAppPurchaseResult, GetAppleInAppPurchaseProductsOptions, GetAppleInAppPurchaseProductsResult, GetAppleInAppPurchaseReceiptResult, GooglePayOptions, GooglePayResult, PaymentPlugin, RestoreAppleInAppPurchaseResult } from './definitions';
|
|
3
|
+
export declare class PaymentWeb extends WebPlugin implements PaymentPlugin {
|
|
4
|
+
/**
|
|
5
|
+
* Apple
|
|
6
|
+
*/
|
|
7
|
+
isAppleInAppPurchaseAvailable(): Promise<void>;
|
|
8
|
+
getAppleInAppPurchaseProducts(_opts: GetAppleInAppPurchaseProductsOptions): Promise<GetAppleInAppPurchaseProductsResult>;
|
|
9
|
+
buyAppleInAppPurchase(_opts: BuyAppleInAppPurchaseOptions): Promise<BuyAppleInAppPurchaseResult>;
|
|
10
|
+
restoreAppleInAppPurchase(): Promise<RestoreAppleInAppPurchaseResult>;
|
|
11
|
+
getAppleInAppPurchaseReceipt(): Promise<GetAppleInAppPurchaseReceiptResult>;
|
|
12
|
+
/**
|
|
13
|
+
* Google
|
|
14
|
+
*/
|
|
15
|
+
isGooglePayAvailable(): Promise<void>;
|
|
16
|
+
handleGooglePay(_opts: GooglePayOptions): Promise<GooglePayResult>;
|
|
17
|
+
}
|
package/dist/esm/web.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { WebPlugin } from '@capacitor/core';
|
|
2
|
+
export class PaymentWeb extends WebPlugin {
|
|
3
|
+
/**
|
|
4
|
+
* Apple
|
|
5
|
+
*/
|
|
6
|
+
isAppleInAppPurchaseAvailable() {
|
|
7
|
+
return Promise.reject('Not supported');
|
|
8
|
+
}
|
|
9
|
+
getAppleInAppPurchaseProducts(_opts) {
|
|
10
|
+
return Promise.reject('Not supported');
|
|
11
|
+
}
|
|
12
|
+
buyAppleInAppPurchase(_opts) {
|
|
13
|
+
return Promise.reject('Not supported');
|
|
14
|
+
}
|
|
15
|
+
restoreAppleInAppPurchase() {
|
|
16
|
+
return Promise.reject('Not supported');
|
|
17
|
+
}
|
|
18
|
+
getAppleInAppPurchaseReceipt() {
|
|
19
|
+
return Promise.reject('Not supported');
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Google
|
|
23
|
+
*/
|
|
24
|
+
isGooglePayAvailable() {
|
|
25
|
+
return Promise.reject('Not supported');
|
|
26
|
+
}
|
|
27
|
+
handleGooglePay(_opts) {
|
|
28
|
+
return Promise.reject('Not supported');
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=web.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAc5C,MAAM,OAAO,UAAW,SAAQ,SAAS;IACrC;;OAEG;IACH,6BAA6B;QACzB,OAAO,OAAO,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;IAC3C,CAAC;IACD,6BAA6B,CAAC,KAA2C;QACrE,OAAO,OAAO,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;IAC3C,CAAC;IACD,qBAAqB,CAAC,KAAmC;QACrD,OAAO,OAAO,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;IAC3C,CAAC;IACD,yBAAyB;QACrB,OAAO,OAAO,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;IAC3C,CAAC;IACD,4BAA4B;QACxB,OAAO,OAAO,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;IAC3C,CAAC;IACD;;OAEG;IACH,oBAAoB;QAChB,OAAO,OAAO,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;IAC3C,CAAC;IACD,eAAe,CAAC,KAAuB;QACnC,OAAO,OAAO,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;IAC3C,CAAC;CACJ","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport {\n BuyAppleInAppPurchaseOptions,\n BuyAppleInAppPurchaseResult,\n GetAppleInAppPurchaseProductsOptions,\n GetAppleInAppPurchaseProductsResult,\n GetAppleInAppPurchaseReceiptResult,\n GooglePayOptions,\n GooglePayResult,\n PaymentPlugin,\n RestoreAppleInAppPurchaseResult,\n} from './definitions';\n\nexport class PaymentWeb extends WebPlugin implements PaymentPlugin {\n /**\n * Apple\n */\n isAppleInAppPurchaseAvailable(): Promise<void> {\n return Promise.reject('Not supported');\n }\n getAppleInAppPurchaseProducts(_opts: GetAppleInAppPurchaseProductsOptions): Promise<GetAppleInAppPurchaseProductsResult> {\n return Promise.reject('Not supported');\n }\n buyAppleInAppPurchase(_opts: BuyAppleInAppPurchaseOptions): Promise<BuyAppleInAppPurchaseResult> {\n return Promise.reject('Not supported');\n }\n restoreAppleInAppPurchase(): Promise<RestoreAppleInAppPurchaseResult> {\n return Promise.reject('Not supported');\n }\n getAppleInAppPurchaseReceipt(): Promise<GetAppleInAppPurchaseReceiptResult> {\n return Promise.reject('Not supported');\n }\n /**\n * Google\n */\n isGooglePayAvailable(): Promise<void> {\n return Promise.reject('Not supported');\n }\n handleGooglePay(_opts: GooglePayOptions): Promise<GooglePayResult> {\n return Promise.reject('Not supported');\n }\n}\n"]}
|