@rnw-community/react-native-payments 0.79.0 → 0.80.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/app.plugin.js ADDED
@@ -0,0 +1 @@
1
+ module.exports = require('./plugins/with-payments');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rnw-community/react-native-payments",
3
- "version": "0.79.0",
3
+ "version": "0.80.0",
4
4
  "description": "React Native Payments",
5
5
  "keywords": [
6
6
  "react",
@@ -15,7 +15,9 @@
15
15
  "apple pay",
16
16
  "payment intents",
17
17
  "cross platform",
18
- "react native payments"
18
+ "react native payments",
19
+ "expo",
20
+ "expo-plugin"
19
21
  ],
20
22
  "author": "Vitalii Yehorov <vitalyiegorov@gmail.com> (https://github.com/rnw-community/rnw-community/packages/react-native-payments)",
21
23
  "homepage": "https://github.com/rnw-community/rnw-community/tree/master/packages/react-native-payments",
@@ -29,6 +31,7 @@
29
31
  "import": "./dist/esm/index.js",
30
32
  "require": "./dist/cjs/index.js"
31
33
  },
34
+ "./app.plugin": "./app.plugin.js",
32
35
  "./package.json": "./package.json"
33
36
  },
34
37
  "react-native": "src/index.ts",
@@ -42,6 +45,8 @@
42
45
  "ios",
43
46
  "cpp",
44
47
  "*.podspec",
48
+ "plugins",
49
+ "app.plugin.js",
45
50
  "!ios/build",
46
51
  "!android/build",
47
52
  "!android/gradle",
@@ -74,9 +79,10 @@
74
79
  "build:android": "cd example/android && ./gradlew assembleDebug --no-daemon --console=plain -PreactNativeArchitectures=arm64-v8a",
75
80
  "build:ios": "cd example/ios && xcodebuild -workspace PaymentsExample.xcworkspace -scheme PaymentsExample -configuration Debug -sdk iphonesimulator CC=clang CPLUSPLUS=clang++ LD=clang LDPLUSPLUS=clang++ GCC_OPTIMIZATION_LEVEL=0 GCC_PRECOMPILE_PREFIX_HEADER=YES ASSETCATALOG_COMPILER_OPTIMIZATION=time DEBUG_INFORMATION_FORMAT=dwarf COMPILER_INDEX_STORE_ENABLE=NO"
76
81
  },
77
- "gitHead": "e5a79e08939b2cf89c33747302b0c41df0285aa9",
82
+ "gitHead": "dc054b67b89063f58a4ea7f4039c46b9bfb5e179",
78
83
  "dependencies": {
79
- "@rnw-community/shared": "0.79.0",
84
+ "@expo/config-plugins": "8.0.10",
85
+ "@rnw-community/shared": "0.80.0",
80
86
  "react-native-uuid": "^2.0.1",
81
87
  "validator": "^13.9.0"
82
88
  },
@@ -86,6 +92,7 @@
86
92
  "react-native": "^0.76.1"
87
93
  },
88
94
  "peerDependencies": {
95
+ "expo": ">=48.0.0",
89
96
  "react": ">=17",
90
97
  "react-native": ">=0.64"
91
98
  },
@@ -0,0 +1,24 @@
1
+ const { withDangerousMod } = require("@expo/config-plugins");
2
+ const fs = require("fs");
3
+ const path = require("path");
4
+
5
+ const withApplePay = (config) =>
6
+ withDangerousMod(config, [
7
+ "ios",
8
+ async (config) => {
9
+ const filePath = path.join(
10
+ config.modRequest.platformProjectRoot,
11
+ config.modRequest.projectName,
12
+ "AppDelegate.h"
13
+ );
14
+
15
+ const content = fs.readFileSync(filePath, "utf-8");
16
+ if (!content.includes("#import <PassKit/PassKit.h>")) {
17
+ fs.writeFileSync(filePath, `#import <PassKit/PassKit.h>\n${content}`);
18
+ }
19
+
20
+ return config;
21
+ },
22
+ ]);
23
+
24
+ module.exports = { withApplePay };
@@ -0,0 +1,49 @@
1
+ const { withAppBuildGradle, withAndroidManifest } = require("@expo/config-plugins");
2
+
3
+ const withGooglePay = (config) => {
4
+ // Add Google Pay dependency to app/build.gradle
5
+ config = withAppBuildGradle(config, (config) => {
6
+ if (config.modResults.language === "groovy") {
7
+ config.modResults.contents = config.modResults.contents.replace(
8
+ /dependencies\s?{/,
9
+ `dependencies {
10
+ implementation 'com.google.android.gms:play-services-wallet:19.2.0'`,
11
+ );
12
+ } else {
13
+ throw new Error(
14
+ "Unable to add Google Pay dependency to build.gradle: Kotlin build files are not supported."
15
+ );
16
+ }
17
+ return config;
18
+ });
19
+
20
+ // Add meta-data to AndroidManifest.xml
21
+ config = withAndroidManifest(config, async (config) => {
22
+ const androidManifest = config.modResults;
23
+ const mainApplication = androidManifest.manifest.application[0];
24
+
25
+ // Check if the meta-data already exists
26
+ const existingMetaData = mainApplication["meta-data"]?.find(
27
+ (metadata) => metadata.$["android:name"] === "com.google.android.gms.wallet.api.enabled"
28
+ );
29
+
30
+ if (!existingMetaData) {
31
+ // Add the new meta-data
32
+ if (!mainApplication["meta-data"]) {
33
+ mainApplication["meta-data"] = [];
34
+ }
35
+ mainApplication["meta-data"].push({
36
+ $: {
37
+ "android:name": "com.google.android.gms.wallet.api.enabled",
38
+ "android:value": "true",
39
+ },
40
+ });
41
+ }
42
+
43
+ return config;
44
+ });
45
+
46
+ return config;
47
+ };
48
+
49
+ module.exports = { withGooglePay };
@@ -0,0 +1,12 @@
1
+ const { withPlugins } = require('@expo/config-plugins');
2
+ const { withApplePay } = require('./with-apple-pay');
3
+ const { withGooglePay } = require('./with-google-pay');
4
+
5
+ const withPayments = (config) => {
6
+ return withPlugins(config, [
7
+ withApplePay,
8
+ withGooglePay
9
+ ]);
10
+ };
11
+
12
+ module.exports = withPayments;
package/readme.md CHANGED
@@ -81,6 +81,33 @@ dependencies {
81
81
 
82
82
  - Your google account that are you using for testing should be added to [Google Pay API Test Cards Allowlist](https://groups.google.com/g/googlepay-test-mode-stub-data?pli=1)
83
83
 
84
+ ### Expo setup
85
+
86
+ To integrate with Expo custom builds, you need to add the payment plugin from the package into your `app.config.js`:
87
+
88
+ 1. Update your `app.config.js` configuration:
89
+ ```js
90
+ export default {
91
+ expo: {
92
+ ...
93
+ ios: {
94
+ ...
95
+ infoPlist: {
96
+ merchant_id: [your_merchant_id],
97
+ },
98
+ entitlements: {
99
+ "com.apple.developer.in-app-payments": [your_merchant_id],
100
+ },
101
+ ...
102
+ },
103
+ plugins: [
104
+ ...
105
+ "@rnw-community/react-native-payments",
106
+ ],
107
+ },
108
+ };
109
+ ```
110
+
84
111
  ## Usage
85
112
 
86
113
  Detailed guide should be found at: