@clickmax/checkout-react 12.5.3 → 12.5.6

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/dist/index.d.ts CHANGED
@@ -428,6 +428,8 @@ export declare interface CheckoutMessages extends ValidationMessages {
428
428
  purchaseFailed: string;
429
429
  purchaseTimeout: string;
430
430
  pixExpired: string;
431
+ /** The offer only sells to a chosen audience and this email is not part of it. */
432
+ offerBuyerNotEligible: string;
431
433
  /** Heading of the required order bumps. */
432
434
  includedInOrder: string;
433
435
  /** Default title of the optional bumps when there is one. */
@@ -558,7 +560,7 @@ export declare function CountdownTimer({ seconds, force, className, children, }:
558
560
 
559
561
  /** Props of {@link CountdownTimer}. */
560
562
  export declare interface CountdownTimerProps {
561
- /** Length of the countdown in seconds. Defaults to 10 minutes. */
563
+ /** Length of the countdown in seconds. Defaults to the minutes the offer sets for its timer. */
562
564
  seconds?: number;
563
565
  /** Shows the timer even when the offer does not ask for one. */
564
566
  force?: boolean;
@@ -951,6 +953,7 @@ declare type GetPublicOfferCheckout2xx = {
951
953
  isSellerPending: boolean;
952
954
  isAnyOfferPending: boolean;
953
955
  isOfferUnavailable: boolean;
956
+ isAudienceRestricted: boolean;
954
957
  isRecurrent: boolean;
955
958
  hash: string;
956
959
  /** @maxLength 1000 */
@@ -973,6 +976,11 @@ declare type GetPublicOfferCheckout2xx = {
973
976
  description?: string | null;
974
977
  methods: GetPublicOfferCheckout2xxMethods;
975
978
  showTimer: boolean;
979
+ /**
980
+ * @minimum 1
981
+ * @maximum 60
982
+ */
983
+ timerMinutes: number;
976
984
  showCoupon: boolean;
977
985
  highlightInstallment: boolean;
978
986
  passPlatformFee: boolean;
@@ -1647,6 +1655,7 @@ declare type GetPublicOfferCheckout2xxOrderBumpsItem = {
1647
1655
  */
1648
1656
  maxInstallments?: number | null;
1649
1657
  paymentMethods: GetPublicOfferCheckout2xxOrderBumpsItemPaymentMethods;
1658
+ isAudienceRestricted: boolean;
1650
1659
  };
1651
1660
 
1652
1661
  declare type GetPublicOfferCheckout2xxOrderBumpsItemInstallmentsItem = {
@@ -1727,17 +1736,47 @@ declare type GetPublicOfferCheckout2xxPixelsItemEventsConfigPurchasePaymentMetho
1727
1736
  */
1728
1737
  declare type GetPublicOfferCheckout2xxSocialProof = {
1729
1738
  enabled: boolean;
1730
- types: GetPublicOfferCheckout2xxSocialProofTypesItem[];
1731
- window: GetPublicOfferCheckout2xxSocialProofWindow;
1739
+ /**
1740
+ * @minimum 1
1741
+ * @maximum 10
1742
+ */
1743
+ maxBalloons: number;
1744
+ views: GetPublicOfferCheckout2xxSocialProofViews;
1745
+ purchases: GetPublicOfferCheckout2xxSocialProofPurchases;
1746
+ orderBumpPurchases: GetPublicOfferCheckout2xxSocialProofOrderBumpPurchases;
1747
+ recentActivity: GetPublicOfferCheckout2xxSocialProofRecentActivity;
1748
+ } | null;
1749
+
1750
+ declare type GetPublicOfferCheckout2xxSocialProofOrderBumpPurchases = {
1751
+ enabled: boolean;
1752
+ window: GetPublicOfferCheckout2xxSocialProofOrderBumpPurchasesWindow;
1732
1753
  /** @minimum 1 */
1733
1754
  minCount: number;
1755
+ };
1756
+
1757
+ declare type GetPublicOfferCheckout2xxSocialProofOrderBumpPurchasesWindow = '1h' | '12h' | '24h' | '48h' | '7d';
1758
+
1759
+ declare type GetPublicOfferCheckout2xxSocialProofPurchases = {
1760
+ enabled: boolean;
1761
+ window: GetPublicOfferCheckout2xxSocialProofPurchasesWindow;
1734
1762
  /** @minimum 1 */
1735
- maxBalloons: number;
1736
- } | null;
1763
+ minCount: number;
1764
+ };
1765
+
1766
+ declare type GetPublicOfferCheckout2xxSocialProofPurchasesWindow = '1h' | '12h' | '24h' | '48h' | '7d';
1737
1767
 
1738
- declare type GetPublicOfferCheckout2xxSocialProofTypesItem = 'views' | 'purchases' | 'orderBumpPurchases' | 'recentActivity';
1768
+ declare type GetPublicOfferCheckout2xxSocialProofRecentActivity = {
1769
+ enabled: boolean;
1770
+ };
1771
+
1772
+ declare type GetPublicOfferCheckout2xxSocialProofViews = {
1773
+ enabled: boolean;
1774
+ window: GetPublicOfferCheckout2xxSocialProofViewsWindow;
1775
+ /** @minimum 1 */
1776
+ minCount: number;
1777
+ };
1739
1778
 
1740
- declare type GetPublicOfferCheckout2xxSocialProofWindow = '1h' | '12h' | '24h' | '48h';
1779
+ declare type GetPublicOfferCheckout2xxSocialProofViewsWindow = '10m' | '1h' | '12h' | '24h' | '48h' | '7d';
1741
1780
 
1742
1781
  declare type Handler<E extends CardElementEvent> = (event: CardElementEventMap[E]) => void;
1743
1782
 
@@ -2309,7 +2348,8 @@ export declare function useCheckout(): CheckoutContextValue;
2309
2348
  * Countdown that starts at `seconds` when the page hydrates. The server renders `seconds`, so the
2310
2349
  * prerendered HTML and the first client render match.
2311
2350
  *
2312
- * @param requestedSeconds Length of the countdown. Defaults to 10 minutes.
2351
+ * @param requestedSeconds Length of the countdown. Defaults to the minutes the offer sets for its
2352
+ * timer, or 10 minutes when the offer does not set them.
2313
2353
  */
2314
2354
  export declare function useCountdown(requestedSeconds?: number): {
2315
2355
  secondsLeft: number;
package/dist/index.js CHANGED
@@ -655,6 +655,7 @@ const PT_BR = {
655
655
  purchaseFailed: 'Não foi possível concluir a compra.',
656
656
  purchaseTimeout: 'A compra está demorando. Confira seu e-mail antes de tentar de novo.',
657
657
  pixExpired: 'O código pix expirou. Gere outro.',
658
+ offerBuyerNotEligible: 'Esta oferta não está disponível para este e-mail.',
658
659
  includedInOrder: 'Incluído no seu pedido',
659
660
  specialOffer: 'Oferta especial',
660
661
  specialOffers: 'Ofertas especiais'
@@ -676,6 +677,7 @@ const EN = {
676
677
  purchaseFailed: 'Could not complete the purchase.',
677
678
  purchaseTimeout: 'The purchase is taking long. Check your email before trying again.',
678
679
  pixExpired: 'The pix code expired. Generate a new one.',
680
+ offerBuyerNotEligible: 'This offer is not available for this email.',
679
681
  includedInOrder: 'Included in your order',
680
682
  specialOffer: 'Special offer',
681
683
  specialOffers: 'Special offers'
@@ -697,6 +699,7 @@ const ES = {
697
699
  purchaseFailed: 'No fue posible completar la compra.',
698
700
  purchaseTimeout: 'La compra está tardando. Revisa tu correo antes de intentar de nuevo.',
699
701
  pixExpired: 'El código pix expiró. Genera otro.',
702
+ offerBuyerNotEligible: 'Esta oferta no está disponible para este correo.',
700
703
  includedInOrder: 'Incluido en tu pedido',
701
704
  specialOffer: 'Oferta especial',
702
705
  specialOffers: 'Ofertas especiales'
@@ -1159,7 +1162,8 @@ async function waitForJob(state, jobId) {
1159
1162
  // a retry is deduplicated by the API instead of charging twice. A definitive refusal (4xx)
1160
1163
  // starts the next attempt with a new key.
1161
1164
  if (apiError.status !== 0 && apiError.status < 500) state.idempotency.key = undefined;
1162
- const message = apiError.message || state.messages.purchaseFailed;
1165
+ // The API answers this refusal with a stable code as the message; show it translated.
1166
+ const message = apiError.message === 'OFFER_BUYER_NOT_ELIGIBLE' ? state.messages.offerBuyerNotEligible : apiError.message || state.messages.purchaseFailed;
1163
1167
  commit(()=>({
1164
1168
  status: 'declined',
1165
1169
  error: message,
@@ -2040,10 +2044,12 @@ const ELEMENTS_LOCALE = {
2040
2044
  * Countdown that starts at `seconds` when the page hydrates. The server renders `seconds`, so the
2041
2045
  * prerendered HTML and the first client render match.
2042
2046
  *
2043
- * @param requestedSeconds Length of the countdown. Defaults to 10 minutes.
2047
+ * @param requestedSeconds Length of the countdown. Defaults to the minutes the offer sets for its
2048
+ * timer, or 10 minutes when the offer does not set them.
2044
2049
  */ function useCountdown(requestedSeconds) {
2045
- const seconds = Math.round(positiveFinite(requestedSeconds, 600));
2046
2050
  const { offer, isHydrated } = useCheckout();
2051
+ const offerSeconds = positiveFinite(offer.timerMinutes, 10) * 60;
2052
+ const seconds = Math.round(positiveFinite(requestedSeconds, offerSeconds));
2047
2053
  const [deadline, setDeadline] = useState(undefined);
2048
2054
  useEffect(()=>{
2049
2055
  if (isHydrated) setDeadline(Date.now() + seconds * 1000);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clickmax/checkout-react",
3
- "version": "12.5.3",
3
+ "version": "12.5.6",
4
4
  "description": "Headless React components for the Clickmax checkout",
5
5
  "keywords": [
6
6
  "clickmax",
@@ -28,7 +28,7 @@
28
28
  "config": {
29
29
  "deploy": "npm",
30
30
  "watch": [
31
- "sdk/payments/openapi.yaml"
31
+ "servers/payments-api/openapi.yaml"
32
32
  ]
33
33
  },
34
34
  "devDependencies": {