@payrails/web-sdk 5.46.0-RC.0 → 5.47.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payrails/web-sdk",
3
- "version": "5.46.0-RC.0",
3
+ "version": "5.47.0",
4
4
  "description": "SDK providing tokenization options on the client for merchants",
5
5
  "main": "index.js",
6
6
  "types": "payrails.d.ts",
@@ -13,8 +13,7 @@
13
13
  "@rollup/plugin-html": "2.0.0",
14
14
  "@types/applepayjs": "14.0.9",
15
15
  "@types/googlepay": "0.7.5",
16
- "rollup-plugin-import-css": "3.5.8",
17
- "vitest-fetch-mock": "0.4.5"
16
+ "rollup-plugin-import-css": "3.5.8"
18
17
  },
19
18
  "module": "index.mjs",
20
19
  "exports": {
@@ -95,6 +95,213 @@
95
95
  }
96
96
  }
97
97
 
98
+ .payrails-billing-address-form {
99
+ display: block;
100
+ margin-bottom: 16px;
101
+ }
102
+
103
+ .payrails-billing-address-form-title {
104
+ font-size: 14px;
105
+ font-weight: 600;
106
+ color: #1f2733;
107
+ margin-bottom: 12px;
108
+ }
109
+
110
+ .payrails-billing-address-form .payrails-dynamic-element-form {
111
+ display: flex;
112
+ flex-direction: row;
113
+ flex-wrap: wrap;
114
+ gap: 12px;
115
+ }
116
+
117
+ .payrails-billing-address-form .payrails-dynamic-element-form-field {
118
+ flex: 1 1 100%;
119
+ gap: 0;
120
+ }
121
+
122
+ .payrails-billing-address-form [id='payrails-dynamic-element-field:city'],
123
+ .payrails-billing-address-form [id='payrails-dynamic-element-field:state'] {
124
+ flex: 1 1 calc(50% - 6px);
125
+ }
126
+
127
+ /* Placeholder-driven design: labels stay for accessibility but are hidden. */
128
+ .payrails-billing-address-form .payrails-dynamic-element-form-field-label {
129
+ position: absolute;
130
+ width: 1px;
131
+ height: 1px;
132
+ padding: 0;
133
+ margin: -1px;
134
+ overflow: hidden;
135
+ clip: rect(0, 0, 0, 0);
136
+ white-space: nowrap;
137
+ border: 0;
138
+ }
139
+
140
+ .payrails-billing-address-form .payrails-dynamic-element-input,
141
+ .payrails-billing-address-form .payrails-dynamic-element-select {
142
+ background-color: #ffffff;
143
+ border: 1px solid #e6e8eb;
144
+ border-radius: 8px;
145
+ padding: 12px 14px;
146
+ font-size: 14px;
147
+ color: #1f2733;
148
+ }
149
+
150
+ .payrails-billing-address-form .payrails-dynamic-element-input::placeholder {
151
+ color: #9aa0a6;
152
+ }
153
+
154
+ .payrails-billing-address-form
155
+ .payrails-dynamic-element-input:not(
156
+ .payrails-dynamic-element-input--readonly
157
+ ):focus,
158
+ .payrails-billing-address-form
159
+ .payrails-dynamic-element-select:not(
160
+ .payrails-dynamic-element-select--readonly
161
+ ):focus {
162
+ outline: none;
163
+ border-color: #cdd2da;
164
+ background-color: #ffffff;
165
+ box-shadow: none;
166
+ }
167
+
168
+ .payrails-billing-address-form
169
+ .payrails-dynamic-element-form-field.error
170
+ .payrails-dynamic-element-input,
171
+ .payrails-billing-address-form
172
+ .payrails-dynamic-element-form-field.error
173
+ .payrails-dynamic-element-select {
174
+ border-color: #f25226;
175
+ background-color: #fdecec;
176
+ }
177
+
178
+ .payrails-billing-address-form .payrails-dynamic-element-input--readonly,
179
+ .payrails-billing-address-form .payrails-dynamic-element-select--readonly {
180
+ background-color: #f5f6f8;
181
+ color: #6b7280;
182
+ cursor: not-allowed;
183
+ }
184
+
185
+ .payrails-dynamic-element-form {
186
+ display: flex;
187
+ flex-direction: column;
188
+ gap: 16px;
189
+ width: 100%;
190
+ }
191
+
192
+ .payrails-dynamic-element-form-field {
193
+ display: flex;
194
+ flex-direction: column;
195
+ gap: 4px;
196
+ width: 100%;
197
+ }
198
+
199
+ .payrails-dynamic-element-form-field-label {
200
+ font-size: 14px;
201
+ font-weight: 500;
202
+ color: #000000;
203
+ margin-bottom: 4px;
204
+ }
205
+
206
+ .payrails-dynamic-element-form-field-component {
207
+ width: 100%;
208
+ }
209
+
210
+ .payrails-dynamic-element-form-field-error {
211
+ font-size: 12px;
212
+ color: #ff0000;
213
+ margin-top: 4px;
214
+ display: none;
215
+ }
216
+
217
+ .payrails-dynamic-element-form-field.error
218
+ .payrails-dynamic-element-form-field-error {
219
+ display: block;
220
+ }
221
+
222
+ .payrails-dynamic-element-input {
223
+ width: 100%;
224
+ padding: 10px 16px;
225
+ border: 1px solid #eae8ee;
226
+ font-size: 14px;
227
+ color: #1d1d1d;
228
+ background-color: #fff;
229
+ box-sizing: border-box;
230
+ transition: border-color 0.2s ease;
231
+ }
232
+
233
+ .payrails-dynamic-element-input:focus {
234
+ outline: none;
235
+ border-color: #007bff;
236
+ box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
237
+ }
238
+
239
+ .payrails-dynamic-element-input:invalid {
240
+ border-color: #f25226;
241
+ background-color: #f9e1e1;
242
+ }
243
+
244
+ .payrails-dynamic-element-form-field.error .payrails-dynamic-element-input {
245
+ border-color: #f25226;
246
+ background-color: #f9e1e1;
247
+ }
248
+
249
+ .payrails-dynamic-element-input::placeholder {
250
+ color: grey;
251
+ opacity: 1;
252
+ }
253
+
254
+ .payrails-dynamic-element-select {
255
+ appearance: none;
256
+ -webkit-appearance: none;
257
+ -moz-appearance: none;
258
+ background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
259
+ background-repeat: no-repeat;
260
+ background-position: right 8px center;
261
+ width: 100%;
262
+ font-size: 14px;
263
+ color: #1d1d1d;
264
+ background-color: #fff;
265
+ box-sizing: border-box;
266
+ transition: border-color 0.2s ease;
267
+ padding: 10px 16px;
268
+ margin: 0;
269
+ border: 1px solid #eae8ee;
270
+ box-shadow: none;
271
+ cursor: pointer;
272
+ }
273
+
274
+ .payrails-dynamic-element-tabs {
275
+ display: flex;
276
+ flex-direction: row;
277
+ border: 1px solid #eae8ee;
278
+ padding: 4px;
279
+ background: transparent;
280
+ }
281
+
282
+ .payrails-dynamic-element-tabs button.payrails-dynamic-element-tab {
283
+ border-radius: 0;
284
+ flex: 1;
285
+ background: white;
286
+ border: none;
287
+ outline: none;
288
+ font-size: 16px;
289
+ font-weight: 500;
290
+ color: #000000;
291
+ padding: 4px;
292
+ text-transform: unset;
293
+ cursor: pointer;
294
+ }
295
+
296
+ .payrails-dynamic-element-tabs button.payrails-dynamic-element-tab.active {
297
+ background-color: #e0e5ed;
298
+ }
299
+
300
+ .payrails-dynamic-element-tabs button.payrails-dynamic-element-tab:hover {
301
+ background-color: unset;
302
+ color: unset;
303
+ }
304
+
98
305
  .payrails-store-instrument-checkbox {
99
306
  margin-right: 4px;
100
307
  }
@@ -849,123 +1056,3 @@ button.payrails-lean-button {
849
1056
  #payrails-paypal-button-wrapper {
850
1057
  min-height: 44px;
851
1058
  }
852
-
853
- .payrails-dynamic-element-form {
854
- display: flex;
855
- flex-direction: column;
856
- gap: 16px;
857
- width: 100%;
858
- }
859
-
860
- .payrails-dynamic-element-form-field {
861
- display: flex;
862
- flex-direction: column;
863
- gap: 4px;
864
- width: 100%;
865
- }
866
-
867
- .payrails-dynamic-element-form-field-label {
868
- font-size: 14px;
869
- font-weight: 500;
870
- color: #000000;
871
- margin-bottom: 4px;
872
- }
873
-
874
- .payrails-dynamic-element-form-field-component {
875
- width: 100%;
876
- }
877
-
878
- .payrails-dynamic-element-form-field-error {
879
- font-size: 12px;
880
- color: #ff0000;
881
- margin-top: 4px;
882
- display: none;
883
- }
884
-
885
- .payrails-dynamic-element-form-field.error
886
- .payrails-dynamic-element-form-field-error {
887
- display: block;
888
- }
889
-
890
- .payrails-dynamic-element-input {
891
- width: 100%;
892
- padding: 10px 16px;
893
- border: 1px solid #eae8ee;
894
- font-size: 14px;
895
- color: #1d1d1d;
896
- background-color: #fff;
897
- box-sizing: border-box;
898
- transition: border-color 0.2s ease;
899
- }
900
-
901
- .payrails-dynamic-element-input:focus {
902
- outline: none;
903
- border-color: #007bff;
904
- box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
905
- }
906
-
907
- .payrails-dynamic-element-input:invalid {
908
- border-color: #f25226;
909
- background-color: #f9e1e1;
910
- }
911
-
912
- .payrails-dynamic-element-form-field.error .payrails-dynamic-element-input {
913
- border-color: #f25226;
914
- background-color: #f9e1e1;
915
- }
916
-
917
- .payrails-dynamic-element-input::placeholder {
918
- color: grey;
919
- opacity: 1;
920
- }
921
-
922
- .payrails-dynamic-element-select {
923
- appearance: none;
924
- -webkit-appearance: none;
925
- -moz-appearance: none;
926
- background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
927
- background-repeat: no-repeat;
928
- background-position: right 8px center;
929
- width: 100%;
930
- font-size: 14px;
931
- color: #1d1d1d;
932
- background-color: #fff;
933
- box-sizing: border-box;
934
- transition: border-color 0.2s ease;
935
- padding: 10px 16px;
936
- margin: 0;
937
- border: 1px solid #eae8ee;
938
- box-shadow: none;
939
- cursor: pointer;
940
- }
941
-
942
- .payrails-dynamic-element-tabs {
943
- display: flex;
944
- flex-direction: row;
945
- border: 1px solid #eae8ee;
946
- padding: 4px;
947
- background: transparent;
948
- }
949
-
950
- .payrails-dynamic-element-tabs button.payrails-dynamic-element-tab {
951
- border-radius: 0;
952
- flex: 1;
953
- background: white;
954
- border: none;
955
- outline: none;
956
- font-size: 16px;
957
- font-weight: 500;
958
- color: #000000;
959
- padding: 4px;
960
- text-transform: unset;
961
- cursor: pointer;
962
- }
963
-
964
- .payrails-dynamic-element-tabs button.payrails-dynamic-element-tab.active {
965
- background-color: #e0e5ed;
966
- }
967
-
968
- .payrails-dynamic-element-tabs button.payrails-dynamic-element-tab:hover {
969
- background-color: unset;
970
- color: unset;
971
- }
package/payrails.d.ts CHANGED
@@ -4,6 +4,10 @@ type JSONSchemaType = JSONSchemaProperty & {
4
4
  required?: string[];
5
5
  dependentSchemas?: Record<string, JSONSchemaDependentSchema>;
6
6
  };
7
+ interface JSONSchemaOneOfOption {
8
+ const: string | number;
9
+ title: string;
10
+ }
7
11
  interface JSONSchemaDependentSchema {
8
12
  oneOf: Array<{
9
13
  properties: Record<string, {
@@ -24,17 +28,14 @@ interface JSONSchemaProperty {
24
28
  [UI_POSITION_FIELD]?: number;
25
29
  properties?: Record<string, JSONSchemaType>;
26
30
  }
27
- interface JSONSchemaOneOfOption {
28
- const: string | number;
29
- title: string;
30
- }
31
- interface JSONSchemaOneOfOption {
32
- const: string | number;
33
- title: string;
34
- }
35
31
  interface DynamicElementEvents {
36
- onReady: () => void;
37
- onValidationChange: (isValid: boolean) => void;
32
+ onReady?: () => void;
33
+ onValidationChange?: (isValid: boolean) => void;
34
+ }
35
+ interface DynamicElementFieldEvents {
36
+ onChange: (value: any) => void;
37
+ onReady: (initialValue: any) => void;
38
+ onBlur: () => void;
38
39
  }
39
40
  interface DynamicElementFieldTranslation {
40
41
  label?: string;
@@ -183,6 +184,14 @@ declare class WorkflowExecution {
183
184
  private static _response;
184
185
  static get response(): WorkflowExecutionResponse;
185
186
  static setResponse(response: WorkflowExecutionResponse): typeof WorkflowExecution;
187
+ /**
188
+ * Non-throwing read of the current execution id. Returns `undefined` when
189
+ * the workflow execution hasn't been initialized yet. Prefer this over
190
+ * `WorkflowExecution.response.id` in observational code paths (event
191
+ * emission, logging, analytics) where the workflow not being loaded should
192
+ * degrade gracefully instead of throwing.
193
+ */
194
+ static get executionId(): string | undefined;
186
195
  static get workflowCode(): string;
187
196
  static get lookup(): {
188
197
  httpCode: number;
@@ -571,6 +580,23 @@ interface SdkConfiguration {
571
580
  };
572
581
  };
573
582
  execution?: WorkflowExecutionResponse;
583
+ featureConfig?: SdkFeatureConfig;
584
+ morData?: MorData;
585
+ }
586
+ interface MorData {
587
+ billingLines?: {
588
+ street?: string;
589
+ line2?: string;
590
+ city?: string;
591
+ state?: string;
592
+ postalCode?: string;
593
+ email?: string;
594
+ country?: string;
595
+ form?: JSONSchemaType;
596
+ };
597
+ }
598
+ interface SdkFeatureConfig {
599
+ gpayIframeRollout?: number;
574
600
  }
575
601
  interface PayrailsAmount {
576
602
  value: string;
@@ -1497,6 +1523,18 @@ declare enum AuthorizationFailureReasons {
1497
1523
  USER_CANCELLED = "USER_CANCELLED"
1498
1524
  }
1499
1525
 
1526
+ type BillingAddressPrefill = Omit<NonNullable<MorData['billingLines']>, 'form'>;
1527
+ interface BillingAddressFormOptions {
1528
+ schema: JSONSchemaType;
1529
+ title?: string;
1530
+ prefill?: BillingAddressPrefill;
1531
+ styles?: DynamicElementStyles;
1532
+ translations?: DynamicElementTranslations;
1533
+ events?: {
1534
+ onReady?: () => void;
1535
+ };
1536
+ }
1537
+
1500
1538
  interface AuthFailedMsgOptions {
1501
1539
  translations?: {
1502
1540
  label?: string;
@@ -1535,7 +1573,7 @@ interface GooglePayButtonOptions extends StoreInstrumentElementOptions {
1535
1573
  } & StoreInstrumentElementOptions['styles'];
1536
1574
  returnInfo?: ReturnInfo;
1537
1575
  }
1538
- declare class GooglePayButton extends PayrailsElementWithStoreInstrumentCheckbox {
1576
+ declare class GooglePayButton$1 extends PayrailsElementWithStoreInstrumentCheckbox {
1539
1577
  protected options: GooglePayButtonOptions;
1540
1578
  private readonly paymentExecutor;
1541
1579
  private static googleSDKClient;
@@ -1556,6 +1594,11 @@ declare class GooglePayButton extends PayrailsElementWithStoreInstrumentCheckbox
1556
1594
  unmount(): void;
1557
1595
  }
1558
1596
 
1597
+ declare class GooglePayButton extends PayrailsElementWithStoreInstrumentCheckbox {
1598
+ static isGooglePayAvailable(...args: Parameters<typeof GooglePayButton$1.isGooglePayAvailable>): Promise<boolean>;
1599
+ constructor(options: GooglePayButtonOptions);
1600
+ }
1601
+
1559
1602
  interface LeanButtonOptions {
1560
1603
  id?: string;
1561
1604
  events?: PaymentEvents;
@@ -1821,6 +1864,8 @@ declare class Dropin extends PayrailsElement {
1821
1864
  private paypal;
1822
1865
  private lean;
1823
1866
  private loadingScreen;
1867
+ private billingAddressForm;
1868
+ private billingValidationBlocked;
1824
1869
  constructor(collectContainer: PayrailsCollectContainer, clientConfig: PayrailsClientOptions, dropinConfig: DropinOptions);
1825
1870
  private get returnInfo();
1826
1871
  private isHppIntegration;
@@ -1838,6 +1883,7 @@ declare class Dropin extends PayrailsElement {
1838
1883
  private createApplePayButton;
1839
1884
  private createCardPaymentButton;
1840
1885
  private onAuthorizeSuccess;
1886
+ private validateBillingAddress;
1841
1887
  private getElementEvents;
1842
1888
  private onAuthorizePending;
1843
1889
  private getErrorMessage;
@@ -1893,6 +1939,7 @@ interface DropinOptions {
1893
1939
  mercadoPago?: GenericRedirectDropinOptions['translations'];
1894
1940
  revolutPay?: GenericRedirectDropinOptions['translations'];
1895
1941
  addressSelector?: AddressSelectorElementOptions['translations'];
1942
+ billingAddressForm?: BillingAddressFormOptions['translations'];
1896
1943
  applePayButton?: ApplePayDropinOptions['translations'];
1897
1944
  leanButton?: LeanDropinOptions['translations'];
1898
1945
  errorMessages?: {
@@ -1913,6 +1960,7 @@ interface DropinOptions {
1913
1960
  authFailed?: Partial<CSSStyleDeclaration>;
1914
1961
  loadingScreen?: LoadingScreenStyles;
1915
1962
  addressSelector?: AddressSelectorElementOptions['styles'];
1963
+ billingAddressForm?: BillingAddressFormOptions['styles'];
1916
1964
  mercadoPago?: GenericRedirectDropinOptions['styles'];
1917
1965
  revolutPay?: GenericRedirectDropinOptions['styles'];
1918
1966
  };
@@ -1925,11 +1973,28 @@ interface ContainerStyles {
1925
1973
  styles?: Partial<CSSStyleDeclaration>;
1926
1974
  }
1927
1975
 
1976
+ interface DynamicElementFieldOptions {
1977
+ id: string;
1978
+ name: string;
1979
+ required?: boolean;
1980
+ property: JSONSchemaProperty;
1981
+ label: string;
1982
+ placeholder: string;
1983
+ value?: string;
1984
+ readOnly?: boolean;
1985
+ errors: DynamicElementErrorTranslation;
1986
+ styles?: DynamicElementFieldStyles;
1987
+ events: DynamicElementFieldEvents;
1988
+ }
1989
+
1990
+ type FieldOptionsWithoutEvents = Omit<DynamicElementFieldOptions, 'events'>;
1991
+
1928
1992
  interface DynamicElementOptions {
1929
1993
  styles?: DynamicElementStyles;
1930
1994
  translations?: DynamicElementTranslations;
1931
- paymentMethod: BasePaymentMethodConfig;
1995
+ paymentMethod?: BasePaymentMethodConfig;
1932
1996
  events?: DynamicElementEvents;
1997
+ fieldOverrides?: Record<string, Partial<FieldOptionsWithoutEvents>>;
1933
1998
  }
1934
1999
  interface FormConfig {
1935
2000
  schema: JSONSchemaType;
@@ -1943,7 +2008,7 @@ declare class DynamicElementForm extends Tokenizable {
1943
2008
  private __schema;
1944
2009
  private _previousFormValidState;
1945
2010
  constructor(options: DynamicElementOptions, formConfig: FormConfig, returnInfo?: ReturnInfo | undefined);
1946
- protected collect(): Promise<Record<string, any>>;
2011
+ collect(): Promise<Record<string, any>>;
1947
2012
  protected constructSaveInstrumentBody(tokens: any, opts?: TokenizeOptions): Promise<any>;
1948
2013
  private isFormValid;
1949
2014
  private isFormValidSilent;
@@ -2166,7 +2231,7 @@ declare class Payrails {
2166
2231
  paypalButton(options?: PaypalButtonOptions): PaypalButton;
2167
2232
  leanButton(options: LeanButtonOptions): LeanButton;
2168
2233
  genericRedirectButton(options: GenericRedirectButtonOptions): GenericRedirectButton;
2169
- dynamicElement(options: DynamicElementOptions): DynamicElementForm;
2234
+ dynamicElement(options: DynamicElementOptions & Required<Pick<DynamicElementOptions, 'paymentMethod'>>): DynamicElementForm;
2170
2235
  getSavedPaypalAccounts(): StoredPaymentInstrument<PayPalMetadata>[];
2171
2236
  private logIntegrationMode;
2172
2237
  private constructor();