pa-sdk-react-native 3.0.2 → 3.0.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.
Files changed (59) hide show
  1. package/README.md +21 -12
  2. package/example/App.tsx +583 -0
  3. package/example/README.md +105 -0
  4. package/example/android/app/build.gradle +130 -0
  5. package/example/android/app/debug.keystore +0 -0
  6. package/example/android/app/proguard-rules.pro +10 -0
  7. package/example/android/app/src/debug/AndroidManifest.xml +9 -0
  8. package/example/android/app/src/main/AndroidManifest.xml +26 -0
  9. package/example/android/app/src/main/java/com/pademo/MainActivity.kt +22 -0
  10. package/example/android/app/src/main/java/com/pademo/MainApplication.kt +45 -0
  11. package/example/android/app/src/main/res/drawable/rn_edit_text_material.xml +37 -0
  12. package/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
  13. package/example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png +0 -0
  14. package/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
  15. package/example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png +0 -0
  16. package/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
  17. package/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
  18. package/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
  19. package/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
  20. package/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
  21. package/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
  22. package/example/android/app/src/main/res/values/strings.xml +3 -0
  23. package/example/android/app/src/main/res/values/styles.xml +9 -0
  24. package/example/android/build.gradle +21 -0
  25. package/example/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  26. package/example/android/gradle/wrapper/gradle-wrapper.properties +7 -0
  27. package/example/android/gradle.properties +39 -0
  28. package/example/android/gradlew +251 -0
  29. package/example/android/gradlew.bat +94 -0
  30. package/example/android/settings.gradle +8 -0
  31. package/example/app.json +4 -0
  32. package/example/index.js +4 -0
  33. package/example/ios/.xcode.env +11 -0
  34. package/example/ios/.xcode.env.local +1 -0
  35. package/example/ios/PaSdkExample/AppDelegate.swift +111 -0
  36. package/example/ios/PaSdkExample/Images.xcassets/AppIcon.appiconset/Contents.json +53 -0
  37. package/example/ios/PaSdkExample/Images.xcassets/Contents.json +6 -0
  38. package/example/ios/PaSdkExample/Info.plist +81 -0
  39. package/example/ios/PaSdkExample/LaunchScreen.storyboard +47 -0
  40. package/example/ios/PaSdkExample/PrivacyInfo.xcprivacy +37 -0
  41. package/example/ios/PaSdkExample.xcodeproj/project.pbxproj +468 -0
  42. package/example/ios/PaSdkExample.xcodeproj/xcshareddata/xcschemes/PaSdkExample.xcscheme +88 -0
  43. package/example/ios/PaSdkExample.xcworkspace/contents.xcworkspacedata +10 -0
  44. package/example/ios/Podfile +39 -0
  45. package/example/ios/Podfile.lock +1990 -0
  46. package/example/metro.config.js +17 -0
  47. package/example/package.json +29 -0
  48. package/example/patches/react-native+0.79.0.patch +215 -0
  49. package/lib/api.d.ts +3 -0
  50. package/lib/api.js +9 -2
  51. package/lib/confirm.js +78 -32
  52. package/lib/locales.generated.js +108 -4
  53. package/locales/en-US.json +27 -1
  54. package/locales/ms-MY.json +27 -1
  55. package/locales/zh-CN.json +27 -1
  56. package/locales/zh-TW.json +27 -1
  57. package/native/ios/PaSdk3ds.swift +3 -2
  58. package/native/ios/PaSdk3dsModule.m +2 -1
  59. package/package.json +10 -2
@@ -0,0 +1,17 @@
1
+ const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');
2
+
3
+ /**
4
+ * Metro configuration. pa-sdk-react-native is a file: dependency symlinked
5
+ * to the repository root (one level up), so Metro needs the SDK root in
6
+ * watchFolders and the example's node_modules first on the resolution path.
7
+ */
8
+ const config = {
9
+ watchFolders: [require('path').resolve(__dirname, '..')],
10
+ resolver: {
11
+ nodeModulesPaths: [
12
+ require('path').resolve(__dirname, 'node_modules'),
13
+ ],
14
+ },
15
+ };
16
+
17
+ module.exports = mergeConfig(getDefaultConfig(__dirname), config);
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "pa-sdk-react-native-example",
3
+ "version": "3.0.4",
4
+ "private": true,
5
+ "scripts": {
6
+ "android": "react-native run-android",
7
+ "ios": "react-native run-ios",
8
+ "start": "react-native start",
9
+ "postinstall": "patch-package"
10
+ },
11
+ "dependencies": {
12
+ "pa-sdk-react-native": "file:..",
13
+ "react": "^19.0.0",
14
+ "react-native": "0.79.0",
15
+ "react-native-webview": "^13.0.0"
16
+ },
17
+ "devDependencies": {
18
+ "@babel/core": "^7.25.0",
19
+ "@react-native-community/cli": "^18.0.1",
20
+ "@react-native-community/cli-platform-android": "^18.0.1",
21
+ "@react-native/babel-preset": "0.79.0",
22
+ "@react-native/metro-config": "0.79.0",
23
+ "patch-package": "^8.0.0",
24
+ "typescript": "^5.5.0"
25
+ },
26
+ "reactNative": {
27
+ "newArchEnabled": true
28
+ }
29
+ }
@@ -0,0 +1,215 @@
1
+ diff --git a/node_modules/react-native/Libraries/Blob/React-RCTBlob.podspec b/node_modules/react-native/Libraries/Blob/React-RCTBlob.podspec
2
+ index 9d758c1..8258360 100644
3
+ --- a/node_modules/react-native/Libraries/Blob/React-RCTBlob.podspec
4
+ +++ b/node_modules/react-native/Libraries/Blob/React-RCTBlob.podspec
5
+ @@ -50,7 +50,7 @@ Pod::Spec.new do |s|
6
+
7
+ s.dependency "DoubleConversion"
8
+ s.dependency "fast_float", "6.1.4"
9
+ - s.dependency "fmt", "11.0.2"
10
+ + s.dependency "fmt", "11.2.0"
11
+ s.dependency "RCT-Folly", folly_version
12
+ s.dependency "React-jsi"
13
+ s.dependency "React-Core/RCTBlobHeaders"
14
+ diff --git a/node_modules/react-native/React/CoreModules/React-CoreModules.podspec b/node_modules/react-native/React/CoreModules/React-CoreModules.podspec
15
+ index 486e7f9..7ad706f 100644
16
+ --- a/node_modules/react-native/React/CoreModules/React-CoreModules.podspec
17
+ +++ b/node_modules/react-native/React/CoreModules/React-CoreModules.podspec
18
+ @@ -61,7 +61,7 @@ Pod::Spec.new do |s|
19
+ s.framework = "UIKit"
20
+ s.dependency "DoubleConversion"
21
+ s.dependency "fast_float", "6.1.4"
22
+ - s.dependency "fmt", "11.0.2"
23
+ + s.dependency "fmt", "11.2.0"
24
+ s.dependency "RCT-Folly", folly_version
25
+ s.dependency "RCTTypeSafety", version
26
+ s.dependency "React-Core/CoreModulesHeaders", version
27
+ diff --git a/node_modules/react-native/ReactCommon/React-Fabric.podspec b/node_modules/react-native/ReactCommon/React-Fabric.podspec
28
+ index 1bff9d9..e23db48 100644
29
+ --- a/node_modules/react-native/ReactCommon/React-Fabric.podspec
30
+ +++ b/node_modules/react-native/ReactCommon/React-Fabric.podspec
31
+ @@ -55,7 +55,7 @@ Pod::Spec.new do |s|
32
+ s.dependency "glog"
33
+ s.dependency "DoubleConversion"
34
+ s.dependency "fast_float", "6.1.4"
35
+ - s.dependency "fmt", "11.0.2"
36
+ + s.dependency "fmt", "11.2.0"
37
+ s.dependency "React-Core"
38
+ s.dependency "React-debug"
39
+ s.dependency "React-featureflags"
40
+ diff --git a/node_modules/react-native/ReactCommon/React-FabricComponents.podspec b/node_modules/react-native/ReactCommon/React-FabricComponents.podspec
41
+ index be4e3fd..38aaa58 100644
42
+ --- a/node_modules/react-native/ReactCommon/React-FabricComponents.podspec
43
+ +++ b/node_modules/react-native/ReactCommon/React-FabricComponents.podspec
44
+ @@ -77,7 +77,7 @@ Pod::Spec.new do |s|
45
+ s.dependency "glog"
46
+ s.dependency "DoubleConversion"
47
+ s.dependency "fast_float", "6.1.4"
48
+ - s.dependency "fmt", "11.0.2"
49
+ + s.dependency "fmt", "11.2.0"
50
+ s.dependency "React-Core"
51
+ s.dependency "React-debug"
52
+ s.dependency "React-featureflags"
53
+ diff --git a/node_modules/react-native/ReactCommon/React-FabricImage.podspec b/node_modules/react-native/ReactCommon/React-FabricImage.podspec
54
+ index bb60cf9..21e6353 100644
55
+ --- a/node_modules/react-native/ReactCommon/React-FabricImage.podspec
56
+ +++ b/node_modules/react-native/ReactCommon/React-FabricImage.podspec
57
+ @@ -77,7 +77,7 @@ Pod::Spec.new do |s|
58
+ s.dependency "glog"
59
+ s.dependency "DoubleConversion"
60
+ s.dependency "fast_float", "6.1.4"
61
+ - s.dependency "fmt", "11.0.2"
62
+ + s.dependency "fmt", "11.2.0"
63
+ s.dependency "React-featureflags"
64
+ s.dependency "React-utils"
65
+ s.dependency "Yoga"
66
+ diff --git a/node_modules/react-native/ReactCommon/ReactCommon.podspec b/node_modules/react-native/ReactCommon/ReactCommon.podspec
67
+ index a6020da..b22c303 100644
68
+ --- a/node_modules/react-native/ReactCommon/ReactCommon.podspec
69
+ +++ b/node_modules/react-native/ReactCommon/ReactCommon.podspec
70
+ @@ -55,7 +55,7 @@ Pod::Spec.new do |s|
71
+ ss.dependency "React-logger", version
72
+ ss.dependency "DoubleConversion"
73
+ ss.dependency "fast_float", "6.1.4"
74
+ - ss.dependency "fmt", "11.0.2"
75
+ + ss.dependency "fmt", "11.2.0"
76
+ ss.dependency "glog"
77
+ if using_hermes
78
+ ss.dependency "hermes-engine"
79
+ diff --git a/node_modules/react-native/ReactCommon/cxxreact/React-cxxreact.podspec b/node_modules/react-native/ReactCommon/cxxreact/React-cxxreact.podspec
80
+ index 6961cf4..1c6b460 100644
81
+ --- a/node_modules/react-native/ReactCommon/cxxreact/React-cxxreact.podspec
82
+ +++ b/node_modules/react-native/ReactCommon/cxxreact/React-cxxreact.podspec
83
+ @@ -44,7 +44,7 @@ Pod::Spec.new do |s|
84
+ s.dependency "boost"
85
+ s.dependency "DoubleConversion"
86
+ s.dependency "fast_float", "6.1.4"
87
+ - s.dependency "fmt", "11.0.2"
88
+ + s.dependency "fmt", "11.2.0"
89
+ s.dependency "RCT-Folly", folly_version
90
+ s.dependency "glog"
91
+ add_dependency(s, "React-jsinspector", :framework_name => 'jsinspector_modern')
92
+ diff --git a/node_modules/react-native/ReactCommon/hermes/React-hermes.podspec b/node_modules/react-native/ReactCommon/hermes/React-hermes.podspec
93
+ index 0a0da65..3f5e781 100644
94
+ --- a/node_modules/react-native/ReactCommon/hermes/React-hermes.podspec
95
+ +++ b/node_modules/react-native/ReactCommon/hermes/React-hermes.podspec
96
+ @@ -50,7 +50,7 @@ Pod::Spec.new do |s|
97
+ s.dependency "RCT-Folly", folly_version
98
+ s.dependency "DoubleConversion"
99
+ s.dependency "fast_float", "6.1.4"
100
+ - s.dependency "fmt", "11.0.2"
101
+ + s.dependency "fmt", "11.2.0"
102
+ s.dependency "glog"
103
+ s.dependency "hermes-engine"
104
+ s.dependency "React-jsi"
105
+ diff --git a/node_modules/react-native/ReactCommon/jsi/React-jsi.podspec b/node_modules/react-native/ReactCommon/jsi/React-jsi.podspec
106
+ index fb3cbe9..e0b2530 100644
107
+ --- a/node_modules/react-native/ReactCommon/jsi/React-jsi.podspec
108
+ +++ b/node_modules/react-native/ReactCommon/jsi/React-jsi.podspec
109
+ @@ -47,7 +47,7 @@ Pod::Spec.new do |s|
110
+ s.dependency "boost"
111
+ s.dependency "DoubleConversion"
112
+ s.dependency "fast_float", "6.1.4"
113
+ - s.dependency "fmt", "11.0.2"
114
+ + s.dependency "fmt", "11.2.0"
115
+ s.dependency "RCT-Folly", folly_version
116
+ s.dependency "glog"
117
+
118
+ diff --git a/node_modules/react-native/ReactCommon/jsiexecutor/React-jsiexecutor.podspec b/node_modules/react-native/ReactCommon/jsiexecutor/React-jsiexecutor.podspec
119
+ index ff874dc..80a9f73 100644
120
+ --- a/node_modules/react-native/ReactCommon/jsiexecutor/React-jsiexecutor.podspec
121
+ +++ b/node_modules/react-native/ReactCommon/jsiexecutor/React-jsiexecutor.podspec
122
+ @@ -43,7 +43,7 @@ Pod::Spec.new do |s|
123
+ s.dependency "RCT-Folly", folly_version
124
+ s.dependency "DoubleConversion"
125
+ s.dependency "fast_float", "6.1.4"
126
+ - s.dependency "fmt", "11.0.2"
127
+ + s.dependency "fmt", "11.2.0"
128
+ s.dependency "glog"
129
+ add_dependency(s, "React-jsinspector", :framework_name => 'jsinspector_modern')
130
+ add_dependency(s, "React-jsinspectortracing", :framework_name => 'jsinspector_moderntracing')
131
+ diff --git a/node_modules/react-native/ReactCommon/jsitooling/React-jsitooling.podspec b/node_modules/react-native/ReactCommon/jsitooling/React-jsitooling.podspec
132
+ index 0b5bbdf..afb9ef0 100644
133
+ --- a/node_modules/react-native/ReactCommon/jsitooling/React-jsitooling.podspec
134
+ +++ b/node_modules/react-native/ReactCommon/jsitooling/React-jsitooling.podspec
135
+ @@ -59,7 +59,7 @@ Pod::Spec.new do |s|
136
+ s.dependency "RCT-Folly", folly_version
137
+ s.dependency "DoubleConversion"
138
+ s.dependency "fast_float", "6.1.4"
139
+ - s.dependency "fmt", "11.0.2"
140
+ + s.dependency "fmt", "11.2.0"
141
+ s.dependency "glog"
142
+ add_dependency(s, "React-jsinspector", :framework_name => 'jsinspector_modern')
143
+ add_dependency(s, "React-jsinspectortracing", :framework_name => 'jsinspector_moderntracing')
144
+ diff --git a/node_modules/react-native/ReactCommon/react/nativemodule/samples/ReactCommon-Samples.podspec b/node_modules/react-native/ReactCommon/react/nativemodule/samples/ReactCommon-Samples.podspec
145
+ index d7d8d07..faa5a9a 100644
146
+ --- a/node_modules/react-native/ReactCommon/react/nativemodule/samples/ReactCommon-Samples.podspec
147
+ +++ b/node_modules/react-native/ReactCommon/react/nativemodule/samples/ReactCommon-Samples.podspec
148
+ @@ -64,7 +64,7 @@ Pod::Spec.new do |s|
149
+ s.dependency "RCT-Folly"
150
+ s.dependency "DoubleConversion"
151
+ s.dependency "fast_float", "6.1.4"
152
+ - s.dependency "fmt", "11.0.2"
153
+ + s.dependency "fmt", "11.2.0"
154
+ s.dependency "React-Core"
155
+ s.dependency "React-cxxreact"
156
+ s.dependency "React-jsi"
157
+ diff --git a/node_modules/react-native/ReactCommon/react/renderer/debug/React-rendererdebug.podspec b/node_modules/react-native/ReactCommon/react/renderer/debug/React-rendererdebug.podspec
158
+ index 52dc39c..adb10ba 100644
159
+ --- a/node_modules/react-native/ReactCommon/react/renderer/debug/React-rendererdebug.podspec
160
+ +++ b/node_modules/react-native/ReactCommon/react/renderer/debug/React-rendererdebug.podspec
161
+ @@ -59,6 +59,6 @@ Pod::Spec.new do |s|
162
+ s.dependency "RCT-Folly", folly_version
163
+ s.dependency "DoubleConversion"
164
+ s.dependency "fast_float", "6.1.4"
165
+ - s.dependency "fmt", "11.0.2"
166
+ + s.dependency "fmt", "11.2.0"
167
+ add_dependency(s, "React-debug")
168
+ end
169
+ diff --git a/node_modules/react-native/ReactCommon/react/renderer/graphics/React-graphics.podspec b/node_modules/react-native/ReactCommon/react/renderer/graphics/React-graphics.podspec
170
+ index 9eddee7..8a60374 100644
171
+ --- a/node_modules/react-native/ReactCommon/react/renderer/graphics/React-graphics.podspec
172
+ +++ b/node_modules/react-native/ReactCommon/react/renderer/graphics/React-graphics.podspec
173
+ @@ -65,7 +65,7 @@ Pod::Spec.new do |s|
174
+ s.dependency "React-utils"
175
+ s.dependency "DoubleConversion"
176
+ s.dependency "fast_float", "6.1.4"
177
+ - s.dependency "fmt", "11.0.2"
178
+ + s.dependency "fmt", "11.2.0"
179
+
180
+ depend_on_js_engine(s)
181
+ end
182
+ diff --git a/node_modules/react-native/third-party-podspecs/RCT-Folly.podspec b/node_modules/react-native/third-party-podspecs/RCT-Folly.podspec
183
+ index b3c60a5..ad08338 100644
184
+ --- a/node_modules/react-native/third-party-podspecs/RCT-Folly.podspec
185
+ +++ b/node_modules/react-native/third-party-podspecs/RCT-Folly.podspec
186
+ @@ -24,7 +24,7 @@ Pod::Spec.new do |spec|
187
+ spec.dependency 'DoubleConversion'
188
+ spec.dependency 'glog'
189
+ spec.dependency "fast_float", "6.1.4"
190
+ - spec.dependency "fmt", "11.0.2"
191
+ + spec.dependency "fmt", "11.2.0"
192
+ spec.compiler_flags = folly_compiler_flags + ' -DFOLLY_HAVE_PTHREAD=1 -Wno-documentation -faligned-new'
193
+ spec.source_files = 'folly/String.cpp',
194
+ 'folly/Conv.cpp',
195
+ diff --git a/node_modules/react-native/third-party-podspecs/fmt.podspec b/node_modules/react-native/third-party-podspecs/fmt.podspec
196
+ index 2f38990..6454ff1 100644
197
+ --- a/node_modules/react-native/third-party-podspecs/fmt.podspec
198
+ +++ b/node_modules/react-native/third-party-podspecs/fmt.podspec
199
+ @@ -8,14 +8,14 @@ fmt_git_url = fmt_config[:git]
200
+
201
+ Pod::Spec.new do |spec|
202
+ spec.name = "fmt"
203
+ - spec.version = "11.0.2"
204
+ + spec.version = "11.2.0"
205
+ spec.license = { :type => "MIT" }
206
+ spec.homepage = "https://github.com/fmtlib/fmt"
207
+ spec.summary = "{fmt} is an open-source formatting library for C++. It can be used as a safe and fast alternative to (s)printf and iostreams."
208
+ spec.authors = "The fmt contributors"
209
+ spec.source = {
210
+ :git => fmt_git_url,
211
+ - :tag => "11.0.2"
212
+ + :tag => "11.2.0"
213
+ }
214
+ spec.pod_target_xcconfig = {
215
+ "CLANG_CXX_LANGUAGE_STANDARD" => rct_cxx_language_standard(),
package/lib/api.d.ts CHANGED
@@ -12,6 +12,9 @@ import type { ConfirmGatewayPayload, Environment, ThreeDsAction } from './types'
12
12
  export declare const GATEWAY_BASE_URLS: {
13
13
  [env in Environment]: string;
14
14
  };
15
+ /** CardInput accepts 2-digit expiry years ("29"); the gateway requires
16
+ * YYYY — expand before sending (RN-13). */
17
+ export declare function normalizeExpiryYear(year: number | string): string;
15
18
  export interface ApiCallOptions {
16
19
  /** Publishable merchantToken — used for per-account paths. */
17
20
  merchantToken?: string;
package/lib/api.js CHANGED
@@ -11,6 +11,7 @@
11
11
  */
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  exports.ApiClient = exports.GATEWAY_BASE_URLS = void 0;
14
+ exports.normalizeExpiryYear = normalizeExpiryYear;
14
15
  const errors_1 = require("./errors");
15
16
  const errors_generated_1 = require("./errors.generated");
16
17
  /** Whether a code exists in the shared table. */
@@ -22,6 +23,12 @@ exports.GATEWAY_BASE_URLS = {
22
23
  sandbox: 'https://gateway-sandbox.pa-sys.com/pasdk/v1',
23
24
  };
24
25
  const HTTP_OK = 200;
26
+ /** CardInput accepts 2-digit expiry years ("29"); the gateway requires
27
+ * YYYY — expand before sending (RN-13). */
28
+ function normalizeExpiryYear(year) {
29
+ const raw = String(year).trim();
30
+ return raw.length === 2 ? '20' + raw : raw;
31
+ }
25
32
  class ApiClient {
26
33
  constructor(environment, origin) {
27
34
  this.environment = environment;
@@ -114,7 +121,7 @@ class ApiClient {
114
121
  session_token: params.sessionToken,
115
122
  card_number: params.cardNumber,
116
123
  card_expiry_month: String(params.expiryMonth).padStart(2, '0'),
117
- card_expiry_year: String(params.expiryYear),
124
+ card_expiry_year: normalizeExpiryYear(params.expiryYear),
118
125
  card_cvv: params.cvc,
119
126
  card_holder_name: params.cardHolderName,
120
127
  };
@@ -154,7 +161,7 @@ class ApiClient {
154
161
  body.card_expiry_month = params.cardExpiryMonth;
155
162
  }
156
163
  if (params.cardExpiryYear) {
157
- body.card_expiry_year = params.cardExpiryYear;
164
+ body.card_expiry_year = normalizeExpiryYear(params.cardExpiryYear);
158
165
  }
159
166
  if (params.merchantReference) {
160
167
  body.merchant_reference = params.merchantReference;
package/lib/confirm.js CHANGED
@@ -159,34 +159,88 @@ async function handleThreeDs(api, options, threedsData) {
159
159
  }
160
160
  return { done: false };
161
161
  });
162
- let dismissal = null;
163
162
  let presentFailure = null;
164
- try {
165
- dismissal = await (0, threeDs_1.presentThreeDs)({
166
- url,
167
- fields,
168
- strings: {
169
- title: strings('threeds.title'),
170
- cancel: strings('threeds.cancel'),
171
- close: strings('threeds.close'),
172
- processing: strings('threeds.processing'),
173
- redirecting: strings('threeds.redirecting'),
174
- },
175
- returnUrlScheme: returnUrls.scheme,
176
- returnUrlUniversalHost: returnUrls.universalLinkHost,
177
- }, options.onThreeDsWillPresent);
178
- }
179
- catch (cause) {
163
+ const presentPromise = (0, threeDs_1.presentThreeDs)({
164
+ url,
165
+ fields,
166
+ strings: {
167
+ title: strings('threeds.title'),
168
+ cancel: strings('threeds.cancel'),
169
+ close: strings('threeds.close'),
170
+ processing: strings('threeds.processing'),
171
+ redirecting: strings('threeds.redirecting'),
172
+ },
173
+ returnUrlScheme: returnUrls.scheme,
174
+ returnUrlUniversalHost: returnUrls.universalLinkHost,
175
+ }, options.onThreeDsWillPresent).then((d) => ({ kind: 'dismissed', dismissal: d }), (cause) => {
180
176
  // Challenge UI failed to appear — not a payment result. Keep
181
177
  // polling the intent; worst case resolves `processing`.
182
178
  presentFailure = cause;
183
- }
179
+ return { kind: 'failed' };
180
+ });
184
181
  if (options.onThreeDsEnded) {
185
- options.onThreeDsEnded();
182
+ void presentPromise.then(() => {
183
+ options.onThreeDsEnded();
184
+ });
185
+ }
186
+ // Race the dismissal against the poller (RN-18): when the challenge
187
+ // completes inside the WebView the gateway settles the intent
188
+ // server-side, so the polled terminal state usually arrives while the
189
+ // challenge is still on screen — close it and let the polled result win.
190
+ const raced = await Promise.race([
191
+ presentPromise,
192
+ pollPromise.then((p) => ({ kind: 'polled', result: p })),
193
+ ]);
194
+ if (raced.kind === 'polled') {
195
+ if (raced.result) {
196
+ (0, threeDs_1.closeThreeDs)();
197
+ await presentPromise;
198
+ return { result: raced.result, cancelled: false };
199
+ }
200
+ // Budget exhausted with the challenge possibly still open — close it so
201
+ // the user is not left on a dead challenge, then resolve `processing`.
202
+ (0, threeDs_1.closeThreeDs)();
203
+ await presentPromise;
204
+ if (presentFailure) {
205
+ throw presentFailure instanceof errors_1.PaError
206
+ ? presentFailure
207
+ : new errors_1.PaError('internal_error', {
208
+ developerMessage: 'The 3DS challenge UI could not be presented.',
209
+ cause: presentFailure,
210
+ });
211
+ }
212
+ return { result: null, cancelled: false };
186
213
  }
187
- if (dismissal && dismissal.cancelled) {
188
- // User closed the challenge -> cancelled. Tell the
189
- // gateway best-effort so the intent does not linger in requires_action.
214
+ if (raced.kind === 'failed') {
215
+ const polled = await pollPromise;
216
+ if (polled) {
217
+ return { result: polled, cancelled: false };
218
+ }
219
+ throw presentFailure instanceof errors_1.PaError
220
+ ? presentFailure
221
+ : new errors_1.PaError('internal_error', {
222
+ developerMessage: 'The 3DS challenge UI could not be presented.',
223
+ cause: presentFailure,
224
+ });
225
+ }
226
+ if (raced.dismissal.cancelled) {
227
+ // User closed the challenge. Before reporting `cancelled`, check the
228
+ // intent once more — a cancel that lands after the charge completed
229
+ // must surface the real outcome, never `cancelled`.
230
+ try {
231
+ const final = await api.intentStatus({
232
+ clientToken: options.clientToken,
233
+ intentToken: options.intentToken,
234
+ });
235
+ if (final && final.status && isTerminalStatus(final.status)) {
236
+ poller.stop();
237
+ return { result: payloadToResult(final.status, final, options.intentToken), cancelled: false };
238
+ }
239
+ }
240
+ catch {
241
+ /* fall through to the cancelled path */
242
+ }
243
+ // Tell the gateway best-effort so the intent does not linger in requires_action.
190
244
  poller.stop();
191
245
  try {
192
246
  await api.intentCancel({ clientToken: options.clientToken, intentToken: options.intentToken });
@@ -210,20 +264,12 @@ async function handleThreeDs(api, options, threedsData) {
210
264
  cancelled: true,
211
265
  };
212
266
  }
267
+ // Challenge closed without a user cancel (consumed 3DS return URL) — the
268
+ // polled result is authoritative.
213
269
  const polled = await pollPromise;
214
270
  if (polled) {
215
271
  return { result: polled, cancelled: false };
216
272
  }
217
- if (presentFailure) {
218
- throw presentFailure instanceof errors_1.PaError
219
- ? presentFailure
220
- : new errors_1.PaError('internal_error', {
221
- developerMessage: 'The 3DS challenge UI could not be presented.',
222
- cause: presentFailure,
223
- });
224
- }
225
- // Budget exhausted with the challenge closed and no terminal state —
226
- // `processing`, never `failed`.
227
273
  return { result: null, cancelled: false };
228
274
  }
229
275
  // ---------------------------------------------------------------------------
@@ -59,7 +59,33 @@ exports.LOCALE_BUNDLES = {
59
59
  "field.invalid_expiry": "Check the expiry date",
60
60
  "field.incomplete_cvc": "Enter the security code",
61
61
  "field.invalid_cvc": "Check the security code",
62
- "field.unsupported_brand": "This card type is not accepted"
62
+ "field.unsupported_brand": "This card type is not accepted",
63
+ "error.customer_not_found": "We could not find your customer record. Please contact support.",
64
+ "error.exemption_request_not_supported": "This payment cannot be processed as requested. Please try again.",
65
+ "error.incomplete_cvc": "Please complete the security code.",
66
+ "error.incomplete_expiry": "Please complete the expiry date.",
67
+ "error.incomplete_number": "Please complete the card number.",
68
+ "error.intent_not_awaiting_action": "This payment is no longer awaiting authentication. Please start the payment again.",
69
+ "error.internal_error": "Something went wrong on our side. Please try again.",
70
+ "error.invalid_card_number": "The card number is invalid.",
71
+ "error.invalid_expiry": "The expiry date is invalid.",
72
+ "error.invalid_threeds_result": "The authentication result could not be verified. Please try again.",
73
+ "error.merchant_misconfigured": "The merchant's payment setup is not ready. Please contact the merchant.",
74
+ "error.method_not_allowed": "This action is not supported.",
75
+ "error.network_error": "Network error. Please check your connection and try again.",
76
+ "error.provider_error": "The payment provider could not process the request. Please try again.",
77
+ "error.refund_failed": "The refund could not be completed. Please contact the merchant.",
78
+ "error.request_invalid": "The request was invalid. Please check your details and try again.",
79
+ "error.saved_card_disabled": "This saved card has been disabled. Please use another card.",
80
+ "error.saved_card_not_found": "This saved card is no longer available. Please use another card.",
81
+ "error.session_already_used": "This payment session was already used. Please start a new payment.",
82
+ "error.session_expired": "The payment session has expired. Please try again.",
83
+ "error.threeds_action_external_not_supported_for_setup": "This verification method is not supported for card verification. Please try again.",
84
+ "error.threeds_action_force_not_supported": "This payment cannot be processed with forced authentication. Please try again.",
85
+ "error.threeds_result_required": "An authentication result is required. Please complete authentication and try again.",
86
+ "error.token_not_chargeable": "This card cannot be charged. Please use another card.",
87
+ "error.token_not_found": "This card is no longer available. Please add your card again.",
88
+ "error.transaction_not_permitted": "This transaction is not permitted. Please contact your bank or the merchant."
63
89
  },
64
90
  "ms-MY": {
65
91
  "_meta": {
@@ -110,7 +136,33 @@ exports.LOCALE_BUNDLES = {
110
136
  "field.invalid_expiry": "Semak tarikh luput",
111
137
  "field.incomplete_cvc": "Masukkan kod keselamatan",
112
138
  "field.invalid_cvc": "Semak kod keselamatan",
113
- "field.unsupported_brand": "Jenis kad ini tidak diterima"
139
+ "field.unsupported_brand": "Jenis kad ini tidak diterima",
140
+ "error.customer_not_found": "Rekod pelanggan anda tidak dijumpai. Sila hubungi sokongan.",
141
+ "error.exemption_request_not_supported": "Pembayaran ini tidak dapat diproses seperti yang diminta. Sila cuba lagi.",
142
+ "error.incomplete_cvc": "Sila lengkapkan kod keselamatan kad.",
143
+ "error.incomplete_expiry": "Sila lengkapkan tarikh luput.",
144
+ "error.incomplete_number": "Sila lengkapkan nombor kad.",
145
+ "error.intent_not_awaiting_action": "Pembayaran ini tidak lagi menunggu pengesahan. Sila mulakan pembayaran semula.",
146
+ "error.internal_error": "Berlaku ralat sistem. Sila cuba lagi.",
147
+ "error.invalid_card_number": "Nombor kad tidak sah.",
148
+ "error.invalid_expiry": "Tarikh luput tidak sah.",
149
+ "error.invalid_threeds_result": "Hasil pengesahan tidak dapat disahkan. Sila cuba lagi.",
150
+ "error.merchant_misconfigured": "Tetapan pembayaran peniaga belum sedia. Sila hubungi peniaga.",
151
+ "error.method_not_allowed": "Tindakan ini tidak disokong.",
152
+ "error.network_error": "Ralat rangkaian. Sila semak sambungan anda dan cuba lagi.",
153
+ "error.provider_error": "Perkhidmatan pembayaran tidak dapat memproses permintaan buat sementara. Sila cuba lagi.",
154
+ "error.refund_failed": "Bayaran balik tidak dapat diselesaikan. Sila hubungi peniaga.",
155
+ "error.request_invalid": "Permintaan tidak sah. Sila semak maklumat anda dan cuba lagi.",
156
+ "error.saved_card_disabled": "Kad tersimpan ini telah dilumpuhkan. Sila gunakan kad lain.",
157
+ "error.saved_card_not_found": "Kad tersimpan ini tidak lagi tersedia. Sila gunakan kad lain.",
158
+ "error.session_already_used": "Sesi pembayaran ini telah digunakan. Sila mulakan pembayaran baharu.",
159
+ "error.session_expired": "Sesi pembayaran telah tamat tempoh. Sila cuba lagi.",
160
+ "error.threeds_action_external_not_supported_for_setup": "Kaedah pengesahan ini tidak disokong untuk pengesahan kad. Sila cuba lagi.",
161
+ "error.threeds_action_force_not_supported": "Pembayaran ini tidak menyokong pengesahan paksa. Sila cuba lagi.",
162
+ "error.threeds_result_required": "Hasil pengesahan diperlukan. Sila selesaikan pengesahan dan cuba lagi.",
163
+ "error.token_not_chargeable": "Kad ini tidak boleh dicaj. Sila gunakan kad lain.",
164
+ "error.token_not_found": "Kad ini tidak lagi boleh digunakan. Sila tambah kad anda semula.",
165
+ "error.transaction_not_permitted": "Transaksi ini tidak dibenarkan. Sila hubungi bank anda atau peniaga."
114
166
  },
115
167
  "zh-CN": {
116
168
  "_meta": {
@@ -161,7 +213,33 @@ exports.LOCALE_BUNDLES = {
161
213
  "field.invalid_expiry": "请检查有效期",
162
214
  "field.incomplete_cvc": "请输入安全码",
163
215
  "field.invalid_cvc": "请检查安全码",
164
- "field.unsupported_brand": "不支持此卡片类型"
216
+ "field.unsupported_brand": "不支持此卡片类型",
217
+ "error.customer_not_found": "找不到你的客户记录,请联系客服。",
218
+ "error.exemption_request_not_supported": "此付款无法以指定方式处理,请重试。",
219
+ "error.incomplete_cvc": "请输入完整的卡片安全码。",
220
+ "error.incomplete_expiry": "请输入完整的有效期。",
221
+ "error.incomplete_number": "请输入完整的卡号。",
222
+ "error.intent_not_awaiting_action": "此付款已不在等待验证的阶段,请重新发起付款。",
223
+ "error.internal_error": "系统发生错误,请重试。",
224
+ "error.invalid_card_number": "卡号无效。",
225
+ "error.invalid_expiry": "有效期无效。",
226
+ "error.invalid_threeds_result": "无法核实验证结果,请重试。",
227
+ "error.merchant_misconfigured": "商户的付款设置尚未就绪,请联系商户。",
228
+ "error.method_not_allowed": "不支持此操作方式。",
229
+ "error.network_error": "网络连接错误,请检查网络后重试。",
230
+ "error.provider_error": "付款服务暂时无法处理请求,请重试。",
231
+ "error.refund_failed": "退款无法完成,请联系商户。",
232
+ "error.request_invalid": "请求内容无效,请确认资料后重试。",
233
+ "error.saved_card_disabled": "此已保存卡片已停用,请改用其他卡片。",
234
+ "error.saved_card_not_found": "找不到此已保存卡片,请改用其他卡片。",
235
+ "error.session_already_used": "此付款工作阶段已使用,请重新发起付款。",
236
+ "error.session_expired": "付款工作阶段已过期,请重试。",
237
+ "error.threeds_action_external_not_supported_for_setup": "此验证方式不适用于验证卡片,请重试。",
238
+ "error.threeds_action_force_not_supported": "此付款不支持强制验证,请重试。",
239
+ "error.threeds_result_required": "需要验证结果,请完成验证后重试。",
240
+ "error.token_not_chargeable": "此卡片无法扣款,请改用其他卡片。",
241
+ "error.token_not_found": "此卡片已不可用,请重新添加卡片。",
242
+ "error.transaction_not_permitted": "此交易不被允许,请联系发卡银行或商户。"
165
243
  },
166
244
  "zh-TW": {
167
245
  "_meta": {
@@ -212,6 +290,32 @@ exports.LOCALE_BUNDLES = {
212
290
  "field.invalid_expiry": "請檢查有效期",
213
291
  "field.incomplete_cvc": "請輸入安全碼",
214
292
  "field.invalid_cvc": "請檢查安全碼",
215
- "field.unsupported_brand": "不支援此卡片類型"
293
+ "field.unsupported_brand": "不支援此卡片類型",
294
+ "error.customer_not_found": "找不到你的客戶記錄,請聯絡客服。",
295
+ "error.exemption_request_not_supported": "此付款無法以指定方式處理,請重試。",
296
+ "error.incomplete_cvc": "請輸入完整的卡片安全碼。",
297
+ "error.incomplete_expiry": "請輸入完整的有效日期。",
298
+ "error.incomplete_number": "請輸入完整的卡號。",
299
+ "error.intent_not_awaiting_action": "此付款已不在等待驗證的階段,請重新發起付款。",
300
+ "error.internal_error": "系統發生錯誤,請重試。",
301
+ "error.invalid_card_number": "卡號無效。",
302
+ "error.invalid_expiry": "有效日期無效。",
303
+ "error.invalid_threeds_result": "無法核實驗證結果,請重試。",
304
+ "error.merchant_misconfigured": "商戶的付款設定尚未就緒,請聯絡商戶。",
305
+ "error.method_not_allowed": "不支援此操作方式。",
306
+ "error.network_error": "網絡連線錯誤,請檢查網絡後重試。",
307
+ "error.provider_error": "付款服務暫時無法處理請求,請重試。",
308
+ "error.refund_failed": "退款無法完成,請聯絡商戶。",
309
+ "error.request_invalid": "請求內容無效,請確認資料後重試。",
310
+ "error.saved_card_disabled": "此已儲存卡片已停用,請改用其他卡片。",
311
+ "error.saved_card_not_found": "找不到此已儲存卡片,請改用其他卡片。",
312
+ "error.session_already_used": "此付款工作階段已使用,請重新發起付款。",
313
+ "error.session_expired": "付款工作階段已過期,請重試。",
314
+ "error.threeds_action_external_not_supported_for_setup": "此驗證方式不適用於驗證卡片,請重試。",
315
+ "error.threeds_action_force_not_supported": "此付款不支援強制驗證,請重試。",
316
+ "error.threeds_result_required": "需要驗證結果,請完成驗證後重試。",
317
+ "error.token_not_chargeable": "此卡片無法扣款,請改用其他卡片。",
318
+ "error.token_not_found": "此卡片已不可用,請重新加入卡片。",
319
+ "error.transaction_not_permitted": "此交易不被允許,請聯絡發卡銀行或商戶。"
216
320
  },
217
321
  };
@@ -47,5 +47,31 @@
47
47
  "field.invalid_expiry": "Check the expiry date",
48
48
  "field.incomplete_cvc": "Enter the security code",
49
49
  "field.invalid_cvc": "Check the security code",
50
- "field.unsupported_brand": "This card type is not accepted"
50
+ "field.unsupported_brand": "This card type is not accepted",
51
+ "error.customer_not_found": "We could not find your customer record. Please contact support.",
52
+ "error.exemption_request_not_supported": "This payment cannot be processed as requested. Please try again.",
53
+ "error.incomplete_cvc": "Please complete the security code.",
54
+ "error.incomplete_expiry": "Please complete the expiry date.",
55
+ "error.incomplete_number": "Please complete the card number.",
56
+ "error.intent_not_awaiting_action": "This payment is no longer awaiting authentication. Please start the payment again.",
57
+ "error.internal_error": "Something went wrong on our side. Please try again.",
58
+ "error.invalid_card_number": "The card number is invalid.",
59
+ "error.invalid_expiry": "The expiry date is invalid.",
60
+ "error.invalid_threeds_result": "The authentication result could not be verified. Please try again.",
61
+ "error.merchant_misconfigured": "The merchant's payment setup is not ready. Please contact the merchant.",
62
+ "error.method_not_allowed": "This action is not supported.",
63
+ "error.network_error": "Network error. Please check your connection and try again.",
64
+ "error.provider_error": "The payment provider could not process the request. Please try again.",
65
+ "error.refund_failed": "The refund could not be completed. Please contact the merchant.",
66
+ "error.request_invalid": "The request was invalid. Please check your details and try again.",
67
+ "error.saved_card_disabled": "This saved card has been disabled. Please use another card.",
68
+ "error.saved_card_not_found": "This saved card is no longer available. Please use another card.",
69
+ "error.session_already_used": "This payment session was already used. Please start a new payment.",
70
+ "error.session_expired": "The payment session has expired. Please try again.",
71
+ "error.threeds_action_external_not_supported_for_setup": "This verification method is not supported for card verification. Please try again.",
72
+ "error.threeds_action_force_not_supported": "This payment cannot be processed with forced authentication. Please try again.",
73
+ "error.threeds_result_required": "An authentication result is required. Please complete authentication and try again.",
74
+ "error.token_not_chargeable": "This card cannot be charged. Please use another card.",
75
+ "error.token_not_found": "This card is no longer available. Please add your card again.",
76
+ "error.transaction_not_permitted": "This transaction is not permitted. Please contact your bank or the merchant."
51
77
  }