@brissoto/pay-react-native 0.0.0-stage → 1.4.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.
Files changed (172) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +180 -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 +297 -0
  47. package/dist/checkout-core/messages/en.js +296 -0
  48. package/dist/checkout-core/messages/fr.d.ts +4 -0
  49. package/dist/checkout-core/messages/fr.js +297 -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 +230 -0
  57. package/dist/checkout-core/models/checkout.enum.js +256 -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 +696 -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 +328 -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 +132 -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 +139 -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 +3 -0
  129. package/dist/components/SheetTerminal.js +21 -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 +423 -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 +211 -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,106 @@
1
+ /** Domain enums the checkout core needs; `src/models` re-exports them for the rest of the app. */
2
+ /** Values are the file names in `public/logo/`, without the extension. */
3
+ /** A brand tile in `public/logo/`: one per brand a payer recognises (see `docs/design-system.md`, Logos). */
4
+ export declare enum ProviderLogoEnum {
5
+ ORANGE = "orange",
6
+ MTN = "mtn",
7
+ MOOV = "moov",
8
+ WAVE = "wave",
9
+ MIXX = "mixx",
10
+ AIRTEL = "airtel",
11
+ AT = "at",
12
+ TELECEL = "telecel",
13
+ TNM = "tnm",
14
+ VODACOM = "vodacom",
15
+ CELTIIS = "celtiis",
16
+ NEXUS = "nexus",
17
+ PAWAPAY = "pawapay",
18
+ FEEXPAY = "feexpay",
19
+ IAPKIT = "iapkit",
20
+ APP_STORE = "app-store",
21
+ GOOGLE_PLAY = "google-play",
22
+ VISA = "visa",
23
+ MASTERCARD = "mastercard",
24
+ PAYPAL = "paypal",
25
+ CARD = "card",
26
+ /** Cartes Bancaires, co-badged on Visa and Mastercard cards. */
27
+ CB = "cb",
28
+ BANCONTACT = "bancontact",
29
+ IDEAL = "ideal",
30
+ EPS = "eps",
31
+ MYBANK = "mybank",
32
+ APPLE_PAY = "apple-pay",
33
+ GOOGLE_PAY = "google-pay"
34
+ }
35
+ /** Declared in the order the Providers page lists its country groups. */
36
+ export declare enum CountryEnum {
37
+ CAMEROON = "cm",
38
+ COTE_D_IVOIRE = "ci",
39
+ SENEGAL = "sn",
40
+ BENIN = "bj",
41
+ TOGO = "tg",
42
+ BURKINA_FASO = "bf",
43
+ DR_CONGO = "cd",
44
+ CONGO = "cg",
45
+ GABON = "ga",
46
+ GHANA = "gh",
47
+ MALAWI = "mw",
48
+ RWANDA = "rw",
49
+ SIERRA_LEONE = "sl",
50
+ UGANDA = "ug",
51
+ ZAMBIA = "zm",
52
+ /** The bank redirects' (ADR 0014). */
53
+ BELGIUM = "be",
54
+ NETHERLANDS = "nl",
55
+ AUSTRIA = "at",
56
+ ITALY = "it",
57
+ INTERNATIONAL = "intl"
58
+ }
59
+ export declare enum CurrencyEnum {
60
+ XAF = "XAF",
61
+ XOF = "XOF",
62
+ EUR = "EUR",
63
+ USD = "USD",
64
+ GHS = "GHS",
65
+ MWK = "MWK",
66
+ UGX = "UGX",
67
+ CDF = "CDF",
68
+ SLE = "SLE",
69
+ RWF = "RWF",
70
+ ZMW = "ZMW",
71
+ CAD = "CAD"
72
+ }
73
+ /** Why an attempt failed. The first six are the payer's and count toward the lock. */
74
+ export declare enum FailureReasonEnum {
75
+ DECLINED = "declined",
76
+ INSUFFICIENT_FUNDS = "insufficient_funds",
77
+ /** No mobile money account on this number. */
78
+ NO_ACCOUNT = "no_account",
79
+ WRONG_PIN = "wrong_pin",
80
+ /** An OTP method: the payment code was wrong or had expired. */
81
+ WRONG_CODE = "wrong_code",
82
+ /** A card: its issuer refused a number, expiry date or security code that does not match it. */
83
+ WRONG_CARD_DETAILS = "wrong_card_details",
84
+ PROVIDER_ERROR = "provider_error",
85
+ TIMEOUT = "timeout",
86
+ MISMATCH = "mismatch",
87
+ /** A store's sheet closed with nothing bought: the form shows again, no failure. */
88
+ CANCELLED = "cancelled"
89
+ }
90
+ /** GLOSSARY: Attempt. */
91
+ export declare enum AttemptStatusEnum {
92
+ PENDING = "pending",
93
+ SUCCEEDED = "succeeded",
94
+ FAILED = "failed"
95
+ }
96
+ /** Interface languages. Values are the URL prefix and the saved cookie value. */
97
+ export declare enum LangEnum {
98
+ FR = "fr",
99
+ EN = "en"
100
+ }
101
+ /** GLOSSARY: Price. The payment methods one price is for. */
102
+ export declare enum PriceGroupEnum {
103
+ MOBILE_MONEY = "mobile_money",
104
+ CARD = "card",
105
+ PAYPAL = "paypal"
106
+ }
@@ -0,0 +1,113 @@
1
+ /** Domain enums the checkout core needs; `src/models` re-exports them for the rest of the app. */
2
+ /** Values are the file names in `public/logo/`, without the extension. */
3
+ /** A brand tile in `public/logo/`: one per brand a payer recognises (see `docs/design-system.md`, Logos). */
4
+ export var ProviderLogoEnum;
5
+ (function (ProviderLogoEnum) {
6
+ ProviderLogoEnum["ORANGE"] = "orange";
7
+ ProviderLogoEnum["MTN"] = "mtn";
8
+ ProviderLogoEnum["MOOV"] = "moov";
9
+ ProviderLogoEnum["WAVE"] = "wave";
10
+ ProviderLogoEnum["MIXX"] = "mixx";
11
+ ProviderLogoEnum["AIRTEL"] = "airtel";
12
+ ProviderLogoEnum["AT"] = "at";
13
+ ProviderLogoEnum["TELECEL"] = "telecel";
14
+ ProviderLogoEnum["TNM"] = "tnm";
15
+ ProviderLogoEnum["VODACOM"] = "vodacom";
16
+ ProviderLogoEnum["CELTIIS"] = "celtiis";
17
+ ProviderLogoEnum["NEXUS"] = "nexus";
18
+ ProviderLogoEnum["PAWAPAY"] = "pawapay";
19
+ ProviderLogoEnum["FEEXPAY"] = "feexpay";
20
+ ProviderLogoEnum["IAPKIT"] = "iapkit";
21
+ ProviderLogoEnum["APP_STORE"] = "app-store";
22
+ ProviderLogoEnum["GOOGLE_PLAY"] = "google-play";
23
+ ProviderLogoEnum["VISA"] = "visa";
24
+ ProviderLogoEnum["MASTERCARD"] = "mastercard";
25
+ ProviderLogoEnum["PAYPAL"] = "paypal";
26
+ ProviderLogoEnum["CARD"] = "card";
27
+ /** Cartes Bancaires, co-badged on Visa and Mastercard cards. */
28
+ ProviderLogoEnum["CB"] = "cb";
29
+ ProviderLogoEnum["BANCONTACT"] = "bancontact";
30
+ ProviderLogoEnum["IDEAL"] = "ideal";
31
+ ProviderLogoEnum["EPS"] = "eps";
32
+ ProviderLogoEnum["MYBANK"] = "mybank";
33
+ ProviderLogoEnum["APPLE_PAY"] = "apple-pay";
34
+ ProviderLogoEnum["GOOGLE_PAY"] = "google-pay";
35
+ })(ProviderLogoEnum || (ProviderLogoEnum = {}));
36
+ /** Declared in the order the Providers page lists its country groups. */
37
+ export var CountryEnum;
38
+ (function (CountryEnum) {
39
+ CountryEnum["CAMEROON"] = "cm";
40
+ CountryEnum["COTE_D_IVOIRE"] = "ci";
41
+ CountryEnum["SENEGAL"] = "sn";
42
+ CountryEnum["BENIN"] = "bj";
43
+ CountryEnum["TOGO"] = "tg";
44
+ CountryEnum["BURKINA_FASO"] = "bf";
45
+ CountryEnum["DR_CONGO"] = "cd";
46
+ CountryEnum["CONGO"] = "cg";
47
+ CountryEnum["GABON"] = "ga";
48
+ CountryEnum["GHANA"] = "gh";
49
+ CountryEnum["MALAWI"] = "mw";
50
+ CountryEnum["RWANDA"] = "rw";
51
+ CountryEnum["SIERRA_LEONE"] = "sl";
52
+ CountryEnum["UGANDA"] = "ug";
53
+ CountryEnum["ZAMBIA"] = "zm";
54
+ /** The bank redirects' (ADR 0014). */
55
+ CountryEnum["BELGIUM"] = "be";
56
+ CountryEnum["NETHERLANDS"] = "nl";
57
+ CountryEnum["AUSTRIA"] = "at";
58
+ CountryEnum["ITALY"] = "it";
59
+ CountryEnum["INTERNATIONAL"] = "intl";
60
+ })(CountryEnum || (CountryEnum = {}));
61
+ export var CurrencyEnum;
62
+ (function (CurrencyEnum) {
63
+ CurrencyEnum["XAF"] = "XAF";
64
+ CurrencyEnum["XOF"] = "XOF";
65
+ CurrencyEnum["EUR"] = "EUR";
66
+ CurrencyEnum["USD"] = "USD";
67
+ CurrencyEnum["GHS"] = "GHS";
68
+ CurrencyEnum["MWK"] = "MWK";
69
+ CurrencyEnum["UGX"] = "UGX";
70
+ CurrencyEnum["CDF"] = "CDF";
71
+ CurrencyEnum["SLE"] = "SLE";
72
+ CurrencyEnum["RWF"] = "RWF";
73
+ CurrencyEnum["ZMW"] = "ZMW";
74
+ CurrencyEnum["CAD"] = "CAD";
75
+ })(CurrencyEnum || (CurrencyEnum = {}));
76
+ /** Why an attempt failed. The first six are the payer's and count toward the lock. */
77
+ export var FailureReasonEnum;
78
+ (function (FailureReasonEnum) {
79
+ FailureReasonEnum["DECLINED"] = "declined";
80
+ FailureReasonEnum["INSUFFICIENT_FUNDS"] = "insufficient_funds";
81
+ /** No mobile money account on this number. */
82
+ FailureReasonEnum["NO_ACCOUNT"] = "no_account";
83
+ FailureReasonEnum["WRONG_PIN"] = "wrong_pin";
84
+ /** An OTP method: the payment code was wrong or had expired. */
85
+ FailureReasonEnum["WRONG_CODE"] = "wrong_code";
86
+ /** A card: its issuer refused a number, expiry date or security code that does not match it. */
87
+ FailureReasonEnum["WRONG_CARD_DETAILS"] = "wrong_card_details";
88
+ FailureReasonEnum["PROVIDER_ERROR"] = "provider_error";
89
+ FailureReasonEnum["TIMEOUT"] = "timeout";
90
+ FailureReasonEnum["MISMATCH"] = "mismatch";
91
+ /** A store's sheet closed with nothing bought: the form shows again, no failure. */
92
+ FailureReasonEnum["CANCELLED"] = "cancelled";
93
+ })(FailureReasonEnum || (FailureReasonEnum = {}));
94
+ /** GLOSSARY: Attempt. */
95
+ export var AttemptStatusEnum;
96
+ (function (AttemptStatusEnum) {
97
+ AttemptStatusEnum["PENDING"] = "pending";
98
+ AttemptStatusEnum["SUCCEEDED"] = "succeeded";
99
+ AttemptStatusEnum["FAILED"] = "failed";
100
+ })(AttemptStatusEnum || (AttemptStatusEnum = {}));
101
+ /** Interface languages. Values are the URL prefix and the saved cookie value. */
102
+ export var LangEnum;
103
+ (function (LangEnum) {
104
+ LangEnum["FR"] = "fr";
105
+ LangEnum["EN"] = "en";
106
+ })(LangEnum || (LangEnum = {}));
107
+ /** GLOSSARY: Price. The payment methods one price is for. */
108
+ export var PriceGroupEnum;
109
+ (function (PriceGroupEnum) {
110
+ PriceGroupEnum["MOBILE_MONEY"] = "mobile_money";
111
+ PriceGroupEnum["CARD"] = "card";
112
+ PriceGroupEnum["PAYPAL"] = "paypal";
113
+ })(PriceGroupEnum || (PriceGroupEnum = {}));
@@ -0,0 +1,8 @@
1
+ import type { BrissotoPayProviderProps } from '../models/sheet.interface.js';
2
+ /**
3
+ * Around the app: the calls to Brissoto Pay and the one payment sheet
4
+ * `usePaymentSheet().presentPayment` opens. Nothing stays connected: a
5
+ * sheet follows its payment live only while the payer waits on it. On
6
+ * start, store purchases the app never reported are sent again.
7
+ */
8
+ export declare function BrissotoPayProvider({ url, children, }: BrissotoPayProviderProps): import("react").JSX.Element;
@@ -0,0 +1,39 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useCallback, useMemo, useRef, useState } from 'react';
3
+ import { PaymentSheetContext } from "../hooks/use-payment-sheet.js";
4
+ import { useStoreRecovery } from "../hooks/use-store-recovery.js";
5
+ import { DEFAULT_URL } from "../models/sheet.constants.js";
6
+ import { convexCheckoutConnection, convexStoreRecovery, } from "../services/checkout.service.js";
7
+ import { PaymentSheetModal } from "./PaymentSheetModal.js";
8
+ /**
9
+ * Around the app: the calls to Brissoto Pay and the one payment sheet
10
+ * `usePaymentSheet().presentPayment` opens. Nothing stays connected: a
11
+ * sheet follows its payment live only while the payer waits on it. On
12
+ * start, store purchases the app never reported are sent again.
13
+ */
14
+ export function BrissotoPayProvider({ url = DEFAULT_URL, children, }) {
15
+ const connection = useMemo(() => convexCheckoutConnection(url), [url]);
16
+ const recovery = useMemo(() => convexStoreRecovery(url), [url]);
17
+ useStoreRecovery(recovery);
18
+ const [request, setRequest] = useState(null);
19
+ /** Sheets opened, so each gets a fresh one. */
20
+ const [count, setCount] = useState(0);
21
+ const busy = useRef(false);
22
+ const presentPayment = useCallback(({ paymentId }) => {
23
+ if (busy.current) {
24
+ return Promise.reject(new Error('A payment sheet is already open.'));
25
+ }
26
+ busy.current = true;
27
+ return new Promise((resolve) => {
28
+ setCount((previous) => previous + 1);
29
+ setRequest({ paymentId, open: true, resolve });
30
+ });
31
+ }, []);
32
+ const sheet = useMemo(() => ({ presentPayment }), [presentPayment]);
33
+ const close = (closing, result) => {
34
+ busy.current = false;
35
+ setRequest({ ...closing, open: false });
36
+ closing.resolve(result);
37
+ };
38
+ return (_jsxs(PaymentSheetContext, { value: sheet, children: [children, request && (_jsx(PaymentSheetModal, { connection: connection, request: request, onClose: (result) => close(request, result) }, count))] }));
39
+ }
@@ -0,0 +1,9 @@
1
+ import type { PaymentSheetModalProps } from '../models/sheet.interface.js';
2
+ /**
3
+ * One payment in a bottom sheet over the dimmed app, as tall as what it
4
+ * shows, in the payment's language and theme, else the device's. Close,
5
+ * a swipe down, a tap on the app behind, back or escape leave it; leaving
6
+ * while a prompt waits on the phone asks first, and resolves `pending`.
7
+ * Android's back on the details goes back to the methods instead.
8
+ */
9
+ export declare function PaymentSheetModal({ connection, request, onClose, }: PaymentSheetModalProps): import("react").JSX.Element;
@@ -0,0 +1,106 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useFonts } from 'expo-font';
3
+ import { useEffect, useMemo, useRef, useState } from 'react';
4
+ import { Alert, Animated, KeyboardAvoidingView, Modal, Pressable, StyleSheet, View, useColorScheme, } from 'react-native';
5
+ import { IntlProvider, createTranslator } from 'use-intl';
6
+ import { CHECKOUT_COLORS, INVALID_BRAND_DARK, INVALID_BRAND_LIGHT, } from "../checkout-core/models/checkout.constants.js";
7
+ import { useCheckoutPayment } from "../checkout-core/hooks/use-checkout-payment.js";
8
+ import { CheckoutThemeEnum } from "../checkout-core/models/checkout.enum.js";
9
+ import { useSheetMotion } from "../hooks/use-sheet-motion.js";
10
+ import { SheetThemeContext } from "../hooks/use-sheet-theme.js";
11
+ import { FIGTREE_FILES, MESSAGES, TIME_ZONE, } from "../models/sheet.constants.js";
12
+ import { sheetLanguage, sheetResult, sheetTheme, } from "../models/sheet.utils.js";
13
+ import { SheetContent } from "./SheetContent.js";
14
+ /**
15
+ * One payment in a bottom sheet over the dimmed app, as tall as what it
16
+ * shows, in the payment's language and theme, else the device's. Close,
17
+ * a swipe down, a tap on the app behind, back or escape leave it; leaving
18
+ * while a prompt waits on the phone asks first, and resolves `pending`.
19
+ * Android's back on the details goes back to the methods instead.
20
+ */
21
+ export function PaymentSheetModal({ connection, request, onClose, }) {
22
+ const payment = useCheckoutPayment(connection, request.open ? request.paymentId : null);
23
+ const { view } = payment;
24
+ const scheme = useColorScheme();
25
+ const [deviceLocale] = useState(() => Intl.DateTimeFormat().resolvedOptions().locale);
26
+ const [fontsLoaded, fontsError] = useFonts(FIGTREE_FILES);
27
+ /** Asked with the payment: `undefined` until the gateway answers. */
28
+ const [ipCountry, setIpCountry] = useState();
29
+ useEffect(() => {
30
+ void connection.ipCountry().then(setIpCountry);
31
+ }, [connection]);
32
+ const lang = sheetLanguage(view?.language ?? null, deviceLocale);
33
+ const dark = sheetTheme(view?.theme ?? null, scheme) === CheckoutThemeEnum.DARK;
34
+ const color = view?.app.color;
35
+ const theme = useMemo(() => ({
36
+ colors: CHECKOUT_COLORS[dark ? CheckoutThemeEnum.DARK : CheckoutThemeEnum.LIGHT],
37
+ brand: color ?? (dark ? INVALID_BRAND_DARK : INVALID_BRAND_LIGHT),
38
+ dark,
39
+ }), [dark, color]);
40
+ /** What the sheet last heard, for the close alert, which answers later. */
41
+ const latest = useRef({ view, failed: payment.failed });
42
+ useEffect(() => {
43
+ latest.current = { view, failed: payment.failed };
44
+ }, [view, payment.failed]);
45
+ /** Closed once: a second close, or a late tap on the alert, changes nothing. */
46
+ const closed = useRef(false);
47
+ const finish = (result) => {
48
+ closed.current = true;
49
+ onClose(result);
50
+ };
51
+ const close = () => {
52
+ if (closed.current)
53
+ return;
54
+ const result = sheetResult(view, payment.failed);
55
+ if (result.status !== 'pending') {
56
+ finish(result);
57
+ return;
58
+ }
59
+ // A prompt still waits: approved later, the payment goes through.
60
+ const t = createTranslator({
61
+ locale: lang,
62
+ messages: MESSAGES[lang],
63
+ namespace: 'checkout.sheet',
64
+ });
65
+ Alert.alert(t('close_title'), t('close_body'), [
66
+ { text: t('keep_waiting'), style: 'cancel' },
67
+ {
68
+ text: MESSAGES[lang].checkout.close,
69
+ style: 'destructive',
70
+ // Answered later: the payment may have gone through, or the sheet
71
+ // closed by itself, while the alert was up.
72
+ onPress: () => {
73
+ if (closed.current)
74
+ return;
75
+ finish(sheetResult(latest.current.view, latest.current.failed));
76
+ },
77
+ },
78
+ ]);
79
+ };
80
+ const motion = useSheetMotion(request.open, close);
81
+ const backRef = useRef(null);
82
+ return (_jsx(Modal, { testID: "payment-sheet-modal", visible: motion.shown, transparent: true, animationType: "none", statusBarTranslucent: true, onRequestClose: () => {
83
+ if (!backRef.current?.())
84
+ close();
85
+ }, children: _jsxs(View, { style: [styles.screen, !request.open && styles.leaving], children: [_jsx(Pressable, { testID: "payment-sheet-backdrop", accessible: false, onPress: close, style: StyleSheet.absoluteFill, children: _jsx(Animated.View, { style: [
86
+ StyleSheet.absoluteFill,
87
+ styles.dim,
88
+ { opacity: motion.dim },
89
+ ] }) }), _jsx(Animated.View, { style: [
90
+ styles.stage,
91
+ { transform: [{ translateY: motion.translateY }] },
92
+ ], children: _jsx(View, { style: [styles.stage, { paddingTop: motion.topGap }], children: _jsxs(KeyboardAvoidingView, { behavior: "padding", style: styles.sheet, children: [_jsx(View, { testID: "payment-sheet-floor", style: [
93
+ styles.floor,
94
+ { backgroundColor: theme.colors.surface },
95
+ ] }), _jsx(IntlProvider, { locale: lang, messages: MESSAGES[lang], timeZone: TIME_ZONE, children: _jsx(SheetThemeContext, { value: theme, children: _jsx(SheetContent, { payment: payment, fontsReady: fontsLoaded || fontsError !== null, deviceLocale: deviceLocale, ipCountry: ipCountry, onClose: close, dragHandlers: motion.dragHandlers, backRef: backRef }) }) })] }) }) })] }) }));
96
+ }
97
+ const styles = StyleSheet.create({
98
+ screen: { flex: 1 },
99
+ leaving: { pointerEvents: 'none' },
100
+ dim: { backgroundColor: 'black' },
101
+ // The app's dim shows through around the sheet.
102
+ stage: { flex: 1, justifyContent: 'flex-end', pointerEvents: 'box-none' },
103
+ sheet: { flexShrink: 1 },
104
+ // Under the sheet's rounded top, down to the screen's bottom.
105
+ floor: { position: 'absolute', top: 14, right: 0, bottom: 0, left: 0 },
106
+ });
@@ -0,0 +1,3 @@
1
+ import type { BoneProps } from '../models/sheet.interface.js';
2
+ /** A rounded block standing in for what is loading, sized like it. */
3
+ export declare function SheetBone({ width, height, radius }: BoneProps): import("react").JSX.Element;
@@ -0,0 +1,12 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { StyleSheet, View } from 'react-native';
3
+ import { useSheetTheme } from "../hooks/use-sheet-theme.js";
4
+ /** A rounded block standing in for what is loading, sized like it. */
5
+ export function SheetBone({ width, height, radius = 6 }) {
6
+ const { colors } = useSheetTheme();
7
+ return (_jsx(View, { style: [
8
+ styles.bone,
9
+ { width, height, borderRadius: radius, backgroundColor: colors.fill },
10
+ ] }));
11
+ }
12
+ const styles = StyleSheet.create({ bone: { flex: 0 } });
@@ -0,0 +1,7 @@
1
+ import type { SheetButtonProps } from '../models/sheet.interface.js';
2
+ /**
3
+ * The sheet's buttons: filled in the app colour for the main action,
4
+ * outlined for the rest, plain (no border) for a quiet second choice, a link
5
+ * in the app colour for a quiet action in a line of its own.
6
+ */
7
+ export declare function SheetButton({ label, onPress, variant, busy, disabled, inactive, }: SheetButtonProps): import("react").JSX.Element;
@@ -0,0 +1,47 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { ActivityIndicator, StyleSheet, TouchableOpacity } from 'react-native';
3
+ import { CheckoutButtonVariantEnum } from "../checkout-core/models/checkout.enum.js";
4
+ import { useSheetTheme } from "../hooks/use-sheet-theme.js";
5
+ import { FigtreeEnum } from "../models/sheet.enum.js";
6
+ import { SheetText } from "./SheetText.js";
7
+ import { FIELD_HEIGHT, FIELD_RADIUS } from "../models/sheet.constants.js";
8
+ /**
9
+ * The sheet's buttons: filled in the app colour for the main action,
10
+ * outlined for the rest, plain (no border) for a quiet second choice, a link
11
+ * in the app colour for a quiet action in a line of its own.
12
+ */
13
+ export function SheetButton({ label, onPress, variant = CheckoutButtonVariantEnum.PRIMARY, busy = false, disabled = false, inactive = false, }) {
14
+ const { colors, brand } = useSheetTheme();
15
+ const primary = variant === CheckoutButtonVariantEnum.PRIMARY;
16
+ const link = variant === CheckoutButtonVariantEnum.LINK;
17
+ const ink = primary ? 'white' : link ? brand : colors.ink;
18
+ const off = disabled || busy;
19
+ return (_jsxs(TouchableOpacity, { onPress: onPress, disabled: off, activeOpacity: 0.8, accessibilityRole: "button", accessibilityState: { disabled: off, busy },
20
+ // A link's text is short: its tap reaches a little past it.
21
+ hitSlop: link ? 6 : undefined, style: [
22
+ link ? styles.link : styles.button,
23
+ primary
24
+ ? { backgroundColor: brand }
25
+ : variant !== CheckoutButtonVariantEnum.PLAIN &&
26
+ !link && {
27
+ borderWidth: 1,
28
+ borderColor: colors.line3,
29
+ },
30
+ (disabled || inactive) && styles.disabled,
31
+ ], children: [busy && _jsx(ActivityIndicator, { color: ink }), _jsx(SheetText, { weight: FigtreeEnum.BOLD, size: link ? 13 : 16, color: ink, style: !link && styles.label, children: label })] }));
32
+ }
33
+ const styles = StyleSheet.create({
34
+ button: {
35
+ minHeight: FIELD_HEIGHT,
36
+ borderRadius: FIELD_RADIUS,
37
+ flexDirection: 'row',
38
+ alignItems: 'center',
39
+ justifyContent: 'center',
40
+ gap: 10,
41
+ paddingHorizontal: 16,
42
+ },
43
+ // The web's link: a line of its own, as tall as a tap needs.
44
+ link: { alignSelf: 'flex-start', height: 32, justifyContent: 'center' },
45
+ label: { textAlign: 'center', fontVariant: ['tabular-nums'] },
46
+ disabled: { opacity: 0.5 },
47
+ });
@@ -0,0 +1,10 @@
1
+ import type { SheetCardFieldsProps } from '../models/sheet.interface.js';
2
+ /**
3
+ * A card method: its provider's card fields page, and only it, in a WebView
4
+ * sized to it. The card is typed there and goes from there to the provider;
5
+ * the sheet only hears, from that page's origin, how it went. The labels and
6
+ * bones stand in until the page says how tall it is. A bank's 3D Secure page
7
+ * shows in the provider's overlay inside it, in place (no window of its
8
+ * own): the page then takes the room the sheet has, brought into view.
9
+ */
10
+ export declare function SheetCardFields({ core, bridge }: SheetCardFieldsProps): import("react").JSX.Element;
@@ -0,0 +1,86 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useMemo } from 'react';
3
+ import { StyleSheet, View } from 'react-native';
4
+ import { WebView } from 'react-native-webview';
5
+ import { useLocale, useTranslations } from 'use-intl';
6
+ import { CARD_FIELDS_HEIGHT } from "../checkout-core/models/checkout.constants.js";
7
+ import { useSheetRoom } from "../hooks/use-sheet-room.js";
8
+ import { useSheetTheme } from "../hooks/use-sheet-theme.js";
9
+ import { FigtreeEnum } from "../models/sheet.enum.js";
10
+ import { cardFieldsBridge, cardFieldsMessageOf, cardFieldsUrl, isCardFieldsPage, originOf, } from "../models/sheet.utils.js";
11
+ import { SheetBone } from "./SheetBone.js";
12
+ import { SheetText } from "./SheetText.js";
13
+ /** Every load goes through `mayLoad`: none is handed to the phone's browser. */
14
+ const ANY_ORIGIN = ['*'];
15
+ /**
16
+ * A card method: its provider's card fields page, and only it, in a WebView
17
+ * sized to it. The card is typed there and goes from there to the provider;
18
+ * the sheet only hears, from that page's origin, how it went. The labels and
19
+ * bones stand in until the page says how tall it is. A bank's 3D Secure page
20
+ * shows in the provider's overlay inside it, in place (no window of its
21
+ * own): the page then takes the room the sheet has, brought into view.
22
+ */
23
+ export function SheetCardFields({ core, bridge }) {
24
+ const t = useTranslations('checkout.card_fields');
25
+ const lang = useLocale();
26
+ const { colors, dark } = useSheetTheme();
27
+ const { room, pinEnd } = useSheetRoom();
28
+ const { view, derived, cardHeight, cardBankPage } = core;
29
+ // Shown only while a card method is picked, and they all come with their page.
30
+ const method = derived.selected;
31
+ const uri = cardFieldsUrl({
32
+ siteUrl: view.siteUrl,
33
+ path: method.cardFieldsPath,
34
+ paymentId: view.id,
35
+ method: method.id,
36
+ color: view.app.color,
37
+ dark,
38
+ lang,
39
+ });
40
+ const source = useMemo(() => ({ uri }), [uri]);
41
+ const loaded = cardHeight !== null;
42
+ // The overlay covers the page: all of it shows at once, never past the sheet.
43
+ const height = !loaded
44
+ ? CARD_FIELDS_HEIGHT
45
+ : cardBankPage && room !== null
46
+ ? Math.min(cardHeight, room)
47
+ : cardHeight;
48
+ // The sheet holds still at it: on Android a drag would scroll the sheet, never the bank's page.
49
+ useEffect(() => {
50
+ pinEnd(cardBankPage);
51
+ return () => pinEnd(false);
52
+ }, [cardBankPage, pinEnd]);
53
+ // The page itself, in either language; the provider's own frames inside
54
+ // it. Android never asks for a frame (its `isTopFrame` is always true):
55
+ // only iOS does, and says so.
56
+ const mayLoad = (request) => request.isTopFrame === false || isCardFieldsPage(request.url, uri);
57
+ // Only what comes from the card fields page's origin reaches the core.
58
+ const hear = ({ nativeEvent }) => {
59
+ if (originOf(nativeEvent.url) !== originOf(uri))
60
+ return;
61
+ const message = cardFieldsMessageOf(nativeEvent.data);
62
+ if (message)
63
+ bridge.receive(message);
64
+ };
65
+ const label = (text) => (_jsx(SheetText, { weight: FigtreeEnum.BOLD, size: 13, style: styles.label, children: text }));
66
+ return (_jsxs(View, { style: styles.section, children: [!loaded && (_jsxs(View, { style: styles.bones, children: [_jsxs(View, { children: [label(t('number')), _jsx(SheetBone, { width: "100%", height: 48, radius: 13 })] }), _jsxs(View, { style: styles.row, children: [_jsxs(View, { style: styles.grow, children: [label(t('expiry')), _jsx(SheetBone, { width: "100%", height: 48, radius: 13 })] }), _jsxs(View, { style: styles.grow, children: [label(t('cvc')), _jsx(SheetBone, { width: "100%", height: 48, radius: 13 })] })] })] })), _jsx(WebView, { ref: bridge.page, source: source, accessibilityLabel: t('title'), originWhitelist: ANY_ORIGIN, onShouldStartLoadWithRequest: mayLoad, injectedJavaScriptBeforeContentLoaded: cardFieldsBridge(), onMessage: hear,
67
+ // 3D Secure is in the page, not in a window of its own.
68
+ setSupportMultipleWindows: false,
69
+ // The provider's frames, on another site, may keep their cookies (an Android switch).
70
+ thirdPartyCookiesEnabled: true, scrollEnabled: false,
71
+ // No iOS form bar (previous, next, done) above the keyboard.
72
+ hideKeyboardAccessoryView: true, style: [
73
+ styles.page,
74
+ { height, backgroundColor: colors.surface },
75
+ !loaded && styles.hidden,
76
+ ] })] }));
77
+ }
78
+ const styles = StyleSheet.create({
79
+ section: { marginTop: 14 },
80
+ bones: { gap: 14, height: CARD_FIELDS_HEIGHT },
81
+ label: { marginBottom: 8 },
82
+ row: { flexDirection: 'row', gap: 12 },
83
+ grow: { flex: 1 },
84
+ page: { width: '100%' },
85
+ hidden: { position: 'absolute', top: 0, left: 0, right: 0, opacity: 0 },
86
+ });
@@ -0,0 +1,3 @@
1
+ import type { ChosenMethodProps } from '../models/sheet.interface.js';
2
+ /** The method picked, on top of the details, with Change back to the methods: as on the web checkout. */
3
+ export declare function SheetChosenMethod({ logo, name, sub, onChange, }: ChosenMethodProps): import("react").JSX.Element;
@@ -0,0 +1,60 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { StyleSheet, TouchableOpacity, View } from 'react-native';
3
+ import { useTranslations } from 'use-intl';
4
+ import { LOGO_SIZE } from "../checkout-core/models/checkout.constants.js";
5
+ import { useSheetTheme } from "../hooks/use-sheet-theme.js";
6
+ import { FigtreeEnum } from "../models/sheet.enum.js";
7
+ import { SheetLogo } from "./SheetLogo.js";
8
+ import { SheetText } from "./SheetText.js";
9
+ import { FIELD_HEIGHT, FIELD_RADIUS, PRESSED_OPACITY, } from "../models/sheet.constants.js";
10
+ /** The method picked, on top of the details, with Change back to the methods: as on the web checkout. */
11
+ export function SheetChosenMethod({ logo, name, sub, onChange, }) {
12
+ const t = useTranslations('checkout');
13
+ const { colors, brand } = useSheetTheme();
14
+ return (_jsxs(View, { testID: "chosen-method", style: [
15
+ styles.row,
16
+ { borderColor: colors.line2, backgroundColor: colors.surface },
17
+ ], children: [_jsxs(View, { children: [_jsx(SheetLogo, { logo: logo, size: LOGO_SIZE.ROW }), _jsx(View, { style: [
18
+ styles.badge,
19
+ { borderColor: colors.surface, backgroundColor: brand },
20
+ ], children: _jsx(View, { style: styles.check }) })] }), _jsxs(View, { style: styles.text, children: [_jsx(SheetText, { weight: FigtreeEnum.SEMI_BOLD, size: 14, numberOfLines: 1, children: name }), _jsx(SheetText, { size: 12, color: colors.muted, numberOfLines: 1, children: sub })] }), _jsx(TouchableOpacity, { onPress: onChange, activeOpacity: PRESSED_OPACITY, accessibilityRole: "button", accessibilityLabel: t('change'), hitSlop: 6, style: styles.change, children: _jsx(SheetText, { weight: FigtreeEnum.BOLD, size: 12, color: brand, children: t('change') }) })] }));
21
+ }
22
+ const styles = StyleSheet.create({
23
+ row: {
24
+ flexDirection: 'row',
25
+ alignItems: 'center',
26
+ gap: 12,
27
+ height: FIELD_HEIGHT,
28
+ borderWidth: 1,
29
+ borderRadius: FIELD_RADIUS,
30
+ paddingLeft: 8,
31
+ paddingRight: 6,
32
+ },
33
+ badge: {
34
+ position: 'absolute',
35
+ right: -4,
36
+ bottom: -4,
37
+ width: 16,
38
+ height: 16,
39
+ alignItems: 'center',
40
+ justifyContent: 'center',
41
+ borderWidth: 2,
42
+ borderRadius: 8,
43
+ },
44
+ check: {
45
+ width: 3.5,
46
+ height: 6.5,
47
+ marginTop: -1,
48
+ borderColor: 'white',
49
+ borderRightWidth: 1.6,
50
+ borderBottomWidth: 1.6,
51
+ transform: [{ rotate: '45deg' }],
52
+ },
53
+ text: { flex: 1, minWidth: 0 },
54
+ change: {
55
+ height: 32,
56
+ justifyContent: 'center',
57
+ borderRadius: 8,
58
+ paddingHorizontal: 10,
59
+ },
60
+ });
@@ -0,0 +1,8 @@
1
+ import type { SheetScreenProps } from '../models/sheet.interface.js';
2
+ /**
3
+ * OTP methods: Dial opens the network's code in the phone dialler for a
4
+ * one-time payment code (on Android; on iOS it says to dial it by hand);
5
+ * back in the app the code field comes up, filled from the SMS when the
6
+ * phone offers it. Sent once with Pay, never kept.
7
+ */
8
+ export declare function SheetCodeField({ core }: SheetScreenProps): import("react").JSX.Element;