@morefin/cashier-bootstrapper 0.3.4 → 0.3.5

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 CHANGED
@@ -37,11 +37,12 @@ new CashierBootstrapper('#cashier-root', {
37
37
  terminalId: 'terminal-456',
38
38
  userId: 'user-789',
39
39
  sessionId: 'session-abc',
40
+ locale: 'sv_SE',
41
+ channel: 'ios',
40
42
  predefinedAmounts: [100, 200, 300],
41
43
  layout: 'default',
42
44
  transactionType: ('deposit'|'withdrawal'),
43
45
  attributes: {
44
- channel: 'web',
45
46
  campaign: 'spring-launch',
46
47
  isVip: true
47
48
  }
@@ -62,7 +63,9 @@ new CashierBootstrapper('#cashier-root', {
62
63
  });
63
64
  ```
64
65
 
65
- `requestParams.attributes` sends custom cashier data as the `attributes` query parameter. Use it for values the cashier should receive as part of the request payload.
66
+ `requestParams.channel` selects the cashier payment method order channel. Supported values are `windows`, `mac`, `ios`, `android`, and `other`; when omitted, the bootstrapper derives it from the user device.
67
+
68
+ `requestParams.attributes` sends custom cashier data as the `attributes` query parameter. Use it for values the cashier should receive as part of the request payload. It does not control payment method ordering.
66
69
 
67
70
  `properties.iframe.attributes` applies plain HTML attributes directly to the rendered `<iframe>`. Use it for DOM concerns such as `data-*`, `loading`, or other iframe element attributes.
68
71
 
@@ -150,12 +153,16 @@ interface CashierRequestParams {
150
153
  terminalId?: string;
151
154
  userId?: string;
152
155
  sessionId?: string;
156
+ locale?: string;
157
+ channel?: CashierRuntimeChannel | string;
153
158
  predefinedAmounts?: number[];
154
159
  layout?: string;
155
160
  transactionType?: string;
156
161
  attributes?: Record<string, unknown>;
157
162
  }
158
163
 
164
+ type CashierRuntimeChannel = 'windows' | 'mac' | 'ios' | 'android' | 'other';
165
+
159
166
  type CashierEnvironment = 'production' | 'uat';
160
167
 
161
168
  interface CashierIframeOptions {
@@ -18,6 +18,7 @@ export function example2(container) {
18
18
  terminalId: 'terminal-456',
19
19
  userId: 'user-789',
20
20
  sessionId: 'session-abc',
21
+ locale: 'sv_SE',
21
22
  predefinedAmounts: [100, 200, 300],
22
23
  layout: 'default'
23
24
  },
@@ -46,6 +47,7 @@ export function example4(container) {
46
47
  merchantId: 'merchant-123',
47
48
  terminalId: 'terminal-456',
48
49
  userId: 'user-789',
50
+ locale: 'sv_SE',
49
51
  predefinedAmounts: [100, 200, 300],
50
52
  layout: 'default'
51
53
  },
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { CashierIframeApi, CashierIframeConfig } from './types';
2
- export type { CashierCallbacks, CashierEnvironment, CashierRequestParams, CashierIframeApi, CashierIframeConfig, CashierIframeProperties, CashierResultCallbackPayload, CashierRedirectPayload, CashierValidationFailedPayload } from './types';
2
+ export type { CashierCallbacks, CashierEnvironment, CashierRequestParams, CashierRuntimeChannel, CashierIframeApi, CashierIframeConfig, CashierIframeProperties, CashierResultCallbackPayload, CashierRedirectPayload, CashierValidationFailedPayload } from './types';
3
3
  type FingerprintJSGlobal = {
4
4
  load: () => Promise<{
5
5
  get: () => Promise<{
package/dist/index.js CHANGED
@@ -6,6 +6,7 @@ const TOP_URL_REPLACE_EVENT = 'TOP_URL_REPLACE';
6
6
  const CASHIER_IFRAME_OVERLAY_CLOSE_EVENT = 'CASHIER_IFRAME_OVERLAY_CLOSE';
7
7
  const CASHIER_RESULT_EVENT = 'CASHIER_RESULT';
8
8
  const CASHIER_VALIDATION_FAILED_EVENT = 'CASHIER_VALIDATION_FAILED';
9
+ const CASHIER_RUNTIME_CHANNELS = ['windows', 'mac', 'ios', 'android', 'other'];
9
10
  const CASHIER_ENVIRONMENT_CONFIG = {
10
11
  production: {
11
12
  host: 'https://api.morefin.com',
@@ -64,6 +65,37 @@ async function generateFingerprint() {
64
65
  return undefined;
65
66
  }
66
67
  }
68
+ function normalizeRuntimeChannel(channel) {
69
+ if (channel == null) {
70
+ return undefined;
71
+ }
72
+ const normalized = channel.trim().toLowerCase();
73
+ return CASHIER_RUNTIME_CHANNELS.includes(normalized)
74
+ ? normalized
75
+ : undefined;
76
+ }
77
+ function detectRuntimeChannel() {
78
+ if (typeof navigator === 'undefined') {
79
+ return undefined;
80
+ }
81
+ const userAgent = `${navigator.userAgent ?? ''} ${navigator.appVersion ?? ''}`.toLowerCase();
82
+ if (userAgent.includes('android')) {
83
+ return 'android';
84
+ }
85
+ if (userAgent.includes('iphone') || userAgent.includes('ipad') || userAgent.includes('ipod')) {
86
+ return 'ios';
87
+ }
88
+ if (userAgent.includes('windows')) {
89
+ return 'windows';
90
+ }
91
+ if (userAgent.includes('mac')) {
92
+ return 'mac';
93
+ }
94
+ return 'other';
95
+ }
96
+ function resolveRuntimeChannel(channel) {
97
+ return channel == null ? detectRuntimeChannel() : normalizeRuntimeChannel(channel);
98
+ }
67
99
  function buildQueryString(requestParams, fingerprint) {
68
100
  const query = new URLSearchParams();
69
101
  if (requestParams.merchantId != null) {
@@ -78,6 +110,13 @@ function buildQueryString(requestParams, fingerprint) {
78
110
  if (requestParams.sessionId != null) {
79
111
  query.append('sessionId', String(requestParams.sessionId));
80
112
  }
113
+ if (requestParams.locale != null && requestParams.locale !== '' && requestParams.locale !== 'undefined') {
114
+ query.append('locale', String(requestParams.locale));
115
+ }
116
+ const channel = resolveRuntimeChannel(requestParams.channel);
117
+ if (channel) {
118
+ query.append('channel', channel);
119
+ }
81
120
  if (Array.isArray(requestParams.predefinedAmounts)) {
82
121
  requestParams.predefinedAmounts.forEach(amount => {
83
122
  query.append('predefinedAmounts', String(amount));
package/dist/types.d.ts CHANGED
@@ -6,11 +6,14 @@ export interface CashierRequestParams {
6
6
  terminalId?: string;
7
7
  userId?: string;
8
8
  sessionId?: string;
9
+ locale?: string;
10
+ channel?: CashierRuntimeChannel | string;
9
11
  predefinedAmounts?: number[];
10
12
  layout?: string;
11
13
  transactionType?: string;
12
14
  attributes?: Record<string, unknown>;
13
15
  }
16
+ export type CashierRuntimeChannel = 'windows' | 'mac' | 'ios' | 'android' | 'other';
14
17
  export type CashierEnvironment = 'production' | 'uat' | 'local' | 'local4200';
15
18
  /**
16
19
  * Bootstrap properties configuration
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@morefin/cashier-bootstrapper",
3
- "version": "0.3.4",
3
+ "version": "0.3.5",
4
4
  "description": "Bootstrap service for initializing cashier payment page data from API",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",