@brissoto/pay-react-native 0.0.0-stage → 1.5.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.
Files changed (172) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +181 -2
  3. package/assets/brand/paypal-wordmark.png +0 -0
  4. package/assets/fonts/Figtree-Bold.ttf +0 -0
  5. package/assets/fonts/Figtree-ExtraBold.ttf +0 -0
  6. package/assets/fonts/Figtree-Medium.ttf +0 -0
  7. package/assets/fonts/Figtree-Regular.ttf +0 -0
  8. package/assets/fonts/Figtree-SemiBold.ttf +0 -0
  9. package/assets/fonts/OFL.txt +93 -0
  10. package/assets/logos/airtel.png +0 -0
  11. package/assets/logos/app-store.png +0 -0
  12. package/assets/logos/apple-pay.png +0 -0
  13. package/assets/logos/at.png +0 -0
  14. package/assets/logos/bancontact.png +0 -0
  15. package/assets/logos/card.png +0 -0
  16. package/assets/logos/cb.png +0 -0
  17. package/assets/logos/celtiis.png +0 -0
  18. package/assets/logos/eps.png +0 -0
  19. package/assets/logos/feexpay.png +0 -0
  20. package/assets/logos/google-pay.png +0 -0
  21. package/assets/logos/google-play.png +0 -0
  22. package/assets/logos/iapkit.png +0 -0
  23. package/assets/logos/ideal.png +0 -0
  24. package/assets/logos/mastercard.png +0 -0
  25. package/assets/logos/mixx.png +0 -0
  26. package/assets/logos/moov.png +0 -0
  27. package/assets/logos/mtn.png +0 -0
  28. package/assets/logos/mybank.png +0 -0
  29. package/assets/logos/nexus.png +0 -0
  30. package/assets/logos/orange.png +0 -0
  31. package/assets/logos/pawapay.png +0 -0
  32. package/assets/logos/paypal.png +0 -0
  33. package/assets/logos/telecel.png +0 -0
  34. package/assets/logos/tnm.png +0 -0
  35. package/assets/logos/visa.png +0 -0
  36. package/assets/logos/vodacom.png +0 -0
  37. package/assets/logos/wave.png +0 -0
  38. package/dist/checkout-core/hooks/use-checkout-controller.d.ts +9 -0
  39. package/dist/checkout-core/hooks/use-checkout-controller.js +563 -0
  40. package/dist/checkout-core/hooks/use-checkout-payment.d.ts +9 -0
  41. package/dist/checkout-core/hooks/use-checkout-payment.js +136 -0
  42. package/dist/checkout-core/hooks/use-checkout-timers.d.ts +15 -0
  43. package/dist/checkout-core/hooks/use-checkout-timers.js +44 -0
  44. package/dist/checkout-core/hooks/use-phone-number.d.ts +7 -0
  45. package/dist/checkout-core/hooks/use-phone-number.js +82 -0
  46. package/dist/checkout-core/messages/en.d.ts +302 -0
  47. package/dist/checkout-core/messages/en.js +301 -0
  48. package/dist/checkout-core/messages/fr.d.ts +4 -0
  49. package/dist/checkout-core/messages/fr.js +302 -0
  50. package/dist/checkout-core/models/checkout.card.utils.d.ts +7 -0
  51. package/dist/checkout-core/models/checkout.card.utils.js +25 -0
  52. package/dist/checkout-core/models/checkout.constants.d.ts +101 -0
  53. package/dist/checkout-core/models/checkout.constants.js +339 -0
  54. package/dist/checkout-core/models/checkout.country.utils.d.ts +17 -0
  55. package/dist/checkout-core/models/checkout.country.utils.js +45 -0
  56. package/dist/checkout-core/models/checkout.enum.d.ts +233 -0
  57. package/dist/checkout-core/models/checkout.enum.js +259 -0
  58. package/dist/checkout-core/models/checkout.fetch.utils.d.ts +6 -0
  59. package/dist/checkout-core/models/checkout.fetch.utils.js +22 -0
  60. package/dist/checkout-core/models/checkout.interface.d.ts +698 -0
  61. package/dist/checkout-core/models/checkout.interface.js +1 -0
  62. package/dist/checkout-core/models/checkout.money.utils.d.ts +7 -0
  63. package/dist/checkout-core/models/checkout.money.utils.js +21 -0
  64. package/dist/checkout-core/models/checkout.phone.utils.d.ts +33 -0
  65. package/dist/checkout-core/models/checkout.phone.utils.js +159 -0
  66. package/dist/checkout-core/models/checkout.view.utils.d.ts +77 -0
  67. package/dist/checkout-core/models/checkout.view.utils.js +331 -0
  68. package/dist/checkout-core/models/domain.enum.d.ts +106 -0
  69. package/dist/checkout-core/models/domain.enum.js +113 -0
  70. package/dist/components/BrissotoPayProvider.d.ts +8 -0
  71. package/dist/components/BrissotoPayProvider.js +39 -0
  72. package/dist/components/PaymentSheetModal.d.ts +9 -0
  73. package/dist/components/PaymentSheetModal.js +106 -0
  74. package/dist/components/SheetBone.d.ts +3 -0
  75. package/dist/components/SheetBone.js +12 -0
  76. package/dist/components/SheetButton.d.ts +7 -0
  77. package/dist/components/SheetButton.js +47 -0
  78. package/dist/components/SheetCardFields.d.ts +10 -0
  79. package/dist/components/SheetCardFields.js +86 -0
  80. package/dist/components/SheetChosenMethod.d.ts +3 -0
  81. package/dist/components/SheetChosenMethod.js +60 -0
  82. package/dist/components/SheetCodeField.d.ts +8 -0
  83. package/dist/components/SheetCodeField.js +98 -0
  84. package/dist/components/SheetContent.d.ts +3 -0
  85. package/dist/components/SheetContent.js +133 -0
  86. package/dist/components/SheetDial.d.ts +7 -0
  87. package/dist/components/SheetDial.js +36 -0
  88. package/dist/components/SheetFailed.d.ts +3 -0
  89. package/dist/components/SheetFailed.js +44 -0
  90. package/dist/components/SheetForm.d.ts +8 -0
  91. package/dist/components/SheetForm.js +141 -0
  92. package/dist/components/SheetGrabber.d.ts +2 -0
  93. package/dist/components/SheetGrabber.js +17 -0
  94. package/dist/components/SheetHeader.d.ts +7 -0
  95. package/dist/components/SheetHeader.js +83 -0
  96. package/dist/components/SheetIcon.d.ts +3 -0
  97. package/dist/components/SheetIcon.js +78 -0
  98. package/dist/components/SheetLayout.d.ts +11 -0
  99. package/dist/components/SheetLayout.js +63 -0
  100. package/dist/components/SheetLogo.d.ts +3 -0
  101. package/dist/components/SheetLogo.js +20 -0
  102. package/dist/components/SheetMessage.d.ts +3 -0
  103. package/dist/components/SheetMessage.js +15 -0
  104. package/dist/components/SheetMethodCard.d.ts +3 -0
  105. package/dist/components/SheetMethodCard.js +71 -0
  106. package/dist/components/SheetNameField.d.ts +7 -0
  107. package/dist/components/SheetNameField.js +48 -0
  108. package/dist/components/SheetPaypalButton.d.ts +3 -0
  109. package/dist/components/SheetPaypalButton.js +23 -0
  110. package/dist/components/SheetPhoneField.d.ts +3 -0
  111. package/dist/components/SheetPhoneField.js +59 -0
  112. package/dist/components/SheetPillSelect.d.ts +7 -0
  113. package/dist/components/SheetPillSelect.js +134 -0
  114. package/dist/components/SheetRow.d.ts +3 -0
  115. package/dist/components/SheetRow.js +28 -0
  116. package/dist/components/SheetSimulator.d.ts +6 -0
  117. package/dist/components/SheetSimulator.js +40 -0
  118. package/dist/components/SheetSkeleton.d.ts +5 -0
  119. package/dist/components/SheetSkeleton.js +23 -0
  120. package/dist/components/SheetStep.d.ts +6 -0
  121. package/dist/components/SheetStep.js +21 -0
  122. package/dist/components/SheetStoreTab.d.ts +7 -0
  123. package/dist/components/SheetStoreTab.js +27 -0
  124. package/dist/components/SheetSuccess.d.ts +3 -0
  125. package/dist/components/SheetSuccess.js +51 -0
  126. package/dist/components/SheetSummary.d.ts +3 -0
  127. package/dist/components/SheetSummary.js +32 -0
  128. package/dist/components/SheetTerminal.d.ts +6 -0
  129. package/dist/components/SheetTerminal.js +31 -0
  130. package/dist/components/SheetText.d.ts +5 -0
  131. package/dist/components/SheetText.js +27 -0
  132. package/dist/components/SheetToast.d.ts +7 -0
  133. package/dist/components/SheetToast.js +71 -0
  134. package/dist/components/SheetWaiting.d.ts +7 -0
  135. package/dist/components/SheetWaiting.js +88 -0
  136. package/dist/hooks/use-native-platform.d.ts +10 -0
  137. package/dist/hooks/use-native-platform.js +71 -0
  138. package/dist/hooks/use-payment-sheet.d.ts +4 -0
  139. package/dist/hooks/use-payment-sheet.js +10 -0
  140. package/dist/hooks/use-shake.d.ts +3 -0
  141. package/dist/hooks/use-shake.js +18 -0
  142. package/dist/hooks/use-sheet-motion.d.ts +7 -0
  143. package/dist/hooks/use-sheet-motion.js +62 -0
  144. package/dist/hooks/use-sheet-resize.d.ts +6 -0
  145. package/dist/hooks/use-sheet-resize.js +15 -0
  146. package/dist/hooks/use-sheet-room.d.ts +4 -0
  147. package/dist/hooks/use-sheet-room.js +8 -0
  148. package/dist/hooks/use-sheet-theme.d.ts +4 -0
  149. package/dist/hooks/use-sheet-theme.js +12 -0
  150. package/dist/hooks/use-step-slide.d.ts +16 -0
  151. package/dist/hooks/use-step-slide.js +50 -0
  152. package/dist/hooks/use-store-recovery.d.ts +9 -0
  153. package/dist/hooks/use-store-recovery.js +50 -0
  154. package/dist/hooks/use-store-tab.d.ts +11 -0
  155. package/dist/hooks/use-store-tab.js +112 -0
  156. package/dist/index.d.ts +3 -0
  157. package/dist/index.js +2 -0
  158. package/dist/models/sheet.constants.d.ts +125 -0
  159. package/dist/models/sheet.constants.js +204 -0
  160. package/dist/models/sheet.enum.d.ts +46 -0
  161. package/dist/models/sheet.enum.js +53 -0
  162. package/dist/models/sheet.interface.d.ts +426 -0
  163. package/dist/models/sheet.interface.js +1 -0
  164. package/dist/models/sheet.utils.d.ts +68 -0
  165. package/dist/models/sheet.utils.js +214 -0
  166. package/dist/services/checkout.service.d.ts +15 -0
  167. package/dist/services/checkout.service.js +96 -0
  168. package/dist/services/provider-window.service.d.ts +13 -0
  169. package/dist/services/provider-window.service.js +53 -0
  170. package/dist/services/store.service.d.ts +36 -0
  171. package/dist/services/store.service.js +107 -0
  172. package/package.json +73 -4
@@ -0,0 +1,101 @@
1
+ import { CheckoutThemeEnum, MethodFlowEnum } from './checkout.enum.js';
2
+ import { CountryEnum, CurrencyEnum, ProviderLogoEnum } from './domain.enum.js';
3
+ import type { BankRedirect, BrandTile, CheckoutColors, FlowTraits } from './checkout.interface.js';
4
+ /** The waiting screen gives the payer this long to approve on their phone. */
5
+ export declare const WAIT_SECONDS = 180;
6
+ /** The success screen sends the payer back to the app after this long. */
7
+ export declare const RETURN_SECONDS = 5;
8
+ /** The countdowns move once a second. */
9
+ export declare const TICK_MS = 1000;
10
+ export declare const TOAST_MS = 2400;
11
+ /** A lost open leaves a product payment unpriced: it is tried this many times, this far apart. */
12
+ export declare const OPEN_TRIES = 3;
13
+ export declare const OPEN_RETRY_MS = 2000;
14
+ export declare const COPIED_MS = 1800;
15
+ /** The last seconds of the waiting clock turn red. */
16
+ export declare const URGENT_SECONDS = 30;
17
+ /** A prompt can be sent again this long after the last one (the backend's `SEND_AGAIN_AFTER_MS`). */
18
+ export declare const SEND_AGAIN_SECONDS = 30;
19
+ /** The card fields' bones until their page says how tall it is, on the web and in the sheet. */
20
+ export declare const CARD_FIELDS_HEIGHT = 190;
21
+ /**
22
+ * The card fields page's height, at least, while PayPal's 3D Secure overlay
23
+ * shows in it (`CardFieldsMessageEnum.BANK_PAGE`): its bank page fits.
24
+ */
25
+ export declare const THREE_DS_HEIGHT = 640;
26
+ /** The only sides a brand tile is drawn at, in pixels: beside a line of text, in a list row, on the waiting screen. */
27
+ export declare const LOGO_SIZE: {
28
+ INLINE: number;
29
+ ROW: number;
30
+ HERO: number;
31
+ };
32
+ /** Corner radius of a brand tile, as a share of its side: the same curve at every size. */
33
+ export declare const LOGO_RADIUS_RATIO = 0.23;
34
+ /** Colour the page takes on the "invalid link" screen, which belongs to no app. */
35
+ export declare const INVALID_BRAND_LIGHT = "#111316";
36
+ export declare const INVALID_BRAND_DARK = "#4c515a";
37
+ /** Every image's 1px grey border, in both themes: `--media-line` of `src/styles.css`. */
38
+ export declare const MEDIA_LINE = "rgb(120 124 132 / 0.35)";
39
+ /**
40
+ * PayPal's own button: its gold and its ink, the same in both themes (its
41
+ * brand rules), as `--ck-paypal` and `--ck-paypal-ink` on the web.
42
+ */
43
+ export declare const PAYPAL_BUTTON_COLORS: {
44
+ gold: string;
45
+ ink: string;
46
+ };
47
+ /**
48
+ * The checkout's colours by theme, for the payment sheet, which has no
49
+ * stylesheet. The web page's tokens in `src/features/checkout/checkout.css`
50
+ * are the source: a test keeps the two equal.
51
+ */
52
+ export declare const CHECKOUT_COLORS: Record<CheckoutThemeEnum, CheckoutColors>;
53
+ /** International dial code of each country the gateway serves. */
54
+ export declare const DIAL_CODES: Record<Exclude<CountryEnum, CountryEnum.INTERNATIONAL>, string>;
55
+ /** The card tile: a generic card, whatever networks the provider takes. */
56
+ export declare const CARD_LOGO = ProviderLogoEnum.CARD;
57
+ /**
58
+ * The card networks taken (ADR 0013): Visa and Mastercard only. The one
59
+ * list for the backend's catalog and PayPal adapter, and the card fields.
60
+ */
61
+ export declare const CARD_NETWORKS: Array<BrandTile>;
62
+ /** Co-badged with Visa or Mastercard, never a network of its own (ADR 0014): Cartes Bancaires. */
63
+ export declare const CO_BADGED_LOGOS: Array<ProviderLogoEnum>;
64
+ /**
65
+ * The bank redirects (ADR 0014), the one list for the backend's catalog and
66
+ * PayPal provider, and the return page: each tile is also its method id,
67
+ * which the return page names the bank by. PayPal refuses less than 1 EUR
68
+ * for Bancontact and EPS.
69
+ */
70
+ export declare const BANK_REDIRECTS: Array<BankRedirect>;
71
+ /** PayPal's own window's tile, on top of its return page. */
72
+ export declare const PAYPAL_TILE: BrandTile;
73
+ /** The sample order the Branding tab's preview shows. */
74
+ export declare const PREVIEW_AMOUNT = 15000;
75
+ export declare const PREVIEW_ORDER_REF = "HY-20419";
76
+ /**
77
+ * GLOSSARY: Flow. What each way of approving changes, on both tiers: the one
78
+ * place a flow's behaviour is written. A new flow is one entry.
79
+ */
80
+ export declare const FLOW_TRAITS: Record<MethodFlowEnum, FlowTraits>;
81
+ /** The longest account holder's name PayPal takes on a bank redirect (`full_name`). */
82
+ export declare const FULL_NAME_MAX_LENGTH = 300;
83
+ /**
84
+ * Every assigned country, the one list in code (the gateway's and the
85
+ * checkout's): pairs of `alpha3 alpha2`. App Store Connect names a territory
86
+ * by its ISO 3166-1 alpha-3 code (`CMR`); Google Play and the payment sheet
87
+ * by alpha-2 (`CM`). Store prices are kept by alpha-2, a payment's country
88
+ * in lowercase (`cm`). Cloudflare's `XX` (unknown) and `T1` (Tor) are none.
89
+ */
90
+ export declare const COUNTRY_PAIRS = "\nABW AW AFG AF AGO AO AIA AI ALA AX ALB AL AND AD ARE AE ARG AR ARM AM ASM AS\nATA AQ ATF TF ATG AG AUS AU AUT AT AZE AZ BDI BI BEL BE BEN BJ BES BQ BFA BF\nBGD BD BGR BG BHR BH BHS BS BIH BA BLM BL BLR BY BLZ BZ BMU BM BOL BO BRA BR\nBRB BB BRN BN BTN BT BVT BV BWA BW CAF CF CAN CA CCK CC CHE CH CHL CL CHN CN\nCIV CI CMR CM COD CD COG CG COK CK COL CO COM KM CPV CV CRI CR CUB CU CUW CW\nCXR CX CYM KY CYP CY CZE CZ DEU DE DJI DJ DMA DM DNK DK DOM DO DZA DZ ECU EC\nEGY EG ERI ER ESH EH ESP ES EST EE ETH ET FIN FI FJI FJ FLK FK FRA FR FRO FO\nFSM FM GAB GA GBR GB GEO GE GGY GG GHA GH GIB GI GIN GN GLP GP GMB GM GNB GW\nGNQ GQ GRC GR GRD GD GRL GL GTM GT GUF GF GUM GU GUY GY HKG HK HMD HM HND HN\nHRV HR HTI HT HUN HU IDN ID IMN IM IND IN IOT IO IRL IE IRN IR IRQ IQ ISL IS\nISR IL ITA IT JAM JM JEY JE JOR JO JPN JP KAZ KZ KEN KE KGZ KG KHM KH KIR KI\nKNA KN KOR KR KWT KW LAO LA LBN LB LBR LR LBY LY LCA LC LIE LI LKA LK LSO LS\nLTU LT LUX LU LVA LV MAC MO MAF MF MAR MA MCO MC MDA MD MDG MG MDV MV MEX MX\nMHL MH MKD MK MLI ML MLT MT MMR MM MNE ME MNG MN MNP MP MOZ MZ MRT MR MSR MS\nMTQ MQ MUS MU MWI MW MYS MY MYT YT NAM NA NCL NC NER NE NFK NF NGA NG NIC NI\nNIU NU NLD NL NOR NO NPL NP NRU NR NZL NZ OMN OM PAK PK PAN PA PCN PN PER PE\nPHL PH PLW PW PNG PG POL PL PRI PR PRK KP PRT PT PRY PY PSE PS PYF PF QAT QA\nREU RE ROU RO RUS RU RWA RW SAU SA SDN SD SEN SN SGP SG SGS GS SHN SH SJM SJ\nSLB SB SLE SL SLV SV SMR SM SOM SO SPM PM SRB RS SSD SS STP ST SUR SR SVK SK\nSVN SI SWE SE SWZ SZ SXM SX SYC SC SYR SY TCA TC TCD TD TGO TG THA TH TJK TJ\nTKL TK TKM TM TLS TL TON TO TTO TT TUN TN TUR TR TUV TV TWN TW TZA TZ UGA UG\nUKR UA UMI UM URY UY USA US UZB UZ VAT VA VCT VC VEN VE VGB VG VIR VI VNM VN\nVUT VU WLF WF WSM WS XKS XK YEM YE ZAF ZA ZMB ZM ZWE ZW\n";
91
+ /** A one-time payment code: networks send 4 to 8 digits (the backend's rule). */
92
+ export declare const OTP_MAX_LENGTH = 8;
93
+ export declare const OTP_PATTERN: RegExp;
94
+ /** A test number ending like this gets no answer from the Simulator on start (the backend's). */
95
+ export declare const SIMULATOR_NO_ANSWER_SUFFIX = "0408";
96
+ /** Digits after the decimal point: amounts travel in minor units. */
97
+ export declare const CURRENCY_DECIMALS: Record<CurrencyEnum, number>;
98
+ /** What follows the amount: francs CFA read the same in both zones. */
99
+ export declare const CURRENCY_LABEL: Record<CurrencyEnum, string>;
100
+ /** A gateway call past this is given up: a half-open socket must not hold the page or the sheet. */
101
+ export declare const CHECKOUT_CALL_TIMEOUT_MS = 20000;
@@ -0,0 +1,339 @@
1
+ import { CheckoutTabEnum, CheckoutThemeEnum, FlowAskEnum, MethodFlowEnum, MethodLineEnum, PayRouteEnum, SimulatorOutcomeEnum, } from "./checkout.enum.js";
2
+ import { CountryEnum, CurrencyEnum, PriceGroupEnum, ProviderLogoEnum, } from "./domain.enum.js";
3
+ /** The waiting screen gives the payer this long to approve on their phone. */
4
+ export const WAIT_SECONDS = 180;
5
+ /** The success screen sends the payer back to the app after this long. */
6
+ export const RETURN_SECONDS = 5;
7
+ /** The countdowns move once a second. */
8
+ export const TICK_MS = 1000;
9
+ export const TOAST_MS = 2400;
10
+ /** A lost open leaves a product payment unpriced: it is tried this many times, this far apart. */
11
+ export const OPEN_TRIES = 3;
12
+ export const OPEN_RETRY_MS = 2000;
13
+ export const COPIED_MS = 1800;
14
+ /** The last seconds of the waiting clock turn red. */
15
+ export const URGENT_SECONDS = 30;
16
+ /** A prompt can be sent again this long after the last one (the backend's `SEND_AGAIN_AFTER_MS`). */
17
+ export const SEND_AGAIN_SECONDS = 30;
18
+ /** The card fields' bones until their page says how tall it is, on the web and in the sheet. */
19
+ export const CARD_FIELDS_HEIGHT = 190;
20
+ /**
21
+ * The card fields page's height, at least, while PayPal's 3D Secure overlay
22
+ * shows in it (`CardFieldsMessageEnum.BANK_PAGE`): its bank page fits.
23
+ */
24
+ export const THREE_DS_HEIGHT = 640;
25
+ /** The only sides a brand tile is drawn at, in pixels: beside a line of text, in a list row, on the waiting screen. */
26
+ export const LOGO_SIZE = { INLINE: 20, ROW: 28, HERO: 56 };
27
+ /** Corner radius of a brand tile, as a share of its side: the same curve at every size. */
28
+ export const LOGO_RADIUS_RATIO = 0.23;
29
+ /** Colour the page takes on the "invalid link" screen, which belongs to no app. */
30
+ export const INVALID_BRAND_LIGHT = '#111316';
31
+ export const INVALID_BRAND_DARK = '#4c515a';
32
+ /** Every image's 1px grey border, in both themes: `--media-line` of `src/styles.css`. */
33
+ export const MEDIA_LINE = 'rgb(120 124 132 / 0.35)';
34
+ /**
35
+ * PayPal's own button: its gold and its ink, the same in both themes (its
36
+ * brand rules), as `--ck-paypal` and `--ck-paypal-ink` on the web.
37
+ */
38
+ export const PAYPAL_BUTTON_COLORS = { gold: '#ffc439', ink: '#2c2e2f' };
39
+ /**
40
+ * The checkout's colours by theme, for the payment sheet, which has no
41
+ * stylesheet. The web page's tokens in `src/features/checkout/checkout.css`
42
+ * are the source: a test keeps the two equal.
43
+ */
44
+ export const CHECKOUT_COLORS = {
45
+ [CheckoutThemeEnum.LIGHT]: {
46
+ page: '#f2f2f4',
47
+ surface: '#ffffff',
48
+ tabOn: '#ffffff',
49
+ fill: '#efeff0',
50
+ fill2: '#f6f6f7',
51
+ fill3: '#e6e6e8',
52
+ ink: '#111316',
53
+ inkStrong: '#2b2e33',
54
+ ink2: '#474b53',
55
+ muted: '#6b7079',
56
+ faint: '#9b9fa6',
57
+ line: '#ececee',
58
+ line2: '#e3e4e6',
59
+ line3: '#d6d7da',
60
+ line4: '#c4c6ca',
61
+ danger: '#b42318',
62
+ dangerSoft: '#fdeceb',
63
+ warnSoft: '#fff3c4',
64
+ warnLine: '#f0dc8a',
65
+ warnInk: '#8a5a00',
66
+ warnInk2: '#5c4400',
67
+ successInk: '#12784f',
68
+ },
69
+ [CheckoutThemeEnum.DARK]: {
70
+ page: '#0c0d0f',
71
+ surface: '#16181b',
72
+ tabOn: '#2a2d33',
73
+ fill: '#202227',
74
+ fill2: '#1d1f23',
75
+ fill3: '#2a2d33',
76
+ ink: '#f2f3f5',
77
+ inkStrong: '#e4e6ea',
78
+ ink2: '#c3c7ce',
79
+ muted: '#9a9fa9',
80
+ faint: '#6f7580',
81
+ line: '#25282d',
82
+ line2: '#2e3137',
83
+ line3: '#3b3f46',
84
+ line4: '#4c515a',
85
+ danger: '#ff8a80',
86
+ dangerSoft: '#3a1a18',
87
+ warnSoft: '#352c10',
88
+ warnLine: '#5a4a1a',
89
+ warnInk: '#e8b65a',
90
+ warnInk2: '#f0d27a',
91
+ successInk: '#5fd6a2',
92
+ },
93
+ };
94
+ /** International dial code of each country the gateway serves. */
95
+ export const DIAL_CODES = {
96
+ [CountryEnum.CAMEROON]: '237',
97
+ [CountryEnum.COTE_D_IVOIRE]: '225',
98
+ [CountryEnum.SENEGAL]: '221',
99
+ [CountryEnum.BENIN]: '229',
100
+ [CountryEnum.TOGO]: '228',
101
+ [CountryEnum.BURKINA_FASO]: '226',
102
+ [CountryEnum.DR_CONGO]: '243',
103
+ [CountryEnum.CONGO]: '242',
104
+ [CountryEnum.GABON]: '241',
105
+ [CountryEnum.GHANA]: '233',
106
+ [CountryEnum.MALAWI]: '265',
107
+ [CountryEnum.RWANDA]: '250',
108
+ [CountryEnum.SIERRA_LEONE]: '232',
109
+ [CountryEnum.UGANDA]: '256',
110
+ [CountryEnum.ZAMBIA]: '260',
111
+ [CountryEnum.BELGIUM]: '32',
112
+ [CountryEnum.NETHERLANDS]: '31',
113
+ [CountryEnum.AUSTRIA]: '43',
114
+ [CountryEnum.ITALY]: '39',
115
+ };
116
+ /** The card tile: a generic card, whatever networks the provider takes. */
117
+ export const CARD_LOGO = ProviderLogoEnum.CARD;
118
+ /**
119
+ * The card networks taken (ADR 0013): Visa and Mastercard only. The one
120
+ * list for the backend's catalog and PayPal adapter, and the card fields.
121
+ */
122
+ export const CARD_NETWORKS = [
123
+ { logo: ProviderLogoEnum.VISA, name: 'Visa' },
124
+ { logo: ProviderLogoEnum.MASTERCARD, name: 'Mastercard' },
125
+ ];
126
+ /** Co-badged with Visa or Mastercard, never a network of its own (ADR 0014): Cartes Bancaires. */
127
+ export const CO_BADGED_LOGOS = [ProviderLogoEnum.CB];
128
+ /**
129
+ * The bank redirects (ADR 0014), the one list for the backend's catalog and
130
+ * PayPal provider, and the return page: each tile is also its method id,
131
+ * which the return page names the bank by. PayPal refuses less than 1 EUR
132
+ * for Bancontact and EPS.
133
+ */
134
+ export const BANK_REDIRECTS = [
135
+ {
136
+ logo: ProviderLogoEnum.BANCONTACT,
137
+ name: 'Bancontact',
138
+ country: CountryEnum.BELGIUM,
139
+ minAmount: 100,
140
+ },
141
+ {
142
+ logo: ProviderLogoEnum.IDEAL,
143
+ name: 'iDEAL',
144
+ country: CountryEnum.NETHERLANDS,
145
+ },
146
+ {
147
+ logo: ProviderLogoEnum.EPS,
148
+ name: 'EPS',
149
+ country: CountryEnum.AUSTRIA,
150
+ minAmount: 100,
151
+ },
152
+ { logo: ProviderLogoEnum.MYBANK, name: 'MyBank', country: CountryEnum.ITALY },
153
+ ];
154
+ /** PayPal's own window's tile, on top of its return page. */
155
+ export const PAYPAL_TILE = {
156
+ logo: ProviderLogoEnum.PAYPAL,
157
+ name: 'PayPal',
158
+ };
159
+ /** The sample order the Branding tab's preview shows. */
160
+ export const PREVIEW_AMOUNT = 15000;
161
+ export const PREVIEW_ORDER_REF = 'HY-20419';
162
+ /** No account, PIN or code of ours behind it: a card, PayPal or a bank. */
163
+ const NO_ACCOUNT_OUTCOMES = [
164
+ SimulatorOutcomeEnum.NO_ACCOUNT,
165
+ SimulatorOutcomeEnum.WRONG_PIN,
166
+ SimulatorOutcomeEnum.WRONG_CODE,
167
+ ];
168
+ /**
169
+ * GLOSSARY: Flow. What each way of approving changes, on both tiers: the one
170
+ * place a flow's behaviour is written. A new flow is one entry.
171
+ */
172
+ export const FLOW_TRAITS = {
173
+ [MethodFlowEnum.USSD_PUSH]: {
174
+ route: PayRouteEnum.PROMPT,
175
+ asks: [FlowAskEnum.PHONE],
176
+ tab: CheckoutTabEnum.MOBILE_MONEY,
177
+ prompt: true,
178
+ clock: true,
179
+ providerWindow: false,
180
+ priceGroup: PriceGroupEnum.MOBILE_MONEY,
181
+ countryScheme: false,
182
+ line: MethodLineEnum.NETWORK,
183
+ ownButton: false,
184
+ genericTile: false,
185
+ returnFinal: false,
186
+ hiddenOutcomes: [SimulatorOutcomeEnum.WRONG_CODE],
187
+ },
188
+ [MethodFlowEnum.OTP]: {
189
+ route: PayRouteEnum.CODE,
190
+ asks: [FlowAskEnum.PHONE, FlowAskEnum.CODE],
191
+ tab: CheckoutTabEnum.MOBILE_MONEY,
192
+ prompt: false,
193
+ clock: true,
194
+ providerWindow: false,
195
+ priceGroup: PriceGroupEnum.MOBILE_MONEY,
196
+ countryScheme: false,
197
+ line: MethodLineEnum.NETWORK,
198
+ ownButton: false,
199
+ genericTile: false,
200
+ returnFinal: false,
201
+ hiddenOutcomes: [SimulatorOutcomeEnum.WRONG_PIN],
202
+ },
203
+ // The card is typed in its provider's fields, the tile is the generic card's.
204
+ [MethodFlowEnum.CARD_FIELDS]: {
205
+ route: PayRouteEnum.CARD,
206
+ asks: [FlowAskEnum.CARD],
207
+ tab: CheckoutTabEnum.CARD,
208
+ prompt: false,
209
+ clock: true,
210
+ providerWindow: false,
211
+ priceGroup: PriceGroupEnum.CARD,
212
+ countryScheme: false,
213
+ line: MethodLineEnum.NETWORK,
214
+ ownButton: false,
215
+ genericTile: true,
216
+ returnFinal: false,
217
+ hiddenOutcomes: NO_ACCOUNT_OUTCOMES,
218
+ },
219
+ // Approved in PayPal's own page, opened by its own button: it asks for everything.
220
+ [MethodFlowEnum.PAYPAL]: {
221
+ route: PayRouteEnum.PAYPAL,
222
+ asks: [],
223
+ tab: CheckoutTabEnum.CARD,
224
+ prompt: false,
225
+ clock: false,
226
+ providerWindow: true,
227
+ priceGroup: PriceGroupEnum.PAYPAL,
228
+ countryScheme: false,
229
+ line: MethodLineEnum.CHARGED_IN,
230
+ ownButton: true,
231
+ genericTile: false,
232
+ returnFinal: false,
233
+ hiddenOutcomes: NO_ACCOUNT_OUTCOMES,
234
+ },
235
+ // Approved on the bank's page, through PayPal's sandbox in Test, in the account holder's name (ADR 0014).
236
+ [MethodFlowEnum.BANK_REDIRECT]: {
237
+ route: PayRouteEnum.BANK,
238
+ asks: [FlowAskEnum.NAME],
239
+ tab: CheckoutTabEnum.CARD,
240
+ prompt: false,
241
+ clock: false,
242
+ providerWindow: true,
243
+ priceGroup: PriceGroupEnum.PAYPAL,
244
+ countryScheme: true,
245
+ line: MethodLineEnum.COUNTRY,
246
+ ownButton: false,
247
+ genericTile: false,
248
+ returnFinal: true,
249
+ hiddenOutcomes: NO_ACCOUNT_OUTCOMES,
250
+ },
251
+ // The store's sheet, priced by the store; its sandbox answers, never the Simulator.
252
+ [MethodFlowEnum.STORE]: {
253
+ route: PayRouteEnum.STORE,
254
+ asks: [],
255
+ tab: CheckoutTabEnum.STORE,
256
+ prompt: false,
257
+ clock: false,
258
+ providerWindow: false,
259
+ priceGroup: null,
260
+ countryScheme: false,
261
+ line: MethodLineEnum.NETWORK,
262
+ ownButton: false,
263
+ genericTile: false,
264
+ returnFinal: false,
265
+ hiddenOutcomes: Object.values(SimulatorOutcomeEnum),
266
+ },
267
+ };
268
+ /** The longest account holder's name PayPal takes on a bank redirect (`full_name`). */
269
+ export const FULL_NAME_MAX_LENGTH = 300;
270
+ /**
271
+ * Every assigned country, the one list in code (the gateway's and the
272
+ * checkout's): pairs of `alpha3 alpha2`. App Store Connect names a territory
273
+ * by its ISO 3166-1 alpha-3 code (`CMR`); Google Play and the payment sheet
274
+ * by alpha-2 (`CM`). Store prices are kept by alpha-2, a payment's country
275
+ * in lowercase (`cm`). Cloudflare's `XX` (unknown) and `T1` (Tor) are none.
276
+ */
277
+ export const COUNTRY_PAIRS = `
278
+ ABW AW AFG AF AGO AO AIA AI ALA AX ALB AL AND AD ARE AE ARG AR ARM AM ASM AS
279
+ ATA AQ ATF TF ATG AG AUS AU AUT AT AZE AZ BDI BI BEL BE BEN BJ BES BQ BFA BF
280
+ BGD BD BGR BG BHR BH BHS BS BIH BA BLM BL BLR BY BLZ BZ BMU BM BOL BO BRA BR
281
+ BRB BB BRN BN BTN BT BVT BV BWA BW CAF CF CAN CA CCK CC CHE CH CHL CL CHN CN
282
+ CIV CI CMR CM COD CD COG CG COK CK COL CO COM KM CPV CV CRI CR CUB CU CUW CW
283
+ CXR CX CYM KY CYP CY CZE CZ DEU DE DJI DJ DMA DM DNK DK DOM DO DZA DZ ECU EC
284
+ EGY EG ERI ER ESH EH ESP ES EST EE ETH ET FIN FI FJI FJ FLK FK FRA FR FRO FO
285
+ FSM FM GAB GA GBR GB GEO GE GGY GG GHA GH GIB GI GIN GN GLP GP GMB GM GNB GW
286
+ GNQ GQ GRC GR GRD GD GRL GL GTM GT GUF GF GUM GU GUY GY HKG HK HMD HM HND HN
287
+ HRV HR HTI HT HUN HU IDN ID IMN IM IND IN IOT IO IRL IE IRN IR IRQ IQ ISL IS
288
+ ISR IL ITA IT JAM JM JEY JE JOR JO JPN JP KAZ KZ KEN KE KGZ KG KHM KH KIR KI
289
+ KNA KN KOR KR KWT KW LAO LA LBN LB LBR LR LBY LY LCA LC LIE LI LKA LK LSO LS
290
+ LTU LT LUX LU LVA LV MAC MO MAF MF MAR MA MCO MC MDA MD MDG MG MDV MV MEX MX
291
+ MHL MH MKD MK MLI ML MLT MT MMR MM MNE ME MNG MN MNP MP MOZ MZ MRT MR MSR MS
292
+ MTQ MQ MUS MU MWI MW MYS MY MYT YT NAM NA NCL NC NER NE NFK NF NGA NG NIC NI
293
+ NIU NU NLD NL NOR NO NPL NP NRU NR NZL NZ OMN OM PAK PK PAN PA PCN PN PER PE
294
+ PHL PH PLW PW PNG PG POL PL PRI PR PRK KP PRT PT PRY PY PSE PS PYF PF QAT QA
295
+ REU RE ROU RO RUS RU RWA RW SAU SA SDN SD SEN SN SGP SG SGS GS SHN SH SJM SJ
296
+ SLB SB SLE SL SLV SV SMR SM SOM SO SPM PM SRB RS SSD SS STP ST SUR SR SVK SK
297
+ SVN SI SWE SE SWZ SZ SXM SX SYC SC SYR SY TCA TC TCD TD TGO TG THA TH TJK TJ
298
+ TKL TK TKM TM TLS TL TON TO TTO TT TUN TN TUR TR TUV TV TWN TW TZA TZ UGA UG
299
+ UKR UA UMI UM URY UY USA US UZB UZ VAT VA VCT VC VEN VE VGB VG VIR VI VNM VN
300
+ VUT VU WLF WF WSM WS XKS XK YEM YE ZAF ZA ZMB ZM ZWE ZW
301
+ `;
302
+ /** A one-time payment code: networks send 4 to 8 digits (the backend's rule). */
303
+ export const OTP_MAX_LENGTH = 8;
304
+ export const OTP_PATTERN = new RegExp(`^\\d{4,${OTP_MAX_LENGTH}}$`);
305
+ /** A test number ending like this gets no answer from the Simulator on start (the backend's). */
306
+ export const SIMULATOR_NO_ANSWER_SUFFIX = '0408';
307
+ /** Digits after the decimal point: amounts travel in minor units. */
308
+ export const CURRENCY_DECIMALS = {
309
+ [CurrencyEnum.XAF]: 0,
310
+ [CurrencyEnum.XOF]: 0,
311
+ [CurrencyEnum.EUR]: 2,
312
+ [CurrencyEnum.USD]: 2,
313
+ [CurrencyEnum.GHS]: 2,
314
+ [CurrencyEnum.MWK]: 2,
315
+ [CurrencyEnum.UGX]: 0,
316
+ // Whole units, not ISO's two: Vodacom refuses decimals.
317
+ [CurrencyEnum.CDF]: 0,
318
+ [CurrencyEnum.SLE]: 2,
319
+ [CurrencyEnum.RWF]: 0,
320
+ [CurrencyEnum.ZMW]: 2,
321
+ [CurrencyEnum.CAD]: 2,
322
+ };
323
+ /** What follows the amount: francs CFA read the same in both zones. */
324
+ export const CURRENCY_LABEL = {
325
+ [CurrencyEnum.XAF]: 'FCFA',
326
+ [CurrencyEnum.XOF]: 'FCFA',
327
+ [CurrencyEnum.EUR]: 'EUR',
328
+ [CurrencyEnum.USD]: 'USD',
329
+ [CurrencyEnum.GHS]: 'GHS',
330
+ [CurrencyEnum.MWK]: 'MWK',
331
+ [CurrencyEnum.UGX]: 'UGX',
332
+ [CurrencyEnum.CDF]: 'CDF',
333
+ [CurrencyEnum.SLE]: 'SLE',
334
+ [CurrencyEnum.RWF]: 'RWF',
335
+ [CurrencyEnum.ZMW]: 'ZMW',
336
+ [CurrencyEnum.CAD]: 'CAD',
337
+ };
338
+ /** A gateway call past this is given up: a half-open socket must not hold the page or the sheet. */
339
+ export const CHECKOUT_CALL_TIMEOUT_MS = 20_000;
@@ -0,0 +1,17 @@
1
+ import type { CountryEnum } from './domain.enum.js';
2
+ import type { CheckoutUi, CheckoutView, CountryClues } from './checkout.interface.js';
3
+ /** The alpha-2 code of an App Store territory, named by its alpha-3 id (`CMR` → `CM`); null for none. */
4
+ export declare function alpha2OfTerritory(territory: string): string | null;
5
+ /**
6
+ * A country code in any case (`BE`, ` be `) as kept, lowercase; null for
7
+ * what is no country: Cloudflare's `XX` and `T1`, a region like `419`.
8
+ */
9
+ export declare function countryCodeOf(raw: string | null | undefined): string | null;
10
+ /** The country whose dial code starts this E.164 number. */
11
+ export declare function countryOfPhone(phone: string): CountryEnum | null;
12
+ /**
13
+ * The payer country (GLOSSARY): the one the app sent, else guessed from the
14
+ * phone's dial code, then the request's IP, then the browser's language
15
+ * (`fr-CM`). Any country, with Mobile Money or not; null when no clue names one.
16
+ */
17
+ export declare function payerCountryOf(view: Pick<CheckoutView, 'country' | 'payer'>, clues: CountryClues): Pick<CheckoutUi, 'payerCountry' | 'countrySent'>;
@@ -0,0 +1,45 @@
1
+ import { COUNTRY_PAIRS, DIAL_CODES } from "./checkout.constants.js";
2
+ /** `COUNTRY_PAIRS` (the one list), split once: `alpha3 alpha2` pairs. */
3
+ const PAIRS = COUNTRY_PAIRS.trim().split(/\s+/);
4
+ /** Each country's alpha-2 code, by its alpha-3 one (`CMR` → `CM`). */
5
+ const ALPHA2_OF_ALPHA3 = new Map(Array.from({ length: PAIRS.length / 2 }, (_, index) => [
6
+ PAIRS[index * 2],
7
+ PAIRS[index * 2 + 1],
8
+ ]));
9
+ /** Each country's alpha-2 code, lowercase (`cm`, `be`). */
10
+ const COUNTRY_CODES = new Set([...ALPHA2_OF_ALPHA3.values()].map((code) => code.toLowerCase()));
11
+ /** The alpha-2 code of an App Store territory, named by its alpha-3 id (`CMR` → `CM`); null for none. */
12
+ export function alpha2OfTerritory(territory) {
13
+ return ALPHA2_OF_ALPHA3.get(territory) ?? null;
14
+ }
15
+ /**
16
+ * A country code in any case (`BE`, ` be `) as kept, lowercase; null for
17
+ * what is no country: Cloudflare's `XX` and `T1`, a region like `419`.
18
+ */
19
+ export function countryCodeOf(raw) {
20
+ const code = raw?.trim().toLowerCase() ?? '';
21
+ return COUNTRY_CODES.has(code) ? code : null;
22
+ }
23
+ /** The country whose dial code starts this E.164 number. */
24
+ export function countryOfPhone(phone) {
25
+ const found = Object.entries(DIAL_CODES).find(([, dial]) => phone.startsWith(`+${dial}`));
26
+ return found ? found[0] : null;
27
+ }
28
+ /**
29
+ * The payer country (GLOSSARY): the one the app sent, else guessed from the
30
+ * phone's dial code, then the request's IP, then the browser's language
31
+ * (`fr-CM`). Any country, with Mobile Money or not; null when no clue names one.
32
+ */
33
+ export function payerCountryOf(view, clues) {
34
+ if (view.country)
35
+ return { payerCountry: view.country, countrySent: true };
36
+ const guesses = [
37
+ view.payer.phone ? countryOfPhone(view.payer.phone) : null,
38
+ countryCodeOf(clues.ipCountry),
39
+ ...clues.languages.map((tag) => countryCodeOf(tag.split('-')[1])),
40
+ ];
41
+ return {
42
+ payerCountry: guesses.find((guess) => !!guess) ?? null,
43
+ countrySent: false,
44
+ };
45
+ }