@superlogic/spree-pay 0.4.14 → 0.5.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.
package/build/index.css CHANGED
@@ -243,6 +243,9 @@
243
243
  .sl-spreepay .pointer-events-none {
244
244
  pointer-events: none;
245
245
  }
246
+ .sl-spreepay .invisible {
247
+ visibility: hidden;
248
+ }
246
249
  .sl-spreepay .sr-only {
247
250
  position: absolute;
248
251
  width: 1px;
@@ -555,6 +558,11 @@
555
558
  .sl-spreepay .gap-6 {
556
559
  gap: calc(var(--spacing) * 6);
557
560
  }
561
+ .sl-spreepay .truncate {
562
+ overflow: hidden;
563
+ text-overflow: ellipsis;
564
+ white-space: nowrap;
565
+ }
558
566
  .sl-spreepay .overflow-hidden {
559
567
  overflow: hidden;
560
568
  }
@@ -662,6 +670,9 @@
662
670
  .sl-spreepay .bg-\(--crypto-pay-bg\) {
663
671
  background-color: var(--crypto-pay-bg);
664
672
  }
673
+ .sl-spreepay .bg-\(--negative\) {
674
+ background-color: var(--negative);
675
+ }
665
676
  .sl-spreepay .bg-\(--overlay\) {
666
677
  background-color: var(--overlay);
667
678
  }
@@ -1000,6 +1011,15 @@
1000
1011
  .sl-spreepay .ring-\(--b-brand\) {
1001
1012
  --tw-ring-color: var(--b-brand);
1002
1013
  }
1014
+ .sl-spreepay .ring-\(--b-tertiary\)\/50 {
1015
+ --tw-ring-color: var(--b-tertiary);
1016
+ @supports (color: color-mix(in lab, red, red)) {
1017
+ --tw-ring-color: color-mix(in oklab, var(--b-tertiary) 50%, transparent);
1018
+ }
1019
+ }
1020
+ .sl-spreepay .ring-offset-\(--s-default\) {
1021
+ --tw-ring-offset-color: var(--s-default);
1022
+ }
1003
1023
  .sl-spreepay .outline {
1004
1024
  outline-style: var(--tw-outline-style);
1005
1025
  outline-width: 1px;
@@ -1117,6 +1137,11 @@
1117
1137
  font-weight: var(--font-weight-medium);
1118
1138
  }
1119
1139
  }
1140
+ .sl-spreepay .file\:text-\(--primary\) {
1141
+ &::file-selector-button {
1142
+ color: var(--primary);
1143
+ }
1144
+ }
1120
1145
  .sl-spreepay .placeholder\:text-\(--tertiary\) {
1121
1146
  &::placeholder {
1122
1147
  color: var(--tertiary);
@@ -1136,6 +1161,16 @@
1136
1161
  }
1137
1162
  }
1138
1163
  }
1164
+ .sl-spreepay .hover\:bg-\(--negative\)\/90 {
1165
+ &:hover {
1166
+ @media (hover: hover) {
1167
+ background-color: var(--negative);
1168
+ @supports (color: color-mix(in lab, red, red)) {
1169
+ background-color: color-mix(in oklab, var(--negative) 90%, transparent);
1170
+ }
1171
+ }
1172
+ }
1173
+ }
1139
1174
  .sl-spreepay .hover\:bg-\(--primary\)\/90 {
1140
1175
  &:hover {
1141
1176
  @media (hover: hover) {
@@ -1229,6 +1264,11 @@
1229
1264
  var(--tw-shadow);
1230
1265
  }
1231
1266
  }
1267
+ .sl-spreepay .focus\:ring-\(--b-tertiary\) {
1268
+ &:focus {
1269
+ --tw-ring-color: var(--b-tertiary);
1270
+ }
1271
+ }
1232
1272
  .sl-spreepay .focus\:ring-offset-2 {
1233
1273
  &:focus {
1234
1274
  --tw-ring-offset-width: 2px;
@@ -1245,6 +1285,11 @@
1245
1285
  }
1246
1286
  }
1247
1287
  }
1288
+ .sl-spreepay .focus-visible\:border-\(--b-tertiary\) {
1289
+ &:focus-visible {
1290
+ border-color: var(--b-tertiary);
1291
+ }
1292
+ }
1248
1293
  .sl-spreepay .focus-visible\:ring-1 {
1249
1294
  &:focus-visible {
1250
1295
  --tw-ring-shadow: var(--tw-ring-inset,) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color, currentcolor);
@@ -1278,6 +1323,32 @@
1278
1323
  var(--tw-shadow);
1279
1324
  }
1280
1325
  }
1326
+ .sl-spreepay .focus-visible\:ring-\(--b-tertiary\) {
1327
+ &:focus-visible {
1328
+ --tw-ring-color: var(--b-tertiary);
1329
+ }
1330
+ }
1331
+ .sl-spreepay .focus-visible\:ring-\(--b-tertiary\)\/50 {
1332
+ &:focus-visible {
1333
+ --tw-ring-color: var(--b-tertiary);
1334
+ @supports (color: color-mix(in lab, red, red)) {
1335
+ --tw-ring-color: color-mix(in oklab, var(--b-tertiary) 50%, transparent);
1336
+ }
1337
+ }
1338
+ }
1339
+ .sl-spreepay .focus-visible\:ring-\(--negative\) {
1340
+ &:focus-visible {
1341
+ --tw-ring-color: var(--negative);
1342
+ }
1343
+ }
1344
+ .sl-spreepay .focus-visible\:ring-\(--negative\)\/20 {
1345
+ &:focus-visible {
1346
+ --tw-ring-color: var(--negative);
1347
+ @supports (color: color-mix(in lab, red, red)) {
1348
+ --tw-ring-color: color-mix(in oklab, var(--negative) 20%, transparent);
1349
+ }
1350
+ }
1351
+ }
1281
1352
  .sl-spreepay .focus-visible\:ring-offset-1 {
1282
1353
  &:focus-visible {
1283
1354
  --tw-ring-offset-width: 1px;
@@ -1355,6 +1426,19 @@
1355
1426
  padding-inline: calc(var(--spacing) * 6);
1356
1427
  }
1357
1428
  }
1429
+ .sl-spreepay .aria-invalid\:border-\(--negative\) {
1430
+ &[aria-invalid=true] {
1431
+ border-color: var(--negative);
1432
+ }
1433
+ }
1434
+ .sl-spreepay .aria-invalid\:ring-\(--negative\)\/20 {
1435
+ &[aria-invalid=true] {
1436
+ --tw-ring-color: var(--negative);
1437
+ @supports (color: color-mix(in lab, red, red)) {
1438
+ --tw-ring-color: color-mix(in oklab, var(--negative) 20%, transparent);
1439
+ }
1440
+ }
1441
+ }
1358
1442
  .sl-spreepay .data-disabled\:opacity-50 {
1359
1443
  &[data-disabled] {
1360
1444
  opacity: 50%;
@@ -1578,6 +1662,27 @@
1578
1662
  font-size: 22px;
1579
1663
  }
1580
1664
  }
1665
+ .sl-spreepay .dark\:border-\(--b-tertiary\) {
1666
+ &:is(.dark *) {
1667
+ border-color: var(--b-tertiary);
1668
+ }
1669
+ }
1670
+ .sl-spreepay .dark\:bg-\(--negative\)\/60 {
1671
+ &:is(.dark *) {
1672
+ background-color: var(--negative);
1673
+ @supports (color: color-mix(in lab, red, red)) {
1674
+ background-color: color-mix(in oklab, var(--negative) 60%, transparent);
1675
+ }
1676
+ }
1677
+ }
1678
+ .sl-spreepay .dark\:bg-\(--s-primary\)\/30 {
1679
+ &:is(.dark *) {
1680
+ background-color: var(--s-primary);
1681
+ @supports (color: color-mix(in lab, red, red)) {
1682
+ background-color: color-mix(in oklab, var(--s-primary) 30%, transparent);
1683
+ }
1684
+ }
1685
+ }
1581
1686
  .sl-spreepay .dark\:hover\:bg-\(--accent\)\/50 {
1582
1687
  &:is(.dark *) {
1583
1688
  &:hover {
@@ -1590,6 +1695,38 @@
1590
1695
  }
1591
1696
  }
1592
1697
  }
1698
+ .sl-spreepay .dark\:hover\:bg-\(--s-primary\)\/50 {
1699
+ &:is(.dark *) {
1700
+ &:hover {
1701
+ @media (hover: hover) {
1702
+ background-color: var(--s-primary);
1703
+ @supports (color: color-mix(in lab, red, red)) {
1704
+ background-color: color-mix(in oklab, var(--s-primary) 50%, transparent);
1705
+ }
1706
+ }
1707
+ }
1708
+ }
1709
+ }
1710
+ .sl-spreepay .dark\:focus-visible\:ring-\(--negative\)\/40 {
1711
+ &:is(.dark *) {
1712
+ &:focus-visible {
1713
+ --tw-ring-color: var(--negative);
1714
+ @supports (color: color-mix(in lab, red, red)) {
1715
+ --tw-ring-color: color-mix(in oklab, var(--negative) 40%, transparent);
1716
+ }
1717
+ }
1718
+ }
1719
+ }
1720
+ .sl-spreepay .dark\:aria-invalid\:ring-\(--negative\)\/40 {
1721
+ &:is(.dark *) {
1722
+ &[aria-invalid=true] {
1723
+ --tw-ring-color: var(--negative);
1724
+ @supports (color: color-mix(in lab, red, red)) {
1725
+ --tw-ring-color: color-mix(in oklab, var(--negative) 40%, transparent);
1726
+ }
1727
+ }
1728
+ }
1729
+ }
1593
1730
  .sl-spreepay .\[\&_a\]\:underline {
1594
1731
  & a {
1595
1732
  text-decoration-line: underline;
package/build/index.d.cts CHANGED
@@ -20,7 +20,9 @@ type SpreePayProps = Partial<{
20
20
 
21
21
  declare const SpreePay: (props: SpreePayProps) => react_jsx_runtime.JSX.Element;
22
22
 
23
- declare const useCapture3DS: (searchParams: Record<string, string | null>) => void;
23
+ declare const useCapture3DS: ({ paymentIntent }: {
24
+ paymentIntent?: string | null;
25
+ }) => void;
24
26
 
25
27
  type Environment = 'dev' | 'stg' | 'prod';
26
28
  type ENV = {
@@ -114,7 +116,7 @@ declare enum PaymentType {
114
116
  CREDIT_CARD_SPLIT = "SPLIT",
115
117
  POINTS = "POINTS"
116
118
  }
117
- declare enum SlapiPaymentStatus {
119
+ declare enum PaymentStatus {
118
120
  NOT_INITIALIZED = "NOT_INITIALIZED",// back-end only
119
121
  PENDING = "PENDING",// back-end only
120
122
  AUTHORIZED = "AUTHORIZED",// success
@@ -124,7 +126,7 @@ declare enum SlapiPaymentStatus {
124
126
  CAPTURE_FAILED = "CAPTURE_FAILED"
125
127
  }
126
128
  type PaymentMethodResult = {
127
- status: SlapiPaymentStatus;
129
+ status: PaymentStatus;
128
130
  paymentId: string;
129
131
  txHash: string | null;
130
132
  txId: string | null;
@@ -133,7 +135,6 @@ type PaymentMethodResult = {
133
135
  type ProcessFnParams = {
134
136
  hash: string;
135
137
  capture?: boolean;
136
- metadata?: Record<string, unknown>;
137
138
  };
138
139
  type ProcessFn = (data: ProcessFnParams) => Promise<PaymentMethodResult>;
139
140
 
@@ -160,6 +161,50 @@ declare global {
160
161
  }
161
162
  }
162
163
 
164
+ /**
165
+ * Thrown on a non-ok HTTP response. Keeps the status code and raw body on
166
+ * dedicated fields so callers can branch on 401/422/5xx without parsing the
167
+ * message string.
168
+ */
169
+ declare class SpreePayHttpError extends Error {
170
+ status: number;
171
+ body: string;
172
+ url: string;
173
+ constructor(status: number, body: string, url: string);
174
+ }
175
+ /**
176
+ * Discriminates *why* a payment failed so consumers can show tailored UI
177
+ * (e.g. "your card was declined, try another" vs. a generic "try again").
178
+ */
179
+ declare enum PaymentErrorCode {
180
+ /** The backend rejected the card (a 4xx decline, or a terminal FAILED status on a card payment). */
181
+ CARD_ERROR = "CARD_ERROR",
182
+ /** Anything else: network/server error, timeout, cancelled flow, crypto failure, … */
183
+ PAYMENT_ERROR = "PAYMENT_ERROR"
184
+ }
185
+ /**
186
+ * Wraps a payment failure with a category `code` and payment `status`; the original
187
+ * error is kept on `cause` (logs only). The widget throws this — detect it with
188
+ * `isPaymentError`. Not meant to be constructed by consumers.
189
+ */
190
+ declare class PaymentError extends Error {
191
+ status: PaymentStatus;
192
+ code: PaymentErrorCode;
193
+ /**
194
+ * Optional stable code from the backend (e.g. `INSUFFICIENT_FUNDS`) for branching
195
+ * on specific cases without changing the `code` enum. Safe to expose (an
196
+ * identifier, not free-text); absent until the backend supplies one.
197
+ */
198
+ backendCode?: string;
199
+ constructor(message: string, status: PaymentStatus, options?: {
200
+ code?: PaymentErrorCode;
201
+ backendCode?: string;
202
+ cause?: unknown;
203
+ });
204
+ }
205
+ /** Type guard so consumers can branch on PaymentError without duck-typing `.status`. */
206
+ declare const isPaymentError: (e: unknown) => e is PaymentError;
207
+
163
208
  declare enum LogLevel {
164
209
  DEBUG = 0,
165
210
  INFO = 1,
@@ -234,4 +279,4 @@ declare const configureLogger: (config: Partial<LoggerConfig> & {
234
279
  environment?: Environment;
235
280
  }) => void;
236
281
 
237
- export { type ENV, LogLevel, type PaymentMethodResult, PaymentType, type ProcessFn, type ProcessFnParams, type SelectedPaymentMethod, SlapiPaymentStatus, SpreePay, type SpreePayProps, SpreePayProvider, configureLogger, logger, useCapture3DS, useSpreePay };
282
+ export { type ENV, type Environment, type LogContext, LogLevel, type LoggerConfig, PaymentError, PaymentErrorCode, type PaymentMethodResult, PaymentStatus, PaymentType, type ProcessFn, type ProcessFnParams, type SelectedPaymentMethod, SpreePay, SpreePayHttpError, type SpreePayProps, SpreePayProvider, configureLogger, isPaymentError, logger, useCapture3DS, useSpreePay };
package/build/index.d.ts CHANGED
@@ -20,7 +20,9 @@ type SpreePayProps = Partial<{
20
20
 
21
21
  declare const SpreePay: (props: SpreePayProps) => react_jsx_runtime.JSX.Element;
22
22
 
23
- declare const useCapture3DS: (searchParams: Record<string, string | null>) => void;
23
+ declare const useCapture3DS: ({ paymentIntent }: {
24
+ paymentIntent?: string | null;
25
+ }) => void;
24
26
 
25
27
  type Environment = 'dev' | 'stg' | 'prod';
26
28
  type ENV = {
@@ -114,7 +116,7 @@ declare enum PaymentType {
114
116
  CREDIT_CARD_SPLIT = "SPLIT",
115
117
  POINTS = "POINTS"
116
118
  }
117
- declare enum SlapiPaymentStatus {
119
+ declare enum PaymentStatus {
118
120
  NOT_INITIALIZED = "NOT_INITIALIZED",// back-end only
119
121
  PENDING = "PENDING",// back-end only
120
122
  AUTHORIZED = "AUTHORIZED",// success
@@ -124,7 +126,7 @@ declare enum SlapiPaymentStatus {
124
126
  CAPTURE_FAILED = "CAPTURE_FAILED"
125
127
  }
126
128
  type PaymentMethodResult = {
127
- status: SlapiPaymentStatus;
129
+ status: PaymentStatus;
128
130
  paymentId: string;
129
131
  txHash: string | null;
130
132
  txId: string | null;
@@ -133,7 +135,6 @@ type PaymentMethodResult = {
133
135
  type ProcessFnParams = {
134
136
  hash: string;
135
137
  capture?: boolean;
136
- metadata?: Record<string, unknown>;
137
138
  };
138
139
  type ProcessFn = (data: ProcessFnParams) => Promise<PaymentMethodResult>;
139
140
 
@@ -160,6 +161,50 @@ declare global {
160
161
  }
161
162
  }
162
163
 
164
+ /**
165
+ * Thrown on a non-ok HTTP response. Keeps the status code and raw body on
166
+ * dedicated fields so callers can branch on 401/422/5xx without parsing the
167
+ * message string.
168
+ */
169
+ declare class SpreePayHttpError extends Error {
170
+ status: number;
171
+ body: string;
172
+ url: string;
173
+ constructor(status: number, body: string, url: string);
174
+ }
175
+ /**
176
+ * Discriminates *why* a payment failed so consumers can show tailored UI
177
+ * (e.g. "your card was declined, try another" vs. a generic "try again").
178
+ */
179
+ declare enum PaymentErrorCode {
180
+ /** The backend rejected the card (a 4xx decline, or a terminal FAILED status on a card payment). */
181
+ CARD_ERROR = "CARD_ERROR",
182
+ /** Anything else: network/server error, timeout, cancelled flow, crypto failure, … */
183
+ PAYMENT_ERROR = "PAYMENT_ERROR"
184
+ }
185
+ /**
186
+ * Wraps a payment failure with a category `code` and payment `status`; the original
187
+ * error is kept on `cause` (logs only). The widget throws this — detect it with
188
+ * `isPaymentError`. Not meant to be constructed by consumers.
189
+ */
190
+ declare class PaymentError extends Error {
191
+ status: PaymentStatus;
192
+ code: PaymentErrorCode;
193
+ /**
194
+ * Optional stable code from the backend (e.g. `INSUFFICIENT_FUNDS`) for branching
195
+ * on specific cases without changing the `code` enum. Safe to expose (an
196
+ * identifier, not free-text); absent until the backend supplies one.
197
+ */
198
+ backendCode?: string;
199
+ constructor(message: string, status: PaymentStatus, options?: {
200
+ code?: PaymentErrorCode;
201
+ backendCode?: string;
202
+ cause?: unknown;
203
+ });
204
+ }
205
+ /** Type guard so consumers can branch on PaymentError without duck-typing `.status`. */
206
+ declare const isPaymentError: (e: unknown) => e is PaymentError;
207
+
163
208
  declare enum LogLevel {
164
209
  DEBUG = 0,
165
210
  INFO = 1,
@@ -234,4 +279,4 @@ declare const configureLogger: (config: Partial<LoggerConfig> & {
234
279
  environment?: Environment;
235
280
  }) => void;
236
281
 
237
- export { type ENV, LogLevel, type PaymentMethodResult, PaymentType, type ProcessFn, type ProcessFnParams, type SelectedPaymentMethod, SlapiPaymentStatus, SpreePay, type SpreePayProps, SpreePayProvider, configureLogger, logger, useCapture3DS, useSpreePay };
282
+ export { type ENV, type Environment, type LogContext, LogLevel, type LoggerConfig, PaymentError, PaymentErrorCode, type PaymentMethodResult, PaymentStatus, PaymentType, type ProcessFn, type ProcessFnParams, type SelectedPaymentMethod, SpreePay, SpreePayHttpError, type SpreePayProps, SpreePayProvider, configureLogger, isPaymentError, logger, useCapture3DS, useSpreePay };