@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
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
require 'json'
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
|
|
4
|
+
|
|
5
|
+
Pod::Spec.new do |s|
|
|
6
|
+
s.name = 'DictyPayment'
|
|
7
|
+
s.version = package['version']
|
|
8
|
+
s.summary = package['description']
|
|
9
|
+
s.license = package['license']
|
|
10
|
+
s.homepage = package['repository']['url']
|
|
11
|
+
s.author = package['author']
|
|
12
|
+
s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
|
|
13
|
+
s.source_files = 'ios/Sources/**/*.{swift,h,m,c,cc,mm,cpp}'
|
|
14
|
+
s.ios.deployment_target = '14.0'
|
|
15
|
+
s.dependency 'Capacitor'
|
|
16
|
+
s.swift_version = '5.1'
|
|
17
|
+
end
|
package/README.md
ADDED
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
# @dicty/stripe
|
|
2
|
+
|
|
3
|
+
Dicty Stripe plugin
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @dicty/stripe
|
|
9
|
+
npx cap sync
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## API
|
|
13
|
+
|
|
14
|
+
<docgen-index>
|
|
15
|
+
|
|
16
|
+
* [`isAppleInAppPurchaseAvailable()`](#isappleinapppurchaseavailable)
|
|
17
|
+
* [`getAppleInAppPurchaseProducts(...)`](#getappleinapppurchaseproducts)
|
|
18
|
+
* [`buyAppleInAppPurchase(...)`](#buyappleinapppurchase)
|
|
19
|
+
* [`restoreAppleInAppPurchase()`](#restoreappleinapppurchase)
|
|
20
|
+
* [`getAppleInAppPurchaseReceipt()`](#getappleinapppurchasereceipt)
|
|
21
|
+
* [`isGooglePayAvailable()`](#isgooglepayavailable)
|
|
22
|
+
* [`handleGooglePay(...)`](#handlegooglepay)
|
|
23
|
+
* [Type Aliases](#type-aliases)
|
|
24
|
+
* [Enums](#enums)
|
|
25
|
+
|
|
26
|
+
</docgen-index>
|
|
27
|
+
|
|
28
|
+
<docgen-api>
|
|
29
|
+
<!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
|
|
30
|
+
|
|
31
|
+
### isAppleInAppPurchaseAvailable()
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
isAppleInAppPurchaseAvailable() => Promise<void>
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Check if Apple In-App Purchases are available on this device
|
|
38
|
+
|
|
39
|
+
--------------------
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
### getAppleInAppPurchaseProducts(...)
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
getAppleInAppPurchaseProducts(opts: GetAppleInAppPurchaseProductsOptions) => Promise<GetAppleInAppPurchaseProductsResult>
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Get Apple In-App Purchase products by their identifiers
|
|
49
|
+
|
|
50
|
+
| Param | Type |
|
|
51
|
+
| ---------- | ----------------------------------------------------------------------------------------------------- |
|
|
52
|
+
| **`opts`** | <code><a href="#getappleinapppurchaseproductsoptions">GetAppleInAppPurchaseProductsOptions</a></code> |
|
|
53
|
+
|
|
54
|
+
**Returns:** <code>Promise<<a href="#getappleinapppurchaseproductsresult">GetAppleInAppPurchaseProductsResult</a>></code>
|
|
55
|
+
|
|
56
|
+
--------------------
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
### buyAppleInAppPurchase(...)
|
|
60
|
+
|
|
61
|
+
```typescript
|
|
62
|
+
buyAppleInAppPurchase(opts: BuyAppleInAppPurchaseOptions) => Promise<BuyAppleInAppPurchaseResult>
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Purchase an Apple In-App Purchase product
|
|
66
|
+
|
|
67
|
+
| Param | Type |
|
|
68
|
+
| ---------- | ------------------------------------------------------------------------------------- |
|
|
69
|
+
| **`opts`** | <code><a href="#buyappleinapppurchaseoptions">BuyAppleInAppPurchaseOptions</a></code> |
|
|
70
|
+
|
|
71
|
+
**Returns:** <code>Promise<<a href="#buyappleinapppurchaseresult">BuyAppleInAppPurchaseResult</a>></code>
|
|
72
|
+
|
|
73
|
+
--------------------
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
### restoreAppleInAppPurchase()
|
|
77
|
+
|
|
78
|
+
```typescript
|
|
79
|
+
restoreAppleInAppPurchase() => Promise<RestoreAppleInAppPurchaseResult>
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Restore Apple In-App Purchase transactions
|
|
83
|
+
|
|
84
|
+
**Returns:** <code>Promise<<a href="#buyappleinapppurchaseresult">BuyAppleInAppPurchaseResult</a>></code>
|
|
85
|
+
|
|
86
|
+
--------------------
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
### getAppleInAppPurchaseReceipt()
|
|
90
|
+
|
|
91
|
+
```typescript
|
|
92
|
+
getAppleInAppPurchaseReceipt() => Promise<GetAppleInAppPurchaseReceiptResult>
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Get Apple In-App Purchase receipt data
|
|
96
|
+
|
|
97
|
+
**Returns:** <code>Promise<<a href="#getappleinapppurchasereceiptresult">GetAppleInAppPurchaseReceiptResult</a>></code>
|
|
98
|
+
|
|
99
|
+
--------------------
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
### isGooglePayAvailable()
|
|
103
|
+
|
|
104
|
+
```typescript
|
|
105
|
+
isGooglePayAvailable() => Promise<void>
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Check if Google Pay is available on this device
|
|
109
|
+
|
|
110
|
+
--------------------
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
### handleGooglePay(...)
|
|
114
|
+
|
|
115
|
+
```typescript
|
|
116
|
+
handleGooglePay(opts: GooglePayOptions) => Promise<GooglePayResult>
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Handle Google Pay payment flow
|
|
120
|
+
|
|
121
|
+
| Param | Type |
|
|
122
|
+
| ---------- | ------------------------------------------------------------- |
|
|
123
|
+
| **`opts`** | <code><a href="#googlepayoptions">GooglePayOptions</a></code> |
|
|
124
|
+
|
|
125
|
+
**Returns:** <code>Promise<<a href="#googlepayresult">GooglePayResult</a>></code>
|
|
126
|
+
|
|
127
|
+
--------------------
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
### Type Aliases
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
#### GetAppleInAppPurchaseProductsResult
|
|
134
|
+
|
|
135
|
+
<code>{ products: AppleInAppPurchaseProduct[]; }</code>
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
#### AppleInAppPurchaseProduct
|
|
139
|
+
|
|
140
|
+
<code>{ id: string; title: string; description: string; price: number; localizedPrice: string; subscriptionPeriod?: { value: number; unit: <a href="#applesubscriptionperiodunit">AppleSubscriptionPeriodUnit</a>; }; }</code>
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
#### GetAppleInAppPurchaseProductsOptions
|
|
144
|
+
|
|
145
|
+
<code>{ id: string[]; }</code>
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
#### BuyAppleInAppPurchaseResult
|
|
149
|
+
|
|
150
|
+
<code><a href="#completedappleinapppurchaseresult">CompletedAppleInAppPurchaseResult</a> | <a href="#restoredappleinapppurchaseresult">RestoredAppleInAppPurchaseResult</a> | <a href="#failedappleinapppurchaseresult">FailedAppleInAppPurchaseResult</a> | <a href="#cancelledappleinapppurchaseresult">CancelledAppleInAppPurchaseResult</a></code>
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
#### CompletedAppleInAppPurchaseResult
|
|
154
|
+
|
|
155
|
+
<code>{ status: <a href="#appleinapppurchasestatus">AppleInAppPurchaseStatus.Completed</a>; productIdentifier: string; transactionIdentifier: string; }</code>
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
#### RestoredAppleInAppPurchaseResult
|
|
159
|
+
|
|
160
|
+
<code>{ status: <a href="#appleinapppurchasestatus">AppleInAppPurchaseStatus.Restored</a>; } & <a href="#omit">Omit</a><<a href="#completedappleinapppurchaseresult">CompletedAppleInAppPurchaseResult</a>, 'status'></code>
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
#### Omit
|
|
164
|
+
|
|
165
|
+
Construct a type with the properties of T except for those in type K.
|
|
166
|
+
|
|
167
|
+
<code><a href="#pick">Pick</a><T, <a href="#exclude">Exclude</a><keyof T, K>></code>
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
#### Pick
|
|
171
|
+
|
|
172
|
+
From T, pick a set of properties whose keys are in the union K
|
|
173
|
+
|
|
174
|
+
<code>{
|
|
175
|
[P in K]: T[P];
|
|
1
176
|
}</code>
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
#### Exclude
|
|
180
|
+
|
|
181
|
+
<a href="#exclude">Exclude</a> from T those types that are assignable to U
|
|
182
|
+
|
|
183
|
+
<code>T extends U ? never : T</code>
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
#### FailedAppleInAppPurchaseResult
|
|
187
|
+
|
|
188
|
+
<code>{ status: <a href="#appleinapppurchasestatus">AppleInAppPurchaseStatus.Failed</a>; productIdentifier?: string; transactionIdentifier?: string; }</code>
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
#### CancelledAppleInAppPurchaseResult
|
|
192
|
+
|
|
193
|
+
<code>{ status: <a href="#appleinapppurchasestatus">AppleInAppPurchaseStatus.Cancelled</a>; } & <a href="#omit">Omit</a><<a href="#failedappleinapppurchaseresult">FailedAppleInAppPurchaseResult</a>, 'status'></code>
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
#### BuyAppleInAppPurchaseOptions
|
|
197
|
+
|
|
198
|
+
<code>{ id: string; }</code>
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
#### RestoreAppleInAppPurchaseResult
|
|
202
|
+
|
|
203
|
+
<code><a href="#buyappleinapppurchaseresult">BuyAppleInAppPurchaseResult</a></code>
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
#### GetAppleInAppPurchaseReceiptResult
|
|
207
|
+
|
|
208
|
+
<code>{ receiptData: string; }</code>
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
#### GooglePayResult
|
|
212
|
+
|
|
213
|
+
<code>{ result: <a href="#googlepayresults">GooglePayResults</a>; }</code>
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
#### GooglePayOptions
|
|
217
|
+
|
|
218
|
+
<code>{ clientSecret: string; }</code>
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
### Enums
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
#### AppleSubscriptionPeriodUnit
|
|
225
|
+
|
|
226
|
+
| Members | Value |
|
|
227
|
+
| ----------- | -------------- |
|
|
228
|
+
| **`Day`** | <code>0</code> |
|
|
229
|
+
| **`Week`** | <code>1</code> |
|
|
230
|
+
| **`Month`** | <code>2</code> |
|
|
231
|
+
| **`Year`** | <code>3</code> |
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
#### AppleInAppPurchaseStatus
|
|
235
|
+
|
|
236
|
+
| Members | Value |
|
|
237
|
+
| --------------- | ------------------------ |
|
|
238
|
+
| **`Completed`** | <code>'completed'</code> |
|
|
239
|
+
| **`Restored`** | <code>'restored'</code> |
|
|
240
|
+
| **`Cancelled`** | <code>'cancelled'</code> |
|
|
241
|
+
| **`Failed`** | <code>'failed'</code> |
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
#### GooglePayResults
|
|
245
|
+
|
|
246
|
+
| Members | Value |
|
|
247
|
+
| --------------- | ------------------------ |
|
|
248
|
+
| **`Completed`** | <code>'completed'</code> |
|
|
249
|
+
| **`Failed`** | <code>'failed'</code> |
|
|
250
|
+
|
|
251
|
+
</docgen-api>
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
ext {
|
|
2
|
+
junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
|
|
3
|
+
androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.7.0'
|
|
4
|
+
androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.2.1'
|
|
5
|
+
androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.6.1'
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
buildscript {
|
|
9
|
+
repositories {
|
|
10
|
+
google()
|
|
11
|
+
mavenCentral()
|
|
12
|
+
}
|
|
13
|
+
dependencies {
|
|
14
|
+
classpath 'com.android.tools.build:gradle:8.9.0'
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
apply plugin: 'com.android.library'
|
|
19
|
+
|
|
20
|
+
android {
|
|
21
|
+
namespace "app.dicty.plugins.payment"
|
|
22
|
+
compileSdk project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 35
|
|
23
|
+
defaultConfig {
|
|
24
|
+
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 23
|
|
25
|
+
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 35
|
|
26
|
+
versionCode 1
|
|
27
|
+
versionName "1.0"
|
|
28
|
+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
|
29
|
+
}
|
|
30
|
+
buildTypes {
|
|
31
|
+
release {
|
|
32
|
+
minifyEnabled false
|
|
33
|
+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
lintOptions {
|
|
37
|
+
abortOnError false
|
|
38
|
+
}
|
|
39
|
+
compileOptions {
|
|
40
|
+
sourceCompatibility JavaVersion.VERSION_21
|
|
41
|
+
targetCompatibility JavaVersion.VERSION_21
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
gradle.projectsEvaluated {
|
|
45
|
+
tasks.withType(JavaCompile) {
|
|
46
|
+
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
repositories {
|
|
52
|
+
google()
|
|
53
|
+
mavenCentral()
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
dependencies {
|
|
58
|
+
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
|
59
|
+
implementation project(':capacitor-android')
|
|
60
|
+
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
|
|
61
|
+
testImplementation "junit:junit:$junitVersion"
|
|
62
|
+
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
|
|
63
|
+
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
|
|
64
|
+
implementation 'com.google.android.gms:play-services-wallet:19.1.0'
|
|
65
|
+
implementation 'com.stripe:stripe-android:20.15.0'
|
|
66
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
package app.dicty.plugins.payment;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
|
|
5
|
+
public enum GooglePayEvents {
|
|
6
|
+
Completed("completed"),
|
|
7
|
+
Cancelled("cancelled"),
|
|
8
|
+
Failed("failed");
|
|
9
|
+
|
|
10
|
+
private final String stringValue;
|
|
11
|
+
|
|
12
|
+
GooglePayEvents(String toString) {
|
|
13
|
+
stringValue = toString;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
@NonNull
|
|
17
|
+
@Override
|
|
18
|
+
public String toString() {
|
|
19
|
+
return stringValue;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
package app.dicty.plugins.payment;
|
|
2
|
+
|
|
3
|
+
import android.content.Context;
|
|
4
|
+
import android.content.pm.ApplicationInfo;
|
|
5
|
+
import android.content.pm.PackageManager;
|
|
6
|
+
|
|
7
|
+
import androidx.core.util.Supplier;
|
|
8
|
+
|
|
9
|
+
import com.getcapacitor.Logger;
|
|
10
|
+
import com.stripe.android.googlepaylauncher.GooglePayEnvironment;
|
|
11
|
+
|
|
12
|
+
public class MetaData {
|
|
13
|
+
|
|
14
|
+
public String publicKey;
|
|
15
|
+
public String countryCode;
|
|
16
|
+
public String displayName;
|
|
17
|
+
public String stripeAccount;
|
|
18
|
+
public GooglePayEnvironment env;
|
|
19
|
+
|
|
20
|
+
public MetaData(Supplier<Context> contextSupplier) {
|
|
21
|
+
try {
|
|
22
|
+
ApplicationInfo appInfo = contextSupplier.get()
|
|
23
|
+
.getPackageManager()
|
|
24
|
+
.getApplicationInfo(contextSupplier.get().getPackageName(), PackageManager.GET_META_DATA);
|
|
25
|
+
|
|
26
|
+
publicKey = appInfo.metaData.getString("app.dicty.plugins.payment.public_key");
|
|
27
|
+
stripeAccount = appInfo.metaData.getString("app.dicty.plugins.payment.account");
|
|
28
|
+
countryCode = appInfo.metaData.getString("app.dicty.plugins.payment.merchant_country_code");
|
|
29
|
+
displayName = appInfo.metaData.getString("app.dicty.plugins.payment.merchant_display_name");
|
|
30
|
+
env = appInfo.metaData.getBoolean("app.dicty.plugins.payment.debug")
|
|
31
|
+
? GooglePayEnvironment.Test
|
|
32
|
+
: GooglePayEnvironment.Production;
|
|
33
|
+
|
|
34
|
+
} catch (Exception ignored) {
|
|
35
|
+
Logger.info("MetaData didn't be prepare fore Google Pay.");
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
package app.dicty.plugins.payment;
|
|
2
|
+
|
|
3
|
+
import com.getcapacitor.JSObject;
|
|
4
|
+
import com.getcapacitor.Plugin;
|
|
5
|
+
import com.getcapacitor.PluginCall;
|
|
6
|
+
import com.getcapacitor.PluginMethod;
|
|
7
|
+
import com.getcapacitor.annotation.CapacitorPlugin;
|
|
8
|
+
import com.stripe.android.PaymentConfiguration;
|
|
9
|
+
import com.stripe.android.googlepaylauncher.GooglePayLauncher;
|
|
10
|
+
|
|
11
|
+
import org.jetbrains.annotations.NotNull;
|
|
12
|
+
|
|
13
|
+
@CapacitorPlugin(name = "Payment")
|
|
14
|
+
public class PaymentPlugin extends Plugin {
|
|
15
|
+
private GooglePayLauncher googlePayLauncher;
|
|
16
|
+
private boolean isAvailable;
|
|
17
|
+
private String payCallId;
|
|
18
|
+
|
|
19
|
+
@Override
|
|
20
|
+
public void load() {
|
|
21
|
+
MetaData metaData = new MetaData(this::getContext);
|
|
22
|
+
PaymentConfiguration.init(getContext(), metaData.publicKey, metaData.stripeAccount);
|
|
23
|
+
|
|
24
|
+
googlePayLauncher = new GooglePayLauncher(
|
|
25
|
+
getActivity(),
|
|
26
|
+
new GooglePayLauncher.Config(metaData.env, metaData.countryCode, metaData.displayName),
|
|
27
|
+
(boolean isReady) -> this.isAvailable = isReady,
|
|
28
|
+
this::onGooglePayResult
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
private void onGooglePayResult(@NotNull GooglePayLauncher.Result result) {
|
|
33
|
+
PluginCall call = bridge.getSavedCall(payCallId);
|
|
34
|
+
if (result instanceof GooglePayLauncher.Result.Completed) {
|
|
35
|
+
call.resolve(new JSObject().put("result", GooglePayEvents.Completed.toString()));
|
|
36
|
+
} else if (result instanceof GooglePayLauncher.Result.Canceled) {
|
|
37
|
+
call.resolve(new JSObject().put("result", GooglePayEvents.Cancelled.toString()));
|
|
38
|
+
} else if (result instanceof GooglePayLauncher.Result.Failed) {
|
|
39
|
+
call.resolve(new JSObject().put("result", GooglePayEvents.Failed.toString()));
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
@PluginMethod
|
|
44
|
+
public void isGooglePayAvailable(final PluginCall call) {
|
|
45
|
+
if (isAvailable) {
|
|
46
|
+
call.resolve();
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
call.unimplemented("Not implemented on Device.");
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
@PluginMethod
|
|
53
|
+
public void handleGooglePay(final PluginCall call) {
|
|
54
|
+
String clientSecret = call.getString("clientSecret");
|
|
55
|
+
|
|
56
|
+
if (clientSecret == null) {
|
|
57
|
+
call.reject("Call must provide \"clientSecret\"");
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
payCallId = call.getCallbackId();
|
|
62
|
+
bridge.saveCall(call);
|
|
63
|
+
googlePayLauncher.presentForPaymentIntent(clientSecret);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
@PluginMethod
|
|
67
|
+
public void isAppleInAppPurchaseAvailable(final PluginCall call) {
|
|
68
|
+
call.unavailable("Not implemented on Android");
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
@PluginMethod
|
|
72
|
+
public void getAppleInAppPurchaseProducts(final PluginCall call) {
|
|
73
|
+
call.unavailable("Not implemented on Android");
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
@PluginMethod
|
|
77
|
+
public void buyAppleInAppPurchase(final PluginCall call) {
|
|
78
|
+
call.unavailable("Not implemented on Android");
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
@PluginMethod
|
|
82
|
+
public void restoreAppleInAppPurchase(final PluginCall call) {
|
|
83
|
+
call.unavailable("Not implemented on Android");
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
@PluginMethod
|
|
87
|
+
public void getAppleInAppPurchaseReceipt(final PluginCall call) {
|
|
88
|
+
call.unavailable("Not implemented on Android");
|
|
89
|
+
}
|
|
90
|
+
}
|
|
File without changes
|