pa-sdk-react-native 3.0.0 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +85 -73
- package/lib/api.d.ts +7 -7
- package/lib/api.js +11 -11
- package/lib/confirm.d.ts +18 -19
- package/lib/confirm.js +20 -21
- package/lib/errors.d.ts +6 -6
- package/lib/errors.generated.d.ts +1 -1
- package/lib/errors.generated.js +1 -1
- package/lib/errors.js +5 -5
- package/lib/index.d.ts +3 -3
- package/lib/index.js +9 -9
- package/lib/init.d.ts +8 -8
- package/lib/init.js +8 -8
- package/lib/locales.d.ts +7 -7
- package/lib/locales.generated.d.ts +2 -2
- package/lib/locales.generated.js +26 -26
- package/lib/locales.js +10 -10
- package/lib/poll.d.ts +3 -3
- package/lib/poll.js +4 -4
- package/lib/threeDs.d.ts +6 -6
- package/lib/threeDs.js +2 -2
- package/lib/threeDsHost.d.ts +2 -2
- package/lib/threeDsHost.js +3 -3
- package/lib/tokenize.d.ts +4 -4
- package/lib/tokenize.js +4 -4
- package/lib/types.d.ts +25 -26
- package/lib/types.js +4 -5
- package/lib/validator.d.ts +8 -8
- package/lib/validator.js +9 -10
- package/locales/ms-MY.json +24 -24
- package/native/android/build.gradle +4 -4
- package/native/android/src/main/AndroidManifest.xml +12 -11
- package/native/android/src/main/java/com/pasdk/reactnative/PaSdk3dsActivity.kt +9 -16
- package/native/android/src/main/java/com/pasdk/reactnative/PaSdk3dsModule.kt +3 -3
- package/native/ios/PaSdk3ds.swift +6 -6
- package/native/ios/PaSdk3dsModule.m +2 -2
- package/package.json +3 -3
- package/scripts/generate-errors.js +2 -2
- package/scripts/generate-locales.js +3 -3
package/lib/tokenize.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* Direct tokenization
|
|
3
|
+
* Direct tokenization.
|
|
4
4
|
*
|
|
5
|
-
* Card data goes from
|
|
6
|
-
* touches
|
|
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
|
|
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) {
|
package/lib/types.d.ts
CHANGED
|
@@ -2,19 +2,19 @@
|
|
|
2
2
|
* PA SDK React Native — shared types.
|
|
3
3
|
*
|
|
4
4
|
* The result states are exactly the five states of the shared payment
|
|
5
|
-
* contract
|
|
6
|
-
* resolved value
|
|
5
|
+
* contract. `requires_action` must never be a
|
|
6
|
+
* resolved value — any 3DS is handled inside confirm.
|
|
7
7
|
*/
|
|
8
|
-
/** Environments
|
|
8
|
+
/** Environments — selected once at init. */
|
|
9
9
|
export type Environment = 'production' | 'sandbox';
|
|
10
|
-
/** SDK result states
|
|
10
|
+
/** SDK result states. */
|
|
11
11
|
export type ResultStatus = 'succeeded' | 'authorized' | 'processing' | 'cancelled' | 'failed';
|
|
12
|
-
/** Field codes reported by validation
|
|
12
|
+
/** Field codes reported by validation. */
|
|
13
13
|
export type FieldErrorCode = 'incomplete_number' | 'invalid_number' | 'incomplete_expiry' | 'invalid_expiry' | 'incomplete_cvc' | 'invalid_cvc' | 'unsupported_brand';
|
|
14
|
-
/** Published brand vocabulary
|
|
14
|
+
/** Published brand vocabulary. Scope is Visa + Mastercard; the
|
|
15
15
|
* other values exist so a non-scope scheme can be detected early and blocked. */
|
|
16
16
|
export type CardBrand = 'visa' | 'mastercard' | 'amex' | 'diners' | 'discover' | 'jcb' | 'unionpay' | 'maestro' | 'unknown';
|
|
17
|
-
/** Card input collected by
|
|
17
|
+
/** Card input collected by the app's own UI. */
|
|
18
18
|
export interface CardInput {
|
|
19
19
|
/** Full card number, spaces and dashes tolerated. */
|
|
20
20
|
cardNumber: string;
|
|
@@ -24,10 +24,10 @@ export interface CardInput {
|
|
|
24
24
|
expiryYear: number | string;
|
|
25
25
|
/** Security code. */
|
|
26
26
|
cvc: string;
|
|
27
|
-
/** Optional; never required
|
|
27
|
+
/** Optional; never required. */
|
|
28
28
|
cardHolderName?: string;
|
|
29
29
|
}
|
|
30
|
-
/** Optional pass-through billing details
|
|
30
|
+
/** Optional pass-through billing details.
|
|
31
31
|
* Postal address is optional and never required. */
|
|
32
32
|
export interface BillingDetails {
|
|
33
33
|
cardholderName?: string;
|
|
@@ -38,7 +38,7 @@ export interface BillingDetails {
|
|
|
38
38
|
phone?: string;
|
|
39
39
|
/** Optional separate dial code, e.g. "+852" (used when `phone` is national). */
|
|
40
40
|
phoneDialCode?: string;
|
|
41
|
-
/** Optional postal address — absent must never fail
|
|
41
|
+
/** Optional postal address — absent must never fail. */
|
|
42
42
|
address?: {
|
|
43
43
|
line1?: string;
|
|
44
44
|
line2?: string;
|
|
@@ -48,7 +48,7 @@ export interface BillingDetails {
|
|
|
48
48
|
countryCode?: string;
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
|
-
/** Init options
|
|
51
|
+
/** Init options: one initialisation serves multiple
|
|
52
52
|
* merchant accounts, keyed by market. Currency and country are per intent. */
|
|
53
53
|
export interface InitOptions {
|
|
54
54
|
environment: Environment;
|
|
@@ -58,39 +58,39 @@ export interface InitOptions {
|
|
|
58
58
|
};
|
|
59
59
|
/** Which market key to use when a call does not name one. */
|
|
60
60
|
defaultAccount: string;
|
|
61
|
-
/**
|
|
61
|
+
/** Locale tag; underscore/hyphen and case-insensitive. */
|
|
62
62
|
locale?: string;
|
|
63
63
|
/** App origin sent with API calls where the gateway recommends one,
|
|
64
|
-
* e.g. "https://
|
|
64
|
+
* e.g. "https://links.yourapp.com". */
|
|
65
65
|
origin?: string;
|
|
66
|
-
/** 3DS return URL configuration
|
|
66
|
+
/** 3DS return URL configuration. */
|
|
67
67
|
threeDsReturnUrls?: {
|
|
68
|
-
/** Custom scheme, e.g. "
|
|
68
|
+
/** Custom scheme, e.g. "yourapp://" — no trailing slash. */
|
|
69
69
|
scheme?: string;
|
|
70
|
-
/** Universal-link host, e.g. "https://
|
|
70
|
+
/** Universal-link host, e.g. "https://links.yourapp.com". */
|
|
71
71
|
universalLinkHost?: string;
|
|
72
72
|
};
|
|
73
73
|
}
|
|
74
|
-
/** The single result object confirm resolves with, exactly once
|
|
74
|
+
/** The single result object confirm resolves with, exactly once. */
|
|
75
75
|
export interface PaymentResult {
|
|
76
76
|
status: ResultStatus;
|
|
77
77
|
intentToken?: string;
|
|
78
78
|
/** PA's reference for this transaction attempt. */
|
|
79
79
|
requestReference?: string | null;
|
|
80
|
-
/**
|
|
80
|
+
/** The app's own order number, echoed by the gateway when present. */
|
|
81
81
|
merchantReference?: string | null;
|
|
82
|
-
/** Saved-card token — set when a card was saved on any path
|
|
82
|
+
/** Saved-card token — set when a card was saved on any path. */
|
|
83
83
|
paToken?: string | null;
|
|
84
84
|
brand?: string | null;
|
|
85
85
|
last4?: string | null;
|
|
86
|
-
/** Shared-table error code for `failed
|
|
86
|
+
/** Shared-table error code for `failed`; null otherwise. */
|
|
87
87
|
errorCode?: string | null;
|
|
88
|
-
/** English developer message for `failed` (optional
|
|
88
|
+
/** English developer message for `failed` (optional). */
|
|
89
89
|
errorMessage?: string | null;
|
|
90
|
-
/** Localized user message for `failed
|
|
90
|
+
/** Localized user message for `failed`. */
|
|
91
91
|
userMessage?: string | null;
|
|
92
92
|
}
|
|
93
|
-
/** Tokenization result
|
|
93
|
+
/** Tokenization result. */
|
|
94
94
|
export interface TokenizeResult {
|
|
95
95
|
paToken: string;
|
|
96
96
|
last4: string;
|
|
@@ -102,9 +102,8 @@ export interface TokenizeOutput {
|
|
|
102
102
|
sessionToken: string;
|
|
103
103
|
result: TokenizeResult;
|
|
104
104
|
}
|
|
105
|
-
/** Polling schedule
|
|
106
|
-
* suspended time while the app is backgrounded does not count
|
|
107
|
-
* WEB-50 analog). */
|
|
105
|
+
/** Polling schedule: 2s x 15 then 5s x 12 —
|
|
106
|
+
* suspended time while the app is backgrounded does not count. */
|
|
108
107
|
export declare const POLL_FAST_INTERVAL_MS = 2000;
|
|
109
108
|
export declare const POLL_FAST_ATTEMPTS = 15;
|
|
110
109
|
export declare const POLL_SLOW_INTERVAL_MS = 5000;
|
package/lib/types.js
CHANGED
|
@@ -3,14 +3,13 @@
|
|
|
3
3
|
* PA SDK React Native — shared types.
|
|
4
4
|
*
|
|
5
5
|
* The result states are exactly the five states of the shared payment
|
|
6
|
-
* contract
|
|
7
|
-
* resolved value
|
|
6
|
+
* contract. `requires_action` must never be a
|
|
7
|
+
* resolved value — any 3DS is handled inside confirm.
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.POLL_SLOW_ATTEMPTS = exports.POLL_SLOW_INTERVAL_MS = exports.POLL_FAST_ATTEMPTS = exports.POLL_FAST_INTERVAL_MS = void 0;
|
|
11
|
-
/** Polling schedule
|
|
12
|
-
* suspended time while the app is backgrounded does not count
|
|
13
|
-
* WEB-50 analog). */
|
|
11
|
+
/** Polling schedule: 2s x 15 then 5s x 12 —
|
|
12
|
+
* suspended time while the app is backgrounded does not count. */
|
|
14
13
|
exports.POLL_FAST_INTERVAL_MS = 2000;
|
|
15
14
|
exports.POLL_FAST_ATTEMPTS = 15;
|
|
16
15
|
exports.POLL_SLOW_INTERVAL_MS = 5000;
|
package/lib/validator.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Headless card validation
|
|
2
|
+
* Headless card validation.
|
|
3
3
|
*
|
|
4
4
|
* Follows Visa and Mastercard rules: current BIN ranges (including
|
|
5
5
|
* Mastercard's 2-series 2221-2720), valid lengths, Luhn, 3-digit CVC,
|
|
6
6
|
* expiry not in the past. Never blocks a valid Visa / Mastercard.
|
|
7
7
|
*
|
|
8
|
-
* Field codes are the shared per-field codes
|
|
8
|
+
* Field codes are the shared per-field codes:
|
|
9
9
|
* incomplete_number, invalid_number, incomplete_expiry, invalid_expiry,
|
|
10
10
|
* incomplete_cvc, invalid_cvc, unsupported_brand.
|
|
11
11
|
*/
|
|
@@ -20,21 +20,21 @@ export interface BrandInfo {
|
|
|
20
20
|
/** Strip spaces / dashes; keep digits only (a stray non-digit is preserved by
|
|
21
21
|
* the caller-level check but never crashes detection). */
|
|
22
22
|
export declare function sanitizeCardNumber(number: string): string;
|
|
23
|
-
/** Brand detection from the BIN while typing
|
|
23
|
+
/** Brand detection from the BIN while typing. Works from the first
|
|
24
24
|
* digit for Visa, the first two/four for the rest. */
|
|
25
25
|
export declare function detectBrand(cardNumber: string): BrandInfo;
|
|
26
|
-
/** Luhn checksum
|
|
26
|
+
/** Luhn checksum. */
|
|
27
27
|
export declare function luhnValid(cardNumber: string): boolean;
|
|
28
28
|
export interface NumberValidation {
|
|
29
29
|
brand: CardBrand;
|
|
30
|
-
/** null when valid; otherwise one of the
|
|
30
|
+
/** null when valid; otherwise one of the shared number codes. */
|
|
31
31
|
error: FieldErrorCode | null;
|
|
32
32
|
complete: boolean;
|
|
33
33
|
}
|
|
34
34
|
/**
|
|
35
35
|
* Validate a card number.
|
|
36
36
|
* @param allowedBrands when provided, a card whose brand is not in the list
|
|
37
|
-
* reports `unsupported_brand` (
|
|
37
|
+
* reports `unsupported_brand` (allowed-brands filter; your server
|
|
38
38
|
* supplies the list per merchant account).
|
|
39
39
|
*/
|
|
40
40
|
export declare function validateCardNumber(cardNumber: string, allowedBrands?: readonly string[] | null): NumberValidation;
|
|
@@ -53,7 +53,7 @@ export declare function cvcLengthsForBrand(brand?: CardBrand | string): number[]
|
|
|
53
53
|
/** Validate CVC for the (detected) brand — 3 digits for Visa / Mastercard. */
|
|
54
54
|
export declare function validateCvc(cvc: string, brand?: CardBrand | string): CvcValidation;
|
|
55
55
|
export interface CardValidation {
|
|
56
|
-
/** Detected brand from the BIN
|
|
56
|
+
/** Detected brand from the BIN — report while typing. */
|
|
57
57
|
brand: CardBrand;
|
|
58
58
|
/** True when every field passes and no brand filter rejects the card. */
|
|
59
59
|
complete: boolean;
|
|
@@ -65,7 +65,7 @@ export interface CardValidation {
|
|
|
65
65
|
};
|
|
66
66
|
}
|
|
67
67
|
/**
|
|
68
|
-
* Validate a whole card input from
|
|
68
|
+
* Validate a whole card input from the app's UI. Runs without any network call.
|
|
69
69
|
* `allowedBrands` behaves as in validateCardNumber().
|
|
70
70
|
*/
|
|
71
71
|
export declare function validateCard(card: Partial<CardInput>, allowedBrands?: readonly string[] | null): CardValidation;
|
package/lib/validator.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* Headless card validation
|
|
3
|
+
* Headless card validation.
|
|
4
4
|
*
|
|
5
5
|
* Follows Visa and Mastercard rules: current BIN ranges (including
|
|
6
6
|
* Mastercard's 2-series 2221-2720), valid lengths, Luhn, 3-digit CVC,
|
|
7
7
|
* expiry not in the past. Never blocks a valid Visa / Mastercard.
|
|
8
8
|
*
|
|
9
|
-
* Field codes are the shared per-field codes
|
|
9
|
+
* Field codes are the shared per-field codes:
|
|
10
10
|
* incomplete_number, invalid_number, incomplete_expiry, invalid_expiry,
|
|
11
11
|
* incomplete_cvc, invalid_cvc, unsupported_brand.
|
|
12
12
|
*/
|
|
@@ -21,13 +21,12 @@ exports.validateCvc = validateCvc;
|
|
|
21
21
|
exports.validateCard = validateCard;
|
|
22
22
|
/**
|
|
23
23
|
* BIN table. Order matters: the first match wins. Only Visa and Mastercard
|
|
24
|
-
* are in scope
|
|
25
|
-
* block a non-scope scheme early
|
|
24
|
+
* are in scope; the other entries exist so the app can detect and
|
|
25
|
+
* block a non-scope scheme early.
|
|
26
26
|
*/
|
|
27
27
|
const BRAND_RULES = [
|
|
28
28
|
{ brand: 'visa', prefixes: ['4'], lengths: [13, 16, 19], cvcLengths: [3] },
|
|
29
|
-
// Mastercard: 51-55 and the 2-series 2221-2720
|
|
30
|
-
// the 2-series out — it must be recognised).
|
|
29
|
+
// Mastercard: 51-55 and the 2-series 2221-2720 — it must be recognised.
|
|
31
30
|
{
|
|
32
31
|
brand: 'mastercard',
|
|
33
32
|
patterns: [/^5[1-5]/, /^(222[1-9]|22[3-9]\d|2[3-6]\d{2}|27[01]\d|2720)/],
|
|
@@ -47,7 +46,7 @@ const UNKNOWN_RULE = { brand: 'unknown', lengths: [16], cvcLengths: [3] };
|
|
|
47
46
|
function sanitizeCardNumber(number) {
|
|
48
47
|
return String(number || '').replace(/[\s-]/g, '');
|
|
49
48
|
}
|
|
50
|
-
/** Brand detection from the BIN while typing
|
|
49
|
+
/** Brand detection from the BIN while typing. Works from the first
|
|
51
50
|
* digit for Visa, the first two/four for the rest. */
|
|
52
51
|
function detectBrand(cardNumber) {
|
|
53
52
|
const n = sanitizeCardNumber(cardNumber);
|
|
@@ -63,7 +62,7 @@ function detectBrand(cardNumber) {
|
|
|
63
62
|
}
|
|
64
63
|
return { brand: 'unknown', lengths: UNKNOWN_RULE.lengths, cvcLengths: UNKNOWN_RULE.cvcLengths };
|
|
65
64
|
}
|
|
66
|
-
/** Luhn checksum
|
|
65
|
+
/** Luhn checksum. */
|
|
67
66
|
function luhnValid(cardNumber) {
|
|
68
67
|
const n = sanitizeCardNumber(cardNumber);
|
|
69
68
|
if (!/^\d+$/.test(n) || n.length < 2) {
|
|
@@ -87,7 +86,7 @@ function luhnValid(cardNumber) {
|
|
|
87
86
|
/**
|
|
88
87
|
* Validate a card number.
|
|
89
88
|
* @param allowedBrands when provided, a card whose brand is not in the list
|
|
90
|
-
* reports `unsupported_brand` (
|
|
89
|
+
* reports `unsupported_brand` (allowed-brands filter; your server
|
|
91
90
|
* supplies the list per merchant account).
|
|
92
91
|
*/
|
|
93
92
|
function validateCardNumber(cardNumber, allowedBrands) {
|
|
@@ -166,7 +165,7 @@ function validateCvc(cvc, brand) {
|
|
|
166
165
|
return { error: null, complete: true };
|
|
167
166
|
}
|
|
168
167
|
/**
|
|
169
|
-
* Validate a whole card input from
|
|
168
|
+
* Validate a whole card input from the app's UI. Runs without any network call.
|
|
170
169
|
* `allowedBrands` behaves as in validateCardNumber().
|
|
171
170
|
*/
|
|
172
171
|
function validateCard(card, allowedBrands) {
|
package/locales/ms-MY.json
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"_meta": {
|
|
3
|
-
"name": "
|
|
3
|
+
"name": "Bahasa Melayu",
|
|
4
4
|
"canonical": "ms-MY",
|
|
5
5
|
"fallback": "en-US",
|
|
6
|
-
"complete":
|
|
6
|
+
"complete": true
|
|
7
7
|
},
|
|
8
|
-
"threeds.title": "",
|
|
9
|
-
"threeds.cancel": "",
|
|
10
|
-
"threeds.close": "",
|
|
11
|
-
"threeds.processing": "",
|
|
12
|
-
"threeds.redirecting": "",
|
|
13
|
-
"payment.processing": "",
|
|
14
|
-
"result.cancelled": "",
|
|
15
|
-
"error.generic": "",
|
|
16
|
-
"error.rate_limited": "",
|
|
17
|
-
"error.processing_timeout": "",
|
|
18
|
-
"error.sdk_load_failed": "",
|
|
19
|
-
"error.invalid_publishable_key": "",
|
|
20
|
-
"error.invalid_client_token": "",
|
|
21
|
-
"error.origin_not_allowed": "",
|
|
22
|
-
"error.font_load_failed": "",
|
|
23
|
-
"field.incomplete_number": "",
|
|
24
|
-
"field.invalid_number": "",
|
|
25
|
-
"field.incomplete_expiry": "",
|
|
26
|
-
"field.invalid_expiry": "",
|
|
27
|
-
"field.incomplete_cvc": "",
|
|
28
|
-
"field.invalid_cvc": "",
|
|
29
|
-
"field.unsupported_brand": ""
|
|
8
|
+
"threeds.title": "Pengesahan Selamat",
|
|
9
|
+
"threeds.cancel": "Batal",
|
|
10
|
+
"threeds.close": "Tutup",
|
|
11
|
+
"threeds.processing": "Memproses, sila tunggu...",
|
|
12
|
+
"threeds.redirecting": "Mengalihkan...",
|
|
13
|
+
"payment.processing": "Pembayaran sedang diproses...",
|
|
14
|
+
"result.cancelled": "Pembayaran dibatalkan",
|
|
15
|
+
"error.generic": "Pembayaran gagal, sila cuba lagi atau gunakan kad lain.",
|
|
16
|
+
"error.rate_limited": "Terlalu banyak percubaan, sila tunggu sebentar dan cuba lagi.",
|
|
17
|
+
"error.processing_timeout": "Pembayaran anda masih diproses. Kami akan mengesahkan keputusan tidak lama lagi.",
|
|
18
|
+
"error.sdk_load_failed": "Komponen pembayaran gagal dimuatkan, sila muat semula halaman.",
|
|
19
|
+
"error.invalid_publishable_key": "Konfigurasi peniaga tidak sah.",
|
|
20
|
+
"error.invalid_client_token": "Sesi pembayaran telah tamat. Sila cuba lagi.",
|
|
21
|
+
"error.origin_not_allowed": "Laman web ini tidak dibenarkan menggunakan komponen pembayaran.",
|
|
22
|
+
"error.font_load_failed": "Fon gagal dimuatkan, fon sistem digunakan sebagai gantian.",
|
|
23
|
+
"field.incomplete_number": "Masukkan nombor kad penuh anda",
|
|
24
|
+
"field.invalid_number": "Semak nombor kad anda",
|
|
25
|
+
"field.incomplete_expiry": "Masukkan tarikh luput penuh",
|
|
26
|
+
"field.invalid_expiry": "Semak tarikh luput",
|
|
27
|
+
"field.incomplete_cvc": "Masukkan kod keselamatan",
|
|
28
|
+
"field.invalid_cvc": "Semak kod keselamatan",
|
|
29
|
+
"field.unsupported_brand": "Jenis kad ini tidak diterima"
|
|
30
30
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
// pa-sdk-react-native — Android library build (
|
|
2
|
-
//
|
|
1
|
+
// pa-sdk-react-native — Android library build (distributed via npm; the
|
|
2
|
+
// Android sources are picked up by React Native autolinking).
|
|
3
3
|
//
|
|
4
|
-
//
|
|
5
|
-
// app's React Native only. minSdk 24
|
|
4
|
+
// No transitive SDKs — WebView and the support of the host
|
|
5
|
+
// app's React Native only. minSdk 24.
|
|
6
6
|
|
|
7
7
|
// Built as part of the host app's Gradle build (see example/settings.gradle);
|
|
8
8
|
// AGP / Kotlin plugins resolve from the root project classpath.
|
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
<application>
|
|
4
4
|
<!--
|
|
5
|
-
SDK-presented 3DS challenge activity
|
|
6
|
-
The intent-filters below let the SDK CONSUME its own 3DS returns
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
SDK-presented 3DS challenge activity. Full-screen WebView.
|
|
6
|
+
The intent-filters below let the SDK CONSUME its own 3DS returns:
|
|
7
|
+
when the issuer/ACS redirects to the app's return URL (the custom
|
|
8
|
+
scheme and the universal-link host declared below) while a challenge
|
|
9
|
+
is pending, this activity receives the intent, marks it consumed and
|
|
10
|
+
resolves the pending present() promise — the app's own link handler
|
|
11
|
+
never sees it. The scheme/host come from manifest placeholders the
|
|
12
|
+
consuming app MUST define in its build.gradle (see README).
|
|
12
13
|
-->
|
|
13
14
|
<activity
|
|
14
15
|
android:name=".PaSdk3dsActivity"
|
|
@@ -18,22 +19,22 @@
|
|
|
18
19
|
android:configChanges="orientation|screenSize|smallestScreenSize|screenLayout|keyboardHidden|uiMode"
|
|
19
20
|
android:windowSoftInputMode="adjustResize">
|
|
20
21
|
|
|
21
|
-
<!--
|
|
22
|
+
<!-- Return custom scheme -->
|
|
22
23
|
<intent-filter>
|
|
23
24
|
<action android:name="android.intent.action.VIEW" />
|
|
24
25
|
<category android:name="android.intent.category.DEFAULT" />
|
|
25
26
|
<category android:name="android.intent.category.BROWSABLE" />
|
|
26
|
-
<data android:scheme="
|
|
27
|
+
<data android:scheme="${paSdk3dsReturnScheme}" />
|
|
27
28
|
</intent-filter>
|
|
28
29
|
|
|
29
|
-
<!--
|
|
30
|
+
<!-- Return universal-link host -->
|
|
30
31
|
<intent-filter android:autoVerify="false">
|
|
31
32
|
<action android:name="android.intent.action.VIEW" />
|
|
32
33
|
<category android:name="android.intent.category.DEFAULT" />
|
|
33
34
|
<category android:name="android.intent.category.BROWSABLE" />
|
|
34
35
|
<data
|
|
35
36
|
android:scheme="https"
|
|
36
|
-
android:host="
|
|
37
|
+
android:host="${paSdk3dsReturnHost}" />
|
|
37
38
|
</intent-filter>
|
|
38
39
|
</activity>
|
|
39
40
|
</application>
|
|
@@ -18,17 +18,17 @@ import android.widget.TextView
|
|
|
18
18
|
import java.io.Serializable
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
|
-
* Full-screen WebView presenting the 3DS challenge
|
|
21
|
+
* Full-screen WebView presenting the 3DS challenge.
|
|
22
22
|
*
|
|
23
23
|
* Loads a tiny HTML document that auto-submits a POST form (Cardinal JWT or
|
|
24
24
|
* ACS creq) to the challenge URL — the same handshake as the iOS side.
|
|
25
25
|
*
|
|
26
|
-
* Return consumption
|
|
27
|
-
*
|
|
26
|
+
* Return consumption: the manifest routes the configured return URIs
|
|
27
|
+
* here. onCreate/onNewIntent hand the URI to
|
|
28
28
|
* PaSdk3dsModule.consumeReturnUri() while a challenge is pending, so the
|
|
29
29
|
* app's own link handler never sees the 3DS return. When no challenge is
|
|
30
30
|
* pending, the SDK does not swallow the URI — it re-dispatches it to the
|
|
31
|
-
* app's launch intent so
|
|
31
|
+
* app's launch intent so the app's normal deep-link handling proceeds.
|
|
32
32
|
*/
|
|
33
33
|
class PaSdk3dsActivity : android.app.Activity() {
|
|
34
34
|
|
|
@@ -121,7 +121,7 @@ class PaSdk3dsActivity : android.app.Activity() {
|
|
|
121
121
|
}
|
|
122
122
|
web.loadDataWithBaseURL(null, buildPostHtml(url, fields, str("redirecting", "Redirecting...")), "text/html", "utf-8", null)
|
|
123
123
|
|
|
124
|
-
//
|
|
124
|
+
// This activity may itself be the target of the 3DS return
|
|
125
125
|
// (cold start straight into the return URI).
|
|
126
126
|
handlePossibleReturn(intent)
|
|
127
127
|
}
|
|
@@ -136,7 +136,7 @@ class PaSdk3dsActivity : android.app.Activity() {
|
|
|
136
136
|
if (!isReturnUri(uri)) {
|
|
137
137
|
return
|
|
138
138
|
}
|
|
139
|
-
// Consume silently
|
|
139
|
+
// Consume silently: resolve the pending present() promise and
|
|
140
140
|
// finish. The gateway posts the challenge result server-side; the JS
|
|
141
141
|
// poller (/intent-status) observes the terminal state.
|
|
142
142
|
if (PaSdk3dsModule.consumeReturnUri(uri)) {
|
|
@@ -145,7 +145,7 @@ class PaSdk3dsActivity : android.app.Activity() {
|
|
|
145
145
|
return
|
|
146
146
|
}
|
|
147
147
|
// No challenge pending: this return is not the SDK's. Hand it on to
|
|
148
|
-
// the app's launch activity so
|
|
148
|
+
// the app's launch activity so the app's own deep-link handling proceeds.
|
|
149
149
|
reDispatchToApp(uri)
|
|
150
150
|
}
|
|
151
151
|
|
|
@@ -177,13 +177,6 @@ class PaSdk3dsActivity : android.app.Activity() {
|
|
|
177
177
|
return true
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
|
-
// Flow defaults, in case the JS layer did not pass them.
|
|
181
|
-
if (scheme == "flow") {
|
|
182
|
-
return true
|
|
183
|
-
}
|
|
184
|
-
if (scheme == "https" && uri.host?.lowercase() == "app.flowtheroom.com") {
|
|
185
|
-
return true
|
|
186
|
-
}
|
|
187
180
|
return false
|
|
188
181
|
}
|
|
189
182
|
|
|
@@ -195,7 +188,7 @@ class PaSdk3dsActivity : android.app.Activity() {
|
|
|
195
188
|
|
|
196
189
|
@Deprecated("Deprecated in Java")
|
|
197
190
|
override fun onBackPressed() {
|
|
198
|
-
// The challenge is not navigable; back means cancel
|
|
191
|
+
// The challenge is not navigable; back means cancel.
|
|
199
192
|
finishCancelled()
|
|
200
193
|
}
|
|
201
194
|
|
|
@@ -215,7 +208,7 @@ class PaSdk3dsActivity : android.app.Activity() {
|
|
|
215
208
|
override fun shouldOverrideUrlLoading(view: WebView?, request: WebResourceRequest?): Boolean {
|
|
216
209
|
val uri = request?.url ?: return false
|
|
217
210
|
if (isReturnUri(uri)) {
|
|
218
|
-
// Consume the 3DS return inside the SDK
|
|
211
|
+
// Consume the 3DS return inside the SDK instead of
|
|
219
212
|
// letting the WebView attempt a custom-scheme navigation.
|
|
220
213
|
if (PaSdk3dsModule.consumeReturnUri(uri)) {
|
|
221
214
|
finishedBySdk = true
|
|
@@ -10,7 +10,7 @@ import com.facebook.react.bridge.ReadableMap
|
|
|
10
10
|
import com.facebook.react.bridge.WritableNativeMap
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
* PaSdk3ds — SDK-presented 3DS challenge for Android
|
|
13
|
+
* PaSdk3ds — SDK-presented 3DS challenge for Android.
|
|
14
14
|
*
|
|
15
15
|
* present({url, fields, strings, returnUrlScheme, returnUrlUniversalHost})
|
|
16
16
|
* launches PaSdk3dsActivity full-screen; the promise resolves when the
|
|
@@ -29,8 +29,8 @@ class PaSdk3dsModule(private val reactContext: ReactApplicationContext) :
|
|
|
29
29
|
@Volatile
|
|
30
30
|
var pendingPromise: Promise? = null
|
|
31
31
|
|
|
32
|
-
/** Consume a 3DS return (
|
|
33
|
-
* landed on PaSdk3dsActivity
|
|
32
|
+
/** Consume a 3DS return (configured scheme / universal-link host) that
|
|
33
|
+
* landed on PaSdk3dsActivity. Returns true when a challenge
|
|
34
34
|
* was pending and the return was consumed by the SDK. */
|
|
35
35
|
fun consumeReturnUri(uri: Uri?): Boolean {
|
|
36
36
|
val promise = pendingPromise ?: return false
|
|
@@ -3,13 +3,13 @@ import UIKit
|
|
|
3
3
|
import WebKit
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* PaSdk3ds — SDK-presented 3DS challenge for iOS
|
|
6
|
+
* PaSdk3ds — SDK-presented 3DS challenge for iOS.
|
|
7
7
|
*
|
|
8
8
|
* Presents a full-screen WKWebView view controller that auto-submits a POST
|
|
9
9
|
* form carrying the Cardinal JWT (3DS2 StepUp) or the ACS creq (3DS1
|
|
10
10
|
* fallback) to the challenge URL. The gateway posts the challenge result
|
|
11
11
|
* server-side; the JS layer observes it via /intent-status polling and calls
|
|
12
|
-
* `close`, or the user taps Cancel, which resolves `cancelled
|
|
12
|
+
* `close`, or the user taps Cancel, which resolves `cancelled`.
|
|
13
13
|
*
|
|
14
14
|
* Bridged by PaSdk3dsModule.m via RCT_EXTERN_METHOD (classic NativeModules
|
|
15
15
|
* bridge; runs on the New Architecture through the interop layer).
|
|
@@ -262,10 +262,10 @@ public final class PaSdk3dsViewController: UIViewController, WKNavigationDelegat
|
|
|
262
262
|
}
|
|
263
263
|
}
|
|
264
264
|
|
|
265
|
-
// WKNavigationDelegate
|
|
266
|
-
// return URLs (
|
|
267
|
-
// here so the app's own link handler never sees it, then
|
|
268
|
-
// poller observe the server-side result.
|
|
265
|
+
// WKNavigationDelegate: when the ACS bounces through the 3DS
|
|
266
|
+
// return URLs (the configured scheme or the universal-link host), consume
|
|
267
|
+
// the navigation here so the app's own link handler never sees it, then
|
|
268
|
+
// let the JS poller observe the server-side result.
|
|
269
269
|
public func webView(_ webView: WKWebView,
|
|
270
270
|
decidePolicyFor navigationAction: WKNavigationAction,
|
|
271
271
|
decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
* url: NSString — Cardinal StepUp URL or issuer ACS URL
|
|
28
28
|
* fields: NSDictionary — form fields, e.g. {JWT: "..."} or {creq: "..."}
|
|
29
29
|
* strings: NSDictionary — {title, cancel, close, processing, redirecting}
|
|
30
|
-
* returnUrlScheme: NSString — e.g. "
|
|
31
|
-
* returnUrlUniversalHost: NSString — e.g. "https://
|
|
30
|
+
* returnUrlScheme: NSString — e.g. "yourapp://" (optional)
|
|
31
|
+
* returnUrlUniversalHost: NSString — e.g. "https://links.yourapp.com" (optional)
|
|
32
32
|
* }
|
|
33
33
|
* resolves: { cancelled: BOOL, returnUrlConsumed: BOOL }
|
|
34
34
|
*/
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pa-sdk-react-native",
|
|
3
|
-
"version": "3.0.
|
|
4
|
-
"description": "Payment Asia card payment SDK for React Native — headless validation, tokenization,
|
|
3
|
+
"version": "3.0.1",
|
|
4
|
+
"description": "Payment Asia card payment SDK for React Native — headless card validation, tokenization, payment confirmation with built-in 3D Secure, card saving and multi-market merchant accounts.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
7
7
|
"files": [
|
|
@@ -46,4 +46,4 @@
|
|
|
46
46
|
"url": "git+https://git.prizm.digital/nelson.lin/security_component_rn.git"
|
|
47
47
|
},
|
|
48
48
|
"homepage": "https://git.prizm.digital/nelson.lin/security_component_rn#readme"
|
|
49
|
-
}
|
|
49
|
+
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Generates src/errors.generated.ts from the shared PA SDK error code table
|
|
4
4
|
* (errors.json, the single source of truth also used by the web SDK and the
|
|
5
|
-
* server API
|
|
5
|
+
* server API).
|
|
6
6
|
*
|
|
7
7
|
* Usage:
|
|
8
8
|
* node scripts/generate-errors.js [path/to/errors.json]
|
|
@@ -61,7 +61,7 @@ const header = [
|
|
|
61
61
|
', generated_at: ' + (table.generated_at || 'unknown') + '.',
|
|
62
62
|
' *',
|
|
63
63
|
' * One code table shared by the server API, webhooks, the web SDK and this',
|
|
64
|
-
' * React Native SDK
|
|
64
|
+
' * React Native SDK. Values are English developer',
|
|
65
65
|
' * messages; localized user messages live in the locale bundles.',
|
|
66
66
|
' */',
|
|
67
67
|
'',
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
3
|
* Generates src/locales.generated.ts from the canonical locale bundles in
|
|
4
|
-
* locales/*.json (
|
|
4
|
+
* locales/*.json (en-US, zh-TW, zh-CN, ms-MY).
|
|
5
5
|
*
|
|
6
6
|
* The JSON files in locales/ are the source of truth; this script mirrors
|
|
7
7
|
* them into src/ so the TypeScript build stays self-contained under rootDir.
|
|
@@ -38,8 +38,8 @@ const out = [
|
|
|
38
38
|
' * GENERATED FILE — do not edit by hand.',
|
|
39
39
|
' * Generated by scripts/generate-locales.js from locales/*.json.',
|
|
40
40
|
' *',
|
|
41
|
-
' * Locale coverage
|
|
42
|
-
' * serves zh_HK/zh-HK), zh-CN (complete), ms-MY (my_MY —
|
|
41
|
+
' * Locale coverage: en-US (complete), zh-TW (complete,',
|
|
42
|
+
' * serves zh_HK/zh-HK), zh-CN (complete), ms-MY (my_MY — complete,',
|
|
43
43
|
' * falls back to en-US at runtime until translations are supplied).',
|
|
44
44
|
' */',
|
|
45
45
|
'',
|