pa-sdk-react-native 3.0.0 → 3.0.2

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 (42) hide show
  1. package/README.md +140 -73
  2. package/lib/api.d.ts +17 -8
  3. package/lib/api.js +35 -13
  4. package/lib/confirm.d.ts +32 -20
  5. package/lib/confirm.js +33 -22
  6. package/lib/errors.d.ts +9 -7
  7. package/lib/errors.generated.d.ts +2 -2
  8. package/lib/errors.generated.js +9 -2
  9. package/lib/errors.js +12 -19
  10. package/lib/index.d.ts +4 -4
  11. package/lib/index.js +11 -10
  12. package/lib/init.d.ts +8 -8
  13. package/lib/init.js +11 -8
  14. package/lib/locales.d.ts +20 -10
  15. package/lib/locales.generated.d.ts +3 -4
  16. package/lib/locales.generated.js +110 -27
  17. package/lib/locales.js +62 -14
  18. package/lib/poll.d.ts +3 -3
  19. package/lib/poll.js +4 -4
  20. package/lib/threeDs.d.ts +17 -6
  21. package/lib/threeDs.js +24 -2
  22. package/lib/threeDsHost.d.ts +2 -2
  23. package/lib/threeDsHost.js +3 -3
  24. package/lib/tokenize.d.ts +9 -4
  25. package/lib/tokenize.js +6 -4
  26. package/lib/types.d.ts +33 -26
  27. package/lib/types.js +4 -5
  28. package/lib/validator.d.ts +8 -8
  29. package/lib/validator.js +9 -10
  30. package/locales/en-US.json +21 -0
  31. package/locales/ms-MY.json +45 -24
  32. package/locales/zh-CN.json +21 -0
  33. package/locales/zh-TW.json +21 -0
  34. package/native/android/build.gradle +4 -4
  35. package/native/android/src/main/AndroidManifest.xml +12 -11
  36. package/native/android/src/main/java/com/pasdk/reactnative/PaSdk3dsActivity.kt +9 -16
  37. package/native/android/src/main/java/com/pasdk/reactnative/PaSdk3dsModule.kt +3 -3
  38. package/native/ios/PaSdk3ds.swift +64 -21
  39. package/native/ios/PaSdk3dsModule.m +16 -9
  40. package/package.json +3 -3
  41. package/scripts/generate-errors.js +2 -2
  42. package/scripts/generate-locales.js +24 -4
@@ -2,9 +2,8 @@
2
2
  * GENERATED FILE — do not edit by hand.
3
3
  * Generated by scripts/generate-locales.js from locales/*.json.
4
4
  *
5
- * Locale coverage (A10 / COM-28): en-US (complete), zh-TW (complete,
6
- * serves zh_HK/zh-HK), zh-CN (complete), ms-MY (my_MY — empty strings,
7
- * falls back to en-US at runtime until translations are supplied).
5
+ * Locale coverage: en-US (complete), zh-TW (complete,
6
+ * serves zh_HK/zh-HK), zh-CN (complete), ms-MY (my_MY — complete).
8
7
  */
9
8
  export interface LocaleMeta {
10
9
  name: string;
@@ -12,7 +11,7 @@ export interface LocaleMeta {
12
11
  fallback: string | null;
13
12
  complete: boolean;
14
13
  }
15
- export type LocaleKey = 'threeds.title' | 'threeds.cancel' | 'threeds.close' | 'threeds.processing' | 'threeds.redirecting' | 'payment.processing' | 'result.cancelled' | 'error.generic' | 'error.rate_limited' | 'error.processing_timeout' | 'error.sdk_load_failed' | 'error.invalid_publishable_key' | 'error.invalid_client_token' | 'error.origin_not_allowed' | 'error.font_load_failed' | 'field.incomplete_number' | 'field.invalid_number' | 'field.incomplete_expiry' | 'field.invalid_expiry' | 'field.incomplete_cvc' | 'field.invalid_cvc' | 'field.unsupported_brand';
14
+ export type LocaleKey = 'threeds.title' | 'threeds.cancel' | 'threeds.close' | 'threeds.processing' | 'threeds.redirecting' | 'payment.processing' | 'result.cancelled' | 'error.generic' | 'error.rate_limited' | 'error.processing_timeout' | 'error.sdk_load_failed' | 'error.invalid_publishable_key' | 'error.invalid_client_token' | 'error.origin_not_allowed' | 'error.font_load_failed' | 'error.card_declined' | 'error.insufficient_funds' | 'error.expired_card' | 'error.invalid_cvc' | 'error.invalid_number' | 'error.unsupported_brand' | 'error.unsupported_currency' | 'error.threeds_failed' | 'error.threeds_cancelled' | 'error.threeds_not_supported' | 'error.threeds_no_liability_shift' | 'error.amount_above_limit' | 'error.amount_below_limit' | 'error.frequency_limit' | 'error.risk_declined' | 'error.issuer_unavailable' | 'error.acquirer_unavailable' | 'error.refund_exceeds_paid' | 'error.duplicate_confirm' | 'error.intent_expired' | 'error.intent_already_final' | 'field.incomplete_number' | 'field.invalid_number' | 'field.incomplete_expiry' | 'field.invalid_expiry' | 'field.incomplete_cvc' | 'field.invalid_cvc' | 'field.unsupported_brand';
16
15
  export interface LocaleBundle {
17
16
  _meta: LocaleMeta;
18
17
  [key: string]: string | LocaleMeta;
@@ -4,9 +4,8 @@
4
4
  * GENERATED FILE — do not edit by hand.
5
5
  * Generated by scripts/generate-locales.js from locales/*.json.
6
6
  *
7
- * Locale coverage (A10 / COM-28): en-US (complete), zh-TW (complete,
8
- * serves zh_HK/zh-HK), zh-CN (complete), ms-MY (my_MY — empty strings,
9
- * falls back to en-US at runtime until translations are supplied).
7
+ * Locale coverage: en-US (complete), zh-TW (complete,
8
+ * serves zh_HK/zh-HK), zh-CN (complete), ms-MY (my_MY — complete).
10
9
  */
11
10
  Object.defineProperty(exports, "__esModule", { value: true });
12
11
  exports.LOCALE_BUNDLES = void 0;
@@ -33,6 +32,27 @@ exports.LOCALE_BUNDLES = {
33
32
  "error.invalid_client_token": "The payment session has expired. Please try again.",
34
33
  "error.origin_not_allowed": "This website is not authorised to use the payment component.",
35
34
  "error.font_load_failed": "Font failed to load, a system font is used instead.",
35
+ "error.card_declined": "Your card was declined. Please try another card.",
36
+ "error.insufficient_funds": "Insufficient funds on this card.",
37
+ "error.expired_card": "This card has expired.",
38
+ "error.invalid_cvc": "The card security code is incorrect.",
39
+ "error.invalid_number": "The card number is incorrect.",
40
+ "error.unsupported_brand": "This card type is not accepted.",
41
+ "error.unsupported_currency": "This currency is not supported for this card.",
42
+ "error.threeds_failed": "Card authentication failed. Please try another card.",
43
+ "error.threeds_cancelled": "Card authentication was cancelled.",
44
+ "error.threeds_not_supported": "This card does not support 3D Secure authentication.",
45
+ "error.threeds_no_liability_shift": "Card authentication could not be completed.",
46
+ "error.amount_above_limit": "The amount exceeds the limit for this card.",
47
+ "error.amount_below_limit": "The amount is below the minimum allowed.",
48
+ "error.frequency_limit": "Too many attempts, please try again later.",
49
+ "error.risk_declined": "The payment was blocked. Please contact your bank or try another card.",
50
+ "error.issuer_unavailable": "Your card issuer is unavailable. Please try again later.",
51
+ "error.acquirer_unavailable": "Payment processing is temporarily unavailable. Please try again later.",
52
+ "error.refund_exceeds_paid": "The refund amount exceeds the amount paid.",
53
+ "error.duplicate_confirm": "This payment is already being processed.",
54
+ "error.intent_expired": "The payment session has expired. Please start again.",
55
+ "error.intent_already_final": "This payment has already been processed.",
36
56
  "field.incomplete_number": "Enter your full card number",
37
57
  "field.invalid_number": "Check your card number",
38
58
  "field.incomplete_expiry": "Enter the full expiry date",
@@ -43,33 +63,54 @@ exports.LOCALE_BUNDLES = {
43
63
  },
44
64
  "ms-MY": {
45
65
  "_meta": {
46
- "name": "Malay",
66
+ "name": "Bahasa Melayu",
47
67
  "canonical": "ms-MY",
48
68
  "fallback": "en-US",
49
- "complete": false
69
+ "complete": true
50
70
  },
51
- "threeds.title": "",
52
- "threeds.cancel": "",
53
- "threeds.close": "",
54
- "threeds.processing": "",
55
- "threeds.redirecting": "",
56
- "payment.processing": "",
57
- "result.cancelled": "",
58
- "error.generic": "",
59
- "error.rate_limited": "",
60
- "error.processing_timeout": "",
61
- "error.sdk_load_failed": "",
62
- "error.invalid_publishable_key": "",
63
- "error.invalid_client_token": "",
64
- "error.origin_not_allowed": "",
65
- "error.font_load_failed": "",
66
- "field.incomplete_number": "",
67
- "field.invalid_number": "",
68
- "field.incomplete_expiry": "",
69
- "field.invalid_expiry": "",
70
- "field.incomplete_cvc": "",
71
- "field.invalid_cvc": "",
72
- "field.unsupported_brand": ""
71
+ "threeds.title": "Pengesahan Selamat",
72
+ "threeds.cancel": "Batal",
73
+ "threeds.close": "Tutup",
74
+ "threeds.processing": "Memproses, sila tunggu...",
75
+ "threeds.redirecting": "Mengalihkan...",
76
+ "payment.processing": "Pembayaran sedang diproses...",
77
+ "result.cancelled": "Pembayaran dibatalkan",
78
+ "error.generic": "Pembayaran gagal, sila cuba lagi atau gunakan kad lain.",
79
+ "error.rate_limited": "Terlalu banyak percubaan, sila tunggu sebentar dan cuba lagi.",
80
+ "error.processing_timeout": "Pembayaran anda masih diproses. Kami akan mengesahkan keputusan tidak lama lagi.",
81
+ "error.sdk_load_failed": "Komponen pembayaran gagal dimuatkan, sila muat semula halaman.",
82
+ "error.invalid_publishable_key": "Konfigurasi peniaga tidak sah.",
83
+ "error.invalid_client_token": "Sesi pembayaran telah tamat. Sila cuba lagi.",
84
+ "error.origin_not_allowed": "Laman web ini tidak dibenarkan menggunakan komponen pembayaran.",
85
+ "error.font_load_failed": "Fon gagal dimuatkan, fon sistem digunakan sebagai gantian.",
86
+ "error.card_declined": "Kad anda ditolak. Sila gunakan kad lain.",
87
+ "error.insufficient_funds": "Baki kad tidak mencukupi.",
88
+ "error.expired_card": "Kad telah luput.",
89
+ "error.invalid_cvc": "Kod keselamatan tidak betul.",
90
+ "error.invalid_number": "Nombor kad tidak betul.",
91
+ "error.unsupported_brand": "Jenis kad ini tidak diterima.",
92
+ "error.unsupported_currency": "Mata wang ini tidak disokong untuk kad ini.",
93
+ "error.threeds_failed": "Pengesahan kad gagal. Sila gunakan kad lain.",
94
+ "error.threeds_cancelled": "Pengesahan telah dibatalkan.",
95
+ "error.threeds_not_supported": "Kad ini tidak menyokong pengesahan 3DS.",
96
+ "error.threeds_no_liability_shift": "Pengesahan kad tidak dapat diselesaikan.",
97
+ "error.amount_above_limit": "Amaun melebihi had untuk kad ini.",
98
+ "error.amount_below_limit": "Amaun kurang daripada jumlah minimum.",
99
+ "error.frequency_limit": "Terlalu banyak percubaan, sila cuba lagi kemudian.",
100
+ "error.risk_declined": "Pembayaran disekat. Sila hubungi bank anda atau gunakan kad lain.",
101
+ "error.issuer_unavailable": "Bank penerbit kad tidak tersedia. Sila cuba lagi kemudian.",
102
+ "error.acquirer_unavailable": "Perkhidmatan pembayaran tidak tersedia buat sementara waktu. Sila cuba lagi kemudian.",
103
+ "error.refund_exceeds_paid": "Amaun bayaran balik melebihi jumlah yang dibayar.",
104
+ "error.duplicate_confirm": "Pembayaran ini sedang diproses.",
105
+ "error.intent_expired": "Sesi pembayaran telah tamat. Sila mula semula.",
106
+ "error.intent_already_final": "Pembayaran ini telah selesai.",
107
+ "field.incomplete_number": "Masukkan nombor kad penuh anda",
108
+ "field.invalid_number": "Semak nombor kad anda",
109
+ "field.incomplete_expiry": "Masukkan tarikh luput penuh",
110
+ "field.invalid_expiry": "Semak tarikh luput",
111
+ "field.incomplete_cvc": "Masukkan kod keselamatan",
112
+ "field.invalid_cvc": "Semak kod keselamatan",
113
+ "field.unsupported_brand": "Jenis kad ini tidak diterima"
73
114
  },
74
115
  "zh-CN": {
75
116
  "_meta": {
@@ -93,6 +134,27 @@ exports.LOCALE_BUNDLES = {
93
134
  "error.invalid_client_token": "付款会话已过期,请重试。",
94
135
  "error.origin_not_allowed": "此网站未获授权使用付款组件。",
95
136
  "error.font_load_failed": "字体加载失败,已改用系统字体。",
137
+ "error.card_declined": "银行卡被拒绝,请更换银行卡重试。",
138
+ "error.insufficient_funds": "银行卡余额不足。",
139
+ "error.expired_card": "银行卡已过期。",
140
+ "error.invalid_cvc": "安全码不正确。",
141
+ "error.invalid_number": "卡号不正确。",
142
+ "error.unsupported_brand": "不支持此银行卡类型。",
143
+ "error.unsupported_currency": "该银行卡不支持此币种。",
144
+ "error.threeds_failed": "安全验证失败,请更换银行卡重试。",
145
+ "error.threeds_cancelled": "你已取消安全验证。",
146
+ "error.threeds_not_supported": "该银行卡不支持 3DS 验证。",
147
+ "error.threeds_no_liability_shift": "安全验证未能完成。",
148
+ "error.amount_above_limit": "金额超过该银行卡的限额。",
149
+ "error.amount_below_limit": "金额低于最低要求。",
150
+ "error.frequency_limit": "操作过于频繁,请稍后再试。",
151
+ "error.risk_declined": "交易被拦截,请联系发卡银行或更换银行卡。",
152
+ "error.issuer_unavailable": "发卡银行暂时无法连接,请稍后再试。",
153
+ "error.acquirer_unavailable": "收单服务暂时不可用,请稍后再试。",
154
+ "error.refund_exceeds_paid": "退款金额超过可退款金额。",
155
+ "error.duplicate_confirm": "该笔付款正在处理中。",
156
+ "error.intent_expired": "付款已过期,请重新发起付款。",
157
+ "error.intent_already_final": "该笔付款已完成。",
96
158
  "field.incomplete_number": "请输入完整卡号",
97
159
  "field.invalid_number": "请检查卡号",
98
160
  "field.incomplete_expiry": "请输入完整有效期",
@@ -123,6 +185,27 @@ exports.LOCALE_BUNDLES = {
123
185
  "error.invalid_client_token": "付款工作階段已過期,請重試。",
124
186
  "error.origin_not_allowed": "此網站未獲授權使用付款元件。",
125
187
  "error.font_load_failed": "字體載入失敗,已改用系統字體。",
188
+ "error.card_declined": "你的卡片被拒絕,請改用其他卡片。",
189
+ "error.insufficient_funds": "卡片餘額不足。",
190
+ "error.expired_card": "卡片已過期。",
191
+ "error.invalid_cvc": "安全碼不正確。",
192
+ "error.invalid_number": "卡號不正確。",
193
+ "error.unsupported_brand": "不接受此卡片類型。",
194
+ "error.unsupported_currency": "此卡片不支援該貨幣。",
195
+ "error.threeds_failed": "安全驗證失敗,請改用其他卡片。",
196
+ "error.threeds_cancelled": "你已取消安全驗證。",
197
+ "error.threeds_not_supported": "此卡片不支援 3DS 驗證。",
198
+ "error.threeds_no_liability_shift": "安全驗證未能完成。",
199
+ "error.amount_above_limit": "金額超過此卡片的限額。",
200
+ "error.amount_below_limit": "金額低於最低要求。",
201
+ "error.frequency_limit": "嘗試次數過多,請稍後再試。",
202
+ "error.risk_declined": "付款被攔截,請聯絡發卡銀行或改用其他卡片。",
203
+ "error.issuer_unavailable": "發卡銀行暫時無法連線,請稍後再試。",
204
+ "error.acquirer_unavailable": "收款服務暫時無法使用,請稍後再試。",
205
+ "error.refund_exceeds_paid": "退款金額超過可退款金額。",
206
+ "error.duplicate_confirm": "此付款正在處理中。",
207
+ "error.intent_expired": "付款已逾時,請重新發起付款。",
208
+ "error.intent_already_final": "此付款已完成。",
126
209
  "field.incomplete_number": "請輸入完整卡號",
127
210
  "field.invalid_number": "請檢查卡號",
128
211
  "field.incomplete_expiry": "請輸入完整有效期",
package/lib/locales.js CHANGED
@@ -1,19 +1,23 @@
1
1
  "use strict";
2
2
  /**
3
- * Locale resolution (A10).
3
+ * Locale resolution.
4
4
  *
5
- * - COM-34: tags accepted in underscore or hyphen form, case-insensitively
5
+ * - tags accepted in underscore or hyphen form, case-insensitively
6
6
  * (`zh_HK`, `zh-HK`, `zh-hk`).
7
- * - COM-35: locale can be changed at runtime via setLocale() without reload.
8
- * - COM-36: unsupported / unknown locale never errors — fallback chain
9
- * exact tag -> same language -> en-US.
10
- * - zh_HK maps to zh-TW strings (documented in A10 as acceptable).
11
- * - ms-MY (my_MY) ships incomplete and falls back to en-US per its _meta.
7
+ * - locale can be changed at runtime via setLocale() without reload.
8
+ * - unsupported / unknown locale never errors — fallback chain
9
+ * exact tag -> alias -> same primary language -> en-US
10
+ * (zh picks zh-TW for Traditional/HK variants and zh-CN for
11
+ * Simplified/SG variants; en picks en-US; ms picks ms-MY).
12
+ * - zh_HK maps to zh-TW strings.
13
+ * - flow-supplied init() messages overlay the resolved bundle at lookup
14
+ * time (setCustomMessages).
12
15
  */
13
16
  Object.defineProperty(exports, "__esModule", { value: true });
14
17
  exports.SUPPORTED_LOCALES = exports.DEFAULT_LOCALE = void 0;
15
18
  exports.normalizeLocale = normalizeLocale;
16
19
  exports.resolveBundle = resolveBundle;
20
+ exports.setCustomMessages = setCustomMessages;
17
21
  exports.setLocale = setLocale;
18
22
  exports.getLocale = getLocale;
19
23
  exports.getLocaleStrings = getLocaleStrings;
@@ -28,14 +32,17 @@ const ALIASES = {
28
32
  'en-hk': 'en-US',
29
33
  'zh': 'zh-TW',
30
34
  'zh-tw': 'zh-TW',
31
- 'zh-hk': 'zh-TW', // A10: zh_HK maps to the zh-TW strings
35
+ 'zh-hk': 'zh-TW', // zh_HK maps to the zh-TW strings
32
36
  'zh-cn': 'zh-CN',
33
37
  'zh-hans': 'zh-CN',
34
38
  'ms': 'ms-MY',
35
39
  'ms-my': 'ms-MY',
36
- 'my-my': 'ms-MY', // Flow's tag for Malay (A10)
40
+ 'my-my': 'ms-MY', // Malay tag
37
41
  };
38
- /** Normalize any accepted tag form; returns null when unknown (never throws). */
42
+ /** Normalize any accepted tag form; returns null when unknown (never throws).
43
+ * Unlisted regional variants of a shipped language resolve to that
44
+ * language's bundle (en-AU -> en-US, zh-SG -> zh-CN, zh-Hant-HK -> zh-TW,
45
+ * fr-CA -> null -> en-US via resolveBundle). */
39
46
  function normalizeLocale(tag) {
40
47
  if (!tag || typeof tag !== 'string') {
41
48
  return null;
@@ -45,9 +52,26 @@ function normalizeLocale(tag) {
45
52
  if (direct) {
46
53
  return direct;
47
54
  }
48
- return ALIASES[norm] || null;
55
+ const alias = ALIASES[norm];
56
+ if (alias) {
57
+ return alias;
58
+ }
59
+ // Same-language fallback for unlisted regional variants.
60
+ const primary = norm.split('-')[0];
61
+ if (primary === 'zh') {
62
+ // Simplified variants -> zh-CN; Traditional / HK / MO / TW -> zh-TW.
63
+ const simplified = norm.includes('hans') || norm.endsWith('-sg') || norm.endsWith('-my') || norm.endsWith('-cn');
64
+ return simplified ? 'zh-CN' : 'zh-TW';
65
+ }
66
+ if (primary === 'en') {
67
+ return 'en-US';
68
+ }
69
+ if (primary === 'ms') {
70
+ return 'ms-MY';
71
+ }
72
+ return null;
49
73
  }
50
- /** The bundle for a tag with the COM-36 fallback chain applied: exact tag ->
74
+ /** The bundle for a tag with the fallback chain applied: exact tag ->
51
75
  * same language -> en-US. Unknown tags fall back to en-US silently.
52
76
  * Incomplete bundles (ms-MY today) keep their non-empty strings and take the
53
77
  * rest from the fallback, so no empty string ever reaches the UI. */
@@ -73,8 +97,27 @@ function resolveBundle(tag) {
73
97
  }
74
98
  return { locale: exact, bundle: merged };
75
99
  }
76
- /** Runtime locale for user messages. Changed via setLocale() (COM-35). */
100
+ /** Runtime locale for user messages. Changed via setLocale(). */
77
101
  let currentLocale = exports.DEFAULT_LOCALE;
102
+ /** Flow-supplied message overrides, merged over the resolved bundle at
103
+ * lookup time (set at init). */
104
+ let customMessages = null;
105
+ /** Install (or clear) flow-supplied message overrides, keyed like the
106
+ * locale bundles ("error.card_declined", "threeds.title", ...). */
107
+ function setCustomMessages(messages) {
108
+ if (messages && typeof messages === 'object') {
109
+ const copy = {};
110
+ for (const key of Object.keys(messages)) {
111
+ if (typeof messages[key] === 'string') {
112
+ copy[key] = messages[key];
113
+ }
114
+ }
115
+ customMessages = copy;
116
+ }
117
+ else {
118
+ customMessages = null;
119
+ }
120
+ }
78
121
  function setLocale(tag) {
79
122
  currentLocale = normalizeLocale(tag) ? String(tag) : tag || exports.DEFAULT_LOCALE;
80
123
  }
@@ -82,13 +125,18 @@ function getLocale() {
82
125
  return currentLocale;
83
126
  }
84
127
  /** Localized strings for a tag (or the current runtime locale when omitted).
85
- * Falls back along the COM-36 chain; never throws for unknown tags. */
128
+ * Falls back along the fallback chain; never throws for unknown tags.
129
+ * Custom messages (init) win over the resolved bundle. */
86
130
  function getLocaleStrings(tag) {
87
131
  const effective = tag == null ? currentLocale : tag;
88
132
  const { locale, bundle } = resolveBundle(effective);
89
133
  return {
90
134
  locale,
91
135
  t(key) {
136
+ const custom = customMessages && customMessages[key];
137
+ if (typeof custom === 'string' && custom.length > 0) {
138
+ return custom;
139
+ }
92
140
  const value = bundle[key];
93
141
  if (typeof value === 'string' && value.length > 0) {
94
142
  return value;
package/lib/poll.d.ts CHANGED
@@ -1,14 +1,14 @@
1
1
  /**
2
- * AppState-aware polling (RN-20 / COM-06, the app analog of WEB-50/51).
2
+ * AppState-aware polling.
3
3
  *
4
- * Schedule: 2s x 15, then 5s x 12 (CONF-08 budget). While the app is
4
+ * Schedule: 2s x 15, then 5s x 12. While the app is
5
5
  * backgrounded (user switched to a banking app during 3DS, screen off, etc.)
6
6
  * the poll timer is suspended and suspended time does NOT consume the
7
7
  * budget — the budget is a number of polls, not wall-clock time. On return
8
8
  * to the foreground polling resumes where it stopped.
9
9
  *
10
10
  * On budget exhaustion the poller resolves undefined and the caller maps
11
- * that to `processing` — never `failed` (COM-06).
11
+ * that to `processing` — never `failed`.
12
12
  */
13
13
  export interface PollerOptions {
14
14
  fastIntervalMs?: number;
package/lib/poll.js CHANGED
@@ -1,15 +1,15 @@
1
1
  "use strict";
2
2
  /**
3
- * AppState-aware polling (RN-20 / COM-06, the app analog of WEB-50/51).
3
+ * AppState-aware polling.
4
4
  *
5
- * Schedule: 2s x 15, then 5s x 12 (CONF-08 budget). While the app is
5
+ * Schedule: 2s x 15, then 5s x 12. While the app is
6
6
  * backgrounded (user switched to a banking app during 3DS, screen off, etc.)
7
7
  * the poll timer is suspended and suspended time does NOT consume the
8
8
  * budget — the budget is a number of polls, not wall-clock time. On return
9
9
  * to the foreground polling resumes where it stopped.
10
10
  *
11
11
  * On budget exhaustion the poller resolves undefined and the caller maps
12
- * that to `processing` — never `failed` (COM-06).
12
+ * that to `processing` — never `failed`.
13
13
  */
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.AppStateAwarePoller = exports.DEFAULT_POLLER_OPTIONS = void 0;
@@ -137,7 +137,7 @@ class AppStateAwarePoller {
137
137
  }
138
138
  catch {
139
139
  // A failed poll (e.g. a network blip) is not terminal — keep going
140
- // within the budget; exhaustion maps to `processing` (COM-06).
140
+ // within the budget; exhaustion maps to `processing`.
141
141
  outcome = { done: false };
142
142
  }
143
143
  this.inFlight = false;
package/lib/threeDs.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * 3DS challenge presentation bridge (RN-18 / RN-19).
2
+ * 3DS challenge presentation bridge.
3
3
  *
4
4
  * Primary path: the SDK's own native modules
5
5
  * - iOS: PaSdk3ds (Swift WKWebView view controller, see native/ios)
@@ -15,7 +15,7 @@
15
15
  * (PaSdk3dsHost, backed by react-native-webview) can register itself here
16
16
  * via setThreeDsPresenter().
17
17
  */
18
- /** Strings the native chrome needs, already resolved for the runtime locale (WEB-45 analog / RN-29). */
18
+ /** Strings the native chrome needs, already resolved for the runtime locale. */
19
19
  export interface ThreeDsStrings {
20
20
  title: string;
21
21
  cancel: string;
@@ -31,15 +31,15 @@ export interface ThreeDsParams {
31
31
  [name: string]: string;
32
32
  };
33
33
  strings: ThreeDsStrings;
34
- /** 3DS return URLs (RN-20) — consumed by the SDK, not the app's handler. */
34
+ /** 3DS return URLs — consumed by the SDK, not the app's handler. */
35
35
  returnUrlScheme?: string;
36
36
  returnUrlUniversalHost?: string;
37
37
  }
38
38
  export interface ThreeDsDismissal {
39
39
  /** true when the user closed the challenge themselves -> result `cancelled`. */
40
40
  cancelled: boolean;
41
- /** Android only: the challenge returned via flow:// / universal link and
42
- * the SDK consumed the return (RN-20). */
41
+ /** Android only: the challenge returned via the configured return scheme /
42
+ * universal link and the SDK consumed the return. */
43
43
  returnUrlConsumed?: boolean;
44
44
  }
45
45
  export type ThreeDsPresenter = (params: ThreeDsParams) => Promise<ThreeDsDismissal>;
@@ -49,7 +49,7 @@ export declare function setThreeDsPresenter(presenter: ThreeDsPresenter | null):
49
49
  export declare function canPresentThreeDs(): boolean;
50
50
  /**
51
51
  * Present the challenge. Fires `onWillPresent` immediately before the
52
- * challenge appears (RN-19 — Flow dismisses its loading overlay then).
52
+ * challenge appears (the app dismisses its loading overlay then).
53
53
  * Resolves when the challenge is dismissed by the user (cancelled: true)
54
54
  * or by closeThreeDs() after the server-side outcome was observed.
55
55
  */
@@ -57,3 +57,14 @@ export declare function presentThreeDs(params: ThreeDsParams, onWillPresent?: ()
57
57
  /** Close a presented challenge (called once polling observed a terminal
58
58
  * state; the native side dismisses the WebView and resolves present()). */
59
59
  export declare function closeThreeDs(): void;
60
+ /**
61
+ * App-switch return hook (iOS). An app-switch return from the issuer's app
62
+ * (or bank portal) lands in the app's own link handler, not inside the
63
+ * challenge WebView — call this FIRST from AppDelegate/SceneDelegate
64
+ * (openURL / continueUserActivity) and ignore the URL when it resolves
65
+ * true: the URL matched the pending 3DS challenge's return URLs and the
66
+ * challenge has been consumed. Resolves false when no challenge is pending
67
+ * or the URL does not match — handle the URL as usual then. Android needs
68
+ * no hook: the SDK consumes its returns at the OS level.
69
+ */
70
+ export declare function handleReturnUrl(url: string): Promise<boolean>;
package/lib/threeDs.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /**
3
- * 3DS challenge presentation bridge (RN-18 / RN-19).
3
+ * 3DS challenge presentation bridge.
4
4
  *
5
5
  * Primary path: the SDK's own native modules
6
6
  * - iOS: PaSdk3ds (Swift WKWebView view controller, see native/ios)
@@ -21,6 +21,7 @@ exports.setThreeDsPresenter = setThreeDsPresenter;
21
21
  exports.canPresentThreeDs = canPresentThreeDs;
22
22
  exports.presentThreeDs = presentThreeDs;
23
23
  exports.closeThreeDs = closeThreeDs;
24
+ exports.handleReturnUrl = handleReturnUrl;
24
25
  const react_native_1 = require("react-native");
25
26
  const errors_1 = require("./errors");
26
27
  const nativeModule = react_native_1.NativeModules.PaSdk3ds;
@@ -35,7 +36,7 @@ function canPresentThreeDs() {
35
36
  }
36
37
  /**
37
38
  * Present the challenge. Fires `onWillPresent` immediately before the
38
- * challenge appears (RN-19 — Flow dismisses its loading overlay then).
39
+ * challenge appears (the app dismisses its loading overlay then).
39
40
  * Resolves when the challenge is dismissed by the user (cancelled: true)
40
41
  * or by closeThreeDs() after the server-side outcome was observed.
41
42
  */
@@ -62,3 +63,24 @@ function closeThreeDs() {
62
63
  });
63
64
  }
64
65
  }
66
+ /**
67
+ * App-switch return hook (iOS). An app-switch return from the issuer's app
68
+ * (or bank portal) lands in the app's own link handler, not inside the
69
+ * challenge WebView — call this FIRST from AppDelegate/SceneDelegate
70
+ * (openURL / continueUserActivity) and ignore the URL when it resolves
71
+ * true: the URL matched the pending 3DS challenge's return URLs and the
72
+ * challenge has been consumed. Resolves false when no challenge is pending
73
+ * or the URL does not match — handle the URL as usual then. Android needs
74
+ * no hook: the SDK consumes its returns at the OS level.
75
+ */
76
+ async function handleReturnUrl(url) {
77
+ if (nativeModule && typeof nativeModule.handleReturnUrl === 'function') {
78
+ try {
79
+ return (await nativeModule.handleReturnUrl(url)) === true;
80
+ }
81
+ catch {
82
+ return false;
83
+ }
84
+ }
85
+ return false;
86
+ }
@@ -1,6 +1,6 @@
1
1
  /**
2
- * PaSdk3dsHost — pure-JS fallback for the SDK-presented 3DS challenge
3
- * (RN-19). Used only when the native module (native/ios, native/android) is
2
+ * PaSdk3dsHost — pure-JS fallback for the SDK-presented 3DS challenge.
3
+ * Used only when the native module (native/ios, native/android) is
4
4
  * not installed. Renders a full-screen Modal with a react-native-webview
5
5
  * that POSTs the challenge payload to the challenge URL, mirroring the
6
6
  * native presentation: cancel button, localized chrome, no swipe-to-dismiss.
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  /**
3
- * PaSdk3dsHost — pure-JS fallback for the SDK-presented 3DS challenge
4
- * (RN-19). Used only when the native module (native/ios, native/android) is
3
+ * PaSdk3dsHost — pure-JS fallback for the SDK-presented 3DS challenge.
4
+ * Used only when the native module (native/ios, native/android) is
5
5
  * not installed. Renders a full-screen Modal with a react-native-webview
6
6
  * that POSTs the challenge payload to the challenge URL, mirroring the
7
7
  * native presentation: cancel button, localized chrome, no swipe-to-dismiss.
@@ -118,7 +118,7 @@ function PaSdk3dsHost() {
118
118
  react_1.default.createElement(react_native_1.Text, { style: styles.cancelText }, strings.cancel))),
119
119
  react_1.default.createElement(react_native_1.View, { style: styles.webContainer },
120
120
  react_1.default.createElement(react_native_webview_1.WebView, { source: { html: buildPostHtml(challenge.params) }, originWhitelist: ['*'], javaScriptEnabled: true, domStorageEnabled: true, onLoadStart: () => setLoading(true), onLoadEnd: () => setLoading(false), onNavigationStateChange: (state) => {
121
- // RN-20: a navigation to the configured 3DS return URLs is the
121
+ // a navigation to the configured 3DS return URLs is the
122
122
  // challenge ending — consume it here so the app's link handler
123
123
  // never sees it, and let polling observe the server-side result.
124
124
  const scheme = challenge.params.returnUrlScheme;
package/lib/tokenize.d.ts CHANGED
@@ -1,15 +1,15 @@
1
1
  /**
2
- * Direct tokenization (COM-02 / RN-13).
2
+ * Direct tokenization.
3
3
  *
4
- * Card data goes from Flow's UI through the SDK straight to PA and never
5
- * touches Flow's servers. Two calls:
4
+ * Card data goes from the app's UI through the SDK straight to PA and never
5
+ * touches your servers. Two calls:
6
6
  * 1. createElementSession — POST /{merchantToken}/element-sessions
7
7
  * 2. tokenizeCard — POST /tokenize
8
8
  */
9
9
  import type { ApiClient } from './api';
10
10
  import type { CardInput, TokenizeOutput } from './types';
11
11
  /** Create a short-lived public session. `merchantToken` is the publishable
12
- * credential of the (market-specific) merchant account — COM-01 / COM-41. */
12
+ * credential of the (market-specific) merchant account. */
13
13
  export declare function createElementSession(api: ApiClient, merchantToken: string): Promise<string>;
14
14
  /** Tokenize a card. Creates the element session automatically when the
15
15
  * caller does not already hold one. */
@@ -19,4 +19,9 @@ export declare function tokenizeCard(api: ApiClient, params: {
19
19
  sessionToken?: string;
20
20
  /** Publishable merchantToken of the market account to tokenize under. */
21
21
  merchantToken: string;
22
+ /** The app's own reference, stored with the token (merchant_reference). */
23
+ merchantReference?: string;
24
+ /** Arbitrary key-value data stored with the token, sent as
25
+ * token_metadata (JSON string). */
26
+ metadata?: Record<string, unknown>;
22
27
  }): Promise<TokenizeOutput>;
package/lib/tokenize.js CHANGED
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  /**
3
- * Direct tokenization (COM-02 / RN-13).
3
+ * Direct tokenization.
4
4
  *
5
- * Card data goes from Flow's UI through the SDK straight to PA and never
6
- * touches Flow's servers. Two calls:
5
+ * Card data goes from the app's UI through the SDK straight to PA and never
6
+ * touches your servers. Two calls:
7
7
  * 1. createElementSession — POST /{merchantToken}/element-sessions
8
8
  * 2. tokenizeCard — POST /tokenize
9
9
  */
@@ -13,7 +13,7 @@ exports.tokenizeCard = tokenizeCard;
13
13
  const errors_1 = require("./errors");
14
14
  const validator_1 = require("./validator");
15
15
  /** Create a short-lived public session. `merchantToken` is the publishable
16
- * credential of the (market-specific) merchant account — COM-01 / COM-41. */
16
+ * credential of the (market-specific) merchant account. */
17
17
  async function createElementSession(api, merchantToken) {
18
18
  const payload = await api.createElementSession(merchantToken);
19
19
  if (!payload || !payload.session_token) {
@@ -34,6 +34,8 @@ async function tokenizeCard(api, params) {
34
34
  expiryYear: params.card.expiryYear,
35
35
  cvc: params.card.cvc,
36
36
  cardHolderName: params.card.cardHolderName,
37
+ merchantReference: params.merchantReference,
38
+ metadata: params.metadata,
37
39
  });
38
40
  if (!payload || !payload.pa_token) {
39
41
  throw new errors_1.PaError('provider_error', {