@rnw-community/react-native-payments 0.83.1 → 1.2.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.
Files changed (98) hide show
  1. package/LICENSE.md +1 -1
  2. package/dist/cjs/app.plugin.d.ts +3 -0
  3. package/dist/cjs/app.plugin.d.ts.map +1 -0
  4. package/dist/cjs/app.plugin.js +5 -0
  5. package/dist/cjs/app.plugin.js.map +1 -0
  6. package/dist/cjs/class/payment-request/payment-request.d.ts.map +1 -1
  7. package/dist/cjs/class/payment-request/payment-request.js +4 -3
  8. package/dist/cjs/class/payment-request/payment-request.js.map +1 -1
  9. package/dist/cjs/class/payment-request/payment-request.web.d.ts +5 -0
  10. package/dist/cjs/class/payment-request/payment-request.web.d.ts.map +1 -0
  11. package/dist/cjs/class/payment-request/payment-request.web.js +5 -0
  12. package/dist/cjs/class/payment-request/payment-request.web.js.map +1 -0
  13. package/dist/cjs/class/payment-response/payment-response.d.ts.map +1 -1
  14. package/dist/cjs/class/payment-response/payment-response.js +4 -3
  15. package/dist/cjs/class/payment-response/payment-response.js.map +1 -1
  16. package/dist/cjs/class/payment-response/payment-response.web.d.ts +5 -0
  17. package/dist/cjs/class/payment-response/payment-response.web.d.ts.map +1 -0
  18. package/dist/cjs/class/payment-response/payment-response.web.js +5 -0
  19. package/dist/cjs/class/payment-response/payment-response.web.js.map +1 -0
  20. package/dist/cjs/expo-plugins/plugin.props.d.ts +4 -0
  21. package/dist/cjs/expo-plugins/plugin.props.d.ts.map +1 -0
  22. package/dist/cjs/expo-plugins/plugin.props.js +3 -0
  23. package/dist/cjs/expo-plugins/plugin.props.js.map +1 -0
  24. package/dist/cjs/expo-plugins/with-apple-pay.d.ts +4 -0
  25. package/dist/cjs/expo-plugins/with-apple-pay.d.ts.map +1 -0
  26. package/dist/cjs/expo-plugins/with-apple-pay.js +24 -0
  27. package/dist/cjs/expo-plugins/with-apple-pay.js.map +1 -0
  28. package/dist/cjs/expo-plugins/with-google-pay.d.ts +4 -0
  29. package/dist/cjs/expo-plugins/with-google-pay.d.ts.map +1 -0
  30. package/dist/cjs/expo-plugins/with-google-pay.js +26 -0
  31. package/dist/cjs/expo-plugins/with-google-pay.js.map +1 -0
  32. package/dist/cjs/expo-plugins/with-payments.d.ts +4 -0
  33. package/dist/cjs/expo-plugins/with-payments.d.ts.map +1 -0
  34. package/dist/cjs/expo-plugins/with-payments.js +12 -0
  35. package/dist/cjs/expo-plugins/with-payments.js.map +1 -0
  36. package/dist/cjs/util/is-valid-decimal-monetary-value.util.js +2 -2
  37. package/dist/cjs/util/is-valid-decimal-monetary-value.util.js.map +1 -1
  38. package/dist/cjs/util/validate-payment-methods.util.js +1 -1
  39. package/dist/cjs/util/validate-payment-methods.util.js.map +1 -1
  40. package/dist/esm/app.plugin.d.ts +3 -0
  41. package/dist/esm/app.plugin.d.ts.map +1 -0
  42. package/dist/esm/app.plugin.js +3 -0
  43. package/dist/esm/app.plugin.js.map +1 -0
  44. package/dist/esm/class/payment-request/payment-request.d.ts.map +1 -1
  45. package/dist/esm/class/payment-request/payment-request.js +5 -4
  46. package/dist/esm/class/payment-request/payment-request.js.map +1 -1
  47. package/dist/esm/class/payment-request/payment-request.web.d.ts +5 -0
  48. package/dist/esm/class/payment-request/payment-request.web.d.ts.map +1 -0
  49. package/dist/esm/class/payment-request/payment-request.web.js +2 -0
  50. package/dist/esm/class/payment-request/payment-request.web.js.map +1 -0
  51. package/dist/esm/class/payment-response/payment-response.d.ts.map +1 -1
  52. package/dist/esm/class/payment-response/payment-response.js +4 -3
  53. package/dist/esm/class/payment-response/payment-response.js.map +1 -1
  54. package/dist/esm/class/payment-response/payment-response.web.d.ts +5 -0
  55. package/dist/esm/class/payment-response/payment-response.web.d.ts.map +1 -0
  56. package/dist/esm/class/payment-response/payment-response.web.js +2 -0
  57. package/dist/esm/class/payment-response/payment-response.web.js.map +1 -0
  58. package/dist/esm/expo-plugins/plugin.props.d.ts +4 -0
  59. package/dist/esm/expo-plugins/plugin.props.d.ts.map +1 -0
  60. package/dist/esm/expo-plugins/plugin.props.js +2 -0
  61. package/dist/esm/expo-plugins/plugin.props.js.map +1 -0
  62. package/dist/esm/expo-plugins/with-apple-pay.d.ts +4 -0
  63. package/dist/esm/expo-plugins/with-apple-pay.d.ts.map +1 -0
  64. package/dist/esm/expo-plugins/with-apple-pay.js +20 -0
  65. package/dist/esm/expo-plugins/with-apple-pay.js.map +1 -0
  66. package/dist/esm/expo-plugins/with-google-pay.d.ts +4 -0
  67. package/dist/esm/expo-plugins/with-google-pay.d.ts.map +1 -0
  68. package/dist/esm/expo-plugins/with-google-pay.js +22 -0
  69. package/dist/esm/expo-plugins/with-google-pay.js.map +1 -0
  70. package/dist/esm/expo-plugins/with-payments.d.ts +4 -0
  71. package/dist/esm/expo-plugins/with-payments.d.ts.map +1 -0
  72. package/dist/esm/expo-plugins/with-payments.js +8 -0
  73. package/dist/esm/expo-plugins/with-payments.js.map +1 -0
  74. package/dist/esm/util/is-valid-decimal-monetary-value.util.js +2 -2
  75. package/dist/esm/util/is-valid-decimal-monetary-value.util.js.map +1 -1
  76. package/dist/esm/util/validate-payment-methods.util.js +2 -2
  77. package/dist/esm/util/validate-payment-methods.util.js.map +1 -1
  78. package/ios/Payments.mm +9 -1
  79. package/package.json +11 -13
  80. package/react-native-payments.podspec +21 -18
  81. package/readme.md +33 -27
  82. package/src/app.plugin.ts +3 -0
  83. package/src/class/payment-request/payment-request.spec.ts +691 -0
  84. package/src/class/payment-request/payment-request.ts +5 -4
  85. package/src/class/payment-request/payment-request.web.ts +1 -0
  86. package/src/class/payment-response/payment-response.spec.ts +142 -0
  87. package/src/class/payment-response/payment-response.ts +4 -3
  88. package/src/class/payment-response/payment-response.web.ts +1 -0
  89. package/src/expo-plugins/plugin.props.ts +3 -0
  90. package/src/expo-plugins/with-apple-pay.ts +27 -0
  91. package/src/expo-plugins/with-google-pay.ts +31 -0
  92. package/src/expo-plugins/with-payments.ts +13 -0
  93. package/src/util/is-valid-decimal-monetary-value.util.ts +2 -2
  94. package/src/util/validate-payment-methods.util.ts +2 -2
  95. package/app.plugin.js +0 -1
  96. package/plugins/with-apple-pay.js +0 -24
  97. package/plugins/with-google-pay.js +0 -49
  98. package/plugins/with-payments.js +0 -12
@@ -0,0 +1,4 @@
1
+ import type { ReactNativePaymentsPluginProps } from './plugin.props';
2
+ import type { ConfigPlugin } from '@expo/config-plugins';
3
+ export declare const withGooglePay: ConfigPlugin<ReactNativePaymentsPluginProps>;
4
+ //# sourceMappingURL=with-google-pay.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"with-google-pay.d.ts","sourceRoot":"","sources":["../../../src/expo-plugins/with-google-pay.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,gBAAgB,CAAC;AACrE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEzD,eAAO,MAAM,aAAa,EAAE,YAAY,CAAC,8BAA8B,CAyBjE,CAAC"}
@@ -0,0 +1,22 @@
1
+ import { withAndroidManifest } from '@expo/config-plugins';
2
+ export const withGooglePay = initialConfig => withAndroidManifest(initialConfig, config => {
3
+ const androidManifest = config.modResults;
4
+ const mainApplication = androidManifest.manifest.application?.[0];
5
+ if (mainApplication) {
6
+ const existingMetaData = mainApplication['meta-data']?.find(metadata => metadata.$['android:name'] === 'com.google.android.gms.wallet.api.enabled');
7
+ if (!existingMetaData) {
8
+ if (!mainApplication['meta-data']) {
9
+ mainApplication['meta-data'] = [];
10
+ }
11
+ mainApplication['meta-data'].push({
12
+ // eslint-disable-next-line id-length
13
+ $: {
14
+ 'android:name': 'com.google.android.gms.wallet.api.enabled',
15
+ 'android:value': 'true',
16
+ },
17
+ });
18
+ }
19
+ }
20
+ return config;
21
+ });
22
+ //# sourceMappingURL=with-google-pay.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"with-google-pay.js","sourceRoot":"","sources":["../../../src/expo-plugins/with-google-pay.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAK3D,MAAM,CAAC,MAAM,aAAa,GAAiD,aAAa,CAAC,EAAE,CACvF,mBAAmB,CAAC,aAAa,EAAE,MAAM,CAAC,EAAE;IACxC,MAAM,eAAe,GAAG,MAAM,CAAC,UAAU,CAAC;IAC1C,MAAM,eAAe,GAAG,eAAe,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC;IAElE,IAAI,eAAe,EAAE,CAAC;QAClB,MAAM,gBAAgB,GAAG,eAAe,CAAC,WAAW,CAAC,EAAE,IAAI,CACvD,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,cAAc,CAAC,KAAK,2CAA2C,CACzF,CAAC;QAEF,IAAI,CAAC,gBAAgB,EAAE,CAAC;YACpB,IAAI,CAAC,eAAe,CAAC,WAAW,CAAC,EAAE,CAAC;gBAChC,eAAe,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC;YACtC,CAAC;YACD,eAAe,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC;gBAC9B,qCAAqC;gBACrC,CAAC,EAAE;oBACC,cAAc,EAAE,2CAA2C;oBAC3D,eAAe,EAAE,MAAM;iBAC1B;aACJ,CAAC,CAAC;QACP,CAAC;IACL,CAAC;IAED,OAAO,MAAM,CAAC;AAClB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { ReactNativePaymentsPluginProps } from './plugin.props';
2
+ import type { ConfigPlugin } from '@expo/config-plugins';
3
+ export declare const withPayments: ConfigPlugin<ReactNativePaymentsPluginProps>;
4
+ //# sourceMappingURL=with-payments.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"with-payments.d.ts","sourceRoot":"","sources":["../../../src/expo-plugins/with-payments.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,gBAAgB,CAAC;AACrE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEzD,eAAO,MAAM,YAAY,EAAE,YAAY,CAAC,8BAA8B,CAIhE,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { withPlugins } from '@expo/config-plugins';
2
+ import { withApplePay } from './with-apple-pay';
3
+ import { withGooglePay } from './with-google-pay';
4
+ export const withPayments = (config, props) => withPlugins(config, [
5
+ [withApplePay, props],
6
+ [withGooglePay, props],
7
+ ]);
8
+ //# sourceMappingURL=with-payments.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"with-payments.js","sourceRoot":"","sources":["../../../src/expo-plugins/with-payments.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAKlD,MAAM,CAAC,MAAM,YAAY,GAAiD,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CACxF,WAAW,CAAC,MAAM,EAAE;IAChB,CAAC,YAAY,EAAE,KAAK,CAAC;IACrB,CAAC,aAAa,EAAE,KAAK,CAAC;CACzB,CAAC,CAAC"}
@@ -1,10 +1,10 @@
1
- import isDecimal from 'validator/es/lib/isDecimal';
1
+ import validator from 'validator';
2
2
  import { isNumber, isString } from '@rnw-community/shared';
3
3
  const isValidStringAmount = (stringAmount) => {
4
4
  if (stringAmount.endsWith('.')) {
5
5
  return false;
6
6
  }
7
- return isDecimal(stringAmount);
7
+ return validator.isDecimal(stringAmount);
8
8
  };
9
9
  export const isValidDecimalMonetaryValue = (amountValue) => {
10
10
  if (!isNumber(amountValue) && !isString(amountValue)) {
@@ -1 +1 @@
1
- {"version":3,"file":"is-valid-decimal-monetary-value.util.js","sourceRoot":"","sources":["../../../src/util/is-valid-decimal-monetary-value.util.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,4BAA4B,CAAC;AAEnD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAI3D,MAAM,mBAAmB,GAAG,CAAC,YAAoB,EAAW,EAAE;IAC1D,IAAI,YAAY,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QAC7B,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,OAAO,SAAS,CAAC,YAAY,CAAC,CAAC;AACnC,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,WAAwB,EAAW,EAAE;IAC7E,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;QACnD,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,OAAO,QAAQ,CAAC,WAAW,CAAC,IAAI,mBAAmB,CAAC,WAAW,CAAC,CAAC;AACrE,CAAC,CAAC"}
1
+ {"version":3,"file":"is-valid-decimal-monetary-value.util.js","sourceRoot":"","sources":["../../../src/util/is-valid-decimal-monetary-value.util.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAI3D,MAAM,mBAAmB,GAAG,CAAC,YAAoB,EAAW,EAAE;IAC1D,IAAI,YAAY,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QAC7B,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,OAAO,SAAS,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;AAC7C,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,WAAwB,EAAW,EAAE;IAC7E,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;QACnD,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,OAAO,QAAQ,CAAC,WAAW,CAAC,IAAI,mBAAmB,CAAC,WAAW,CAAC,CAAC;AACrE,CAAC,CAAC"}
@@ -1,9 +1,9 @@
1
- import { isDefined } from '@rnw-community/shared';
1
+ import { isDefined, isNotEmptyArray } from '@rnw-community/shared';
2
2
  import { ConstructorError } from '../error/constructor.error';
3
3
  /** @deprecated Move to PaymentRequest */
4
4
  export const validatePaymentMethods = (methodData) => {
5
5
  // Check that at least one payment method is passed in
6
- if (methodData.length < 1) {
6
+ if (!isNotEmptyArray(methodData)) {
7
7
  throw new ConstructorError(`At least one payment method is required`);
8
8
  }
9
9
  // Check that each payment method has at least one payment method identifier
@@ -1 +1 @@
1
- {"version":3,"file":"validate-payment-methods.util.js","sourceRoot":"","sources":["../../../src/util/validate-payment-methods.util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAI9D,yCAAyC;AACzC,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,UAA+B,EAAQ,EAAE;IAC5E,sDAAsD;IACtD,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACxB,MAAM,IAAI,gBAAgB,CAAC,yCAAyC,CAAC,CAAC;IAC1E,CAAC;IAED,4EAA4E;IAC5E,UAAU,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE;QAC/B,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,gBAAgB,CAAC,EAAE,CAAC;YAC7C,MAAM,IAAI,gBAAgB,CAAC,gDAAgD,CAAC,CAAC;QACjF,CAAC;IACL,CAAC,CAAC,CAAC;AACP,CAAC,CAAC"}
1
+ {"version":3,"file":"validate-payment-methods.util.js","sourceRoot":"","sources":["../../../src/util/validate-payment-methods.util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAEnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAI9D,yCAAyC;AACzC,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,UAA+B,EAAQ,EAAE;IAC5E,sDAAsD;IACtD,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC,EAAE,CAAC;QAC/B,MAAM,IAAI,gBAAgB,CAAC,yCAAyC,CAAC,CAAC;IAC1E,CAAC;IAED,4EAA4E;IAC5E,UAAU,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE;QAC/B,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,gBAAgB,CAAC,EAAE,CAAC;YAC7C,MAAM,IAAI,gBAAgB,CAAC,gDAAgD,CAAC,CAAC;QACjF,CAAC;IACL,CAAC,CAAC,CAAC;AACP,CAAC,CAAC"}
package/ios/Payments.mm CHANGED
@@ -170,7 +170,15 @@ RCT_EXPORT_METHOD(complete: (NSString *)paymentStatus
170
170
 
171
171
  self.completion([[PKPaymentAuthorizationResult alloc] initWithStatus:status errors:nil]);
172
172
 
173
- resolve(nil);
173
+ dispatch_async(dispatch_get_main_queue(), ^{
174
+ if (self.viewController.presentingViewController) {
175
+ [self.viewController dismissViewControllerAnimated:YES completion:^{
176
+ resolve(nil);
177
+ }];
178
+ } else {
179
+ resolve(nil);
180
+ }
181
+ });
174
182
  }
175
183
 
176
184
  RCT_EXPORT_METHOD(canMakePayments: (NSString *)methodDataString
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@rnw-community/react-native-payments",
3
- "version": "0.83.1",
4
- "description": "React Native Payments",
3
+ "version": "1.2.0",
4
+ "description": "Accept Payments with Apple Pay and Android Pay using the Payment Request API.",
5
5
  "keywords": [
6
6
  "react",
7
7
  "react-native",
@@ -31,7 +31,10 @@
31
31
  "import": "./dist/esm/index.js",
32
32
  "require": "./dist/cjs/index.js"
33
33
  },
34
- "./app.plugin": "./app.plugin.js",
34
+ "./app.plugin": {
35
+ "import": "./dist/esm/app.plugin.js",
36
+ "require": "./dist/cjs/app.plugin.js"
37
+ },
35
38
  "./package.json": "./package.json"
36
39
  },
37
40
  "react-native": "src/index.ts",
@@ -45,8 +48,6 @@
45
48
  "ios",
46
49
  "cpp",
47
50
  "*.podspec",
48
- "plugins",
49
- "app.plugin.js",
50
51
  "!ios/build",
51
52
  "!android/build",
52
53
  "!android/gradle",
@@ -72,17 +73,14 @@
72
73
  "test": "run -T jest --passWithNoTests",
73
74
  "test:coverage": "run -T jest --coverage --passWithNoTests",
74
75
  "format": "run -T prettier --write \"./src/**/*.{ts,tsx}\"",
75
- "clear": "rm -rf coverage && rm -rf dist && rm -f *.tsbuildinfo && yarn run clear:native",
76
+ "clear": "rm -rf coverage && rm -rf dist && rm -f *.tsbuildinfo",
76
77
  "clear:deps": "rm -rf ./node_modules && rm -rf ./dist",
77
- "clear:native": "rm -rf android/build example/android/build example/android/app/build example/ios/build",
78
- "example": "yarn --cwd example",
79
- "build:android": "cd example/android && ./gradlew assembleDebug --no-daemon --console=plain -PreactNativeArchitectures=arm64-v8a",
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"
78
+ "example": "yarn --cwd example"
81
79
  },
82
- "gitHead": "53579cfd92900eecdf1237fe27974a2fd8198b7e",
80
+ "gitHead": "028837fd8d39e79797438f41eeff1128a9ad5652",
83
81
  "dependencies": {
84
- "@expo/config-plugins": "8.0.10",
85
- "@rnw-community/shared": "0.83.0",
82
+ "@expo/config-plugins": "^9.0.14",
83
+ "@rnw-community/shared": "1.1.0",
86
84
  "react-native-uuid": "^2.0.1",
87
85
  "validator": "^13.9.0"
88
86
  },
@@ -11,31 +11,34 @@ Pod::Spec.new do |s|
11
11
  s.license = package["license"]
12
12
  s.authors = package["author"]
13
13
 
14
- s.platforms = { :ios => "11.0" }
14
+ s.platforms = { :ios => min_ios_version_supported }
15
15
  s.source = { :git => "https://github.com/vitalyiegorov/react-native-payments.git", :tag => "#{s.version}" }
16
16
 
17
- s.source_files = "ios/**/*.{h,m,mm}"
17
+ s.source_files = "ios/**/*.{h,m,mm,cpp}"
18
+ s.private_header_files = "ios/generated/**/*.h"
19
+
20
+ s.frameworks = "PassKit"
18
21
 
19
22
  # Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
20
23
  # See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
21
24
  if respond_to?(:install_modules_dependencies, true)
22
25
  install_modules_dependencies(s)
23
26
  else
24
- s.dependency "React-Core"
27
+ s.dependency "React-Core"
25
28
 
26
- # Don't install the dependencies when we run `pod install` in the old architecture.
27
- if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
28
- s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
29
- s.pod_target_xcconfig = {
30
- "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
31
- "OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
32
- "CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
33
- }
34
- s.dependency "React-Codegen"
35
- s.dependency "RCT-Folly"
36
- s.dependency "RCTRequired"
37
- s.dependency "RCTTypeSafety"
38
- s.dependency "ReactCommon/turbomodule/core"
39
- end
40
- end
29
+ # Don't install the dependencies when we run `pod install` in the old architecture.
30
+ if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
31
+ s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
32
+ s.pod_target_xcconfig = {
33
+ "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
34
+ "OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
35
+ "CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
36
+ }
37
+ s.dependency "React-Codegen"
38
+ s.dependency "RCT-Folly"
39
+ s.dependency "RCTRequired"
40
+ s.dependency "RCTTypeSafety"
41
+ s.dependency "ReactCommon/turbomodule/core"
42
+ end
43
+ end
41
44
  end
package/readme.md CHANGED
@@ -52,6 +52,7 @@ integration experience for your applications.
52
52
  - Follow [this guide](https://developer.apple.com/library/archive/ApplePay_Guide/Configuration.html) to setup ApplePay in
53
53
  your application.
54
54
  - [Payment token reference](https://developer.apple.com/documentation/passkit/apple_pay/payment_token_format_reference?language=objc)
55
+ #### Objective-C setup
55
56
  - Add following code to your `AppDelegate.h`:
56
57
  ```objc
57
58
  #import <RCTAppDelegate.h>
@@ -59,7 +60,15 @@ integration experience for your applications.
59
60
  #import <PassKit/PassKit.h> // Add this import
60
61
 
61
62
  @interface AppDelegate : RCTAppDelegate
62
-
63
+ ```
64
+ #### Swift setup
65
+ - Add following code to your `AppDelegate.swift`:
66
+ ```swift
67
+ import UIKit
68
+ import React
69
+ import React_RCTAppDelegate
70
+ import ReactAppDependencyProvider
71
+ import PassKit // Add this import
63
72
  ```
64
73
 
65
74
  ### AndroidPay setup
@@ -83,30 +92,27 @@ dependencies {
83
92
 
84
93
  ### Expo setup
85
94
 
86
- To integrate with Expo custom builds, you need to add the payment plugin from the package into your `app.config.js`:
95
+ To integrate with Expo [custom builds](https://docs.expo.dev/custom-builds/get-started/), you need to add the `@rnw-community/react-native-payments` plugin into your `app.config.js`:
87
96
 
88
97
  1. Update your `app.config.js` configuration:
89
98
  ```js
90
99
  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
100
  plugins: [
104
101
  ...
105
- "@rnw-community/react-native-payments",
102
+ [
103
+ "@rnw-community/react-native-payments/app.plugin",
104
+ {
105
+ "merchantIdentifier": "merchant.react-native-payments"
106
+ }
107
+ ],
106
108
  ],
107
109
  },
108
110
  };
109
111
  ```
112
+ 2. Prebuild your project:
113
+ ```bash
114
+ npx expo prebuild --clean
115
+ ```
110
116
 
111
117
  ## Usage
112
118
 
@@ -181,7 +187,7 @@ Depending on the platform and payment method, you can provide additional data to
181
187
 
182
188
  - `environment`: This property represents the Android environment for the payment.
183
189
  - `requestPayerName`: "An optional boolean field that, when present and set to true, indicates that the `PaymentResponse` will include the name of the payer.
184
- - `requestPayerPhone`: "An optional boolean field that, when present and set to true, indicates that the `PaymentResponse` will include the phone of the payer.
190
+ - `requestPayerPhone`: "An optional boolean field that, when present and set to true, indicates that the `PaymentResponse` will include the phone of the payer.
185
191
  - `requestBillingAddress`: An optional boolean field that, when present and set to true, indicates that the `PaymentResponse` will
186
192
  include the billing address of the payer.
187
193
  - `requestPayerEmail`: An optional boolean field that, when present and set to true, indicates that the `PaymentResponse` will
@@ -305,8 +311,16 @@ export function setupJestTurboModuleMock(): void {
305
311
 
306
312
  ## Example
307
313
 
308
- You can find working example in the `App` component of
309
- the [react-native-payments-example](../react-native-payments-example/README.md) package.
314
+ ### Expo
315
+ You can find working example in the `App` component of the [react-native-payments-expo-example](../react-native-payments-expo-example/README.md) package.
316
+
317
+ #### Web(react-native-web)
318
+ On web the library will fallback to [W3C implementation](https://developer.mozilla.org/en-US/docs/Web/API/Payment_Request_API)
319
+
320
+ ### Bare React Native CLI
321
+ You can find working example in the `App` component of the [react-native-payments-example](../react-native-payments-example/README.md) package.
322
+
323
+
310
324
 
311
325
  ## TODO
312
326
 
@@ -335,16 +349,8 @@ the [react-native-payments-example](../react-native-payments-example/README.md)
335
349
 
336
350
  ### Other
337
351
 
338
- - [ ] Add [EXPO support](https://docs.expo.dev/modules/existing-library/)
339
- - [ ] Add unit tests
340
352
  - [ ] Refactor `utils`
341
- - [ ] Add web support
342
- - [ ] Merge react-native-payments-example into this package, and setup it properly
343
- - [ ] CI/CD:
344
- - [ ] check/setup pull request
345
- - [ ] check/setup push to master and release to NPM
346
- - [ ] add e2e via maestro for IOS
347
- - [ ] add e2e via maestro for Android
353
+ - [ ] Find alternative/suctom implementation for the `validator` library
348
354
 
349
355
  ## License
350
356
 
@@ -0,0 +1,3 @@
1
+ import { withPayments } from './expo-plugins/with-payments';
2
+
3
+ export default withPayments;