@heyama/pay-react-native 0.0.0-stage → 1.0.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 (120) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +99 -2
  3. package/assets/fonts/Figtree-Bold.ttf +0 -0
  4. package/assets/fonts/Figtree-ExtraBold.ttf +0 -0
  5. package/assets/fonts/Figtree-Medium.ttf +0 -0
  6. package/assets/fonts/Figtree-Regular.ttf +0 -0
  7. package/assets/fonts/Figtree-SemiBold.ttf +0 -0
  8. package/assets/fonts/OFL.txt +93 -0
  9. package/assets/logos/apple-pay.png +0 -0
  10. package/assets/logos/card.png +0 -0
  11. package/assets/logos/google-pay.png +0 -0
  12. package/assets/logos/mastercard.png +0 -0
  13. package/assets/logos/mixx.png +0 -0
  14. package/assets/logos/moov.png +0 -0
  15. package/assets/logos/mtn.png +0 -0
  16. package/assets/logos/orange.png +0 -0
  17. package/assets/logos/paypal.png +0 -0
  18. package/assets/logos/visa.png +0 -0
  19. package/assets/logos/wave.png +0 -0
  20. package/dist/checkout-core/hooks/use-checkout-controller.d.ts +9 -0
  21. package/dist/checkout-core/hooks/use-checkout-controller.js +319 -0
  22. package/dist/checkout-core/hooks/use-checkout-timers.d.ts +15 -0
  23. package/dist/checkout-core/hooks/use-checkout-timers.js +44 -0
  24. package/dist/checkout-core/hooks/use-phone-number.d.ts +7 -0
  25. package/dist/checkout-core/hooks/use-phone-number.js +82 -0
  26. package/dist/checkout-core/messages/en.d.ts +252 -0
  27. package/dist/checkout-core/messages/en.js +242 -0
  28. package/dist/checkout-core/messages/fr.d.ts +4 -0
  29. package/dist/checkout-core/messages/fr.js +244 -0
  30. package/dist/checkout-core/models/checkout.card.utils.d.ts +22 -0
  31. package/dist/checkout-core/models/checkout.card.utils.js +101 -0
  32. package/dist/checkout-core/models/checkout.constants.d.ts +56 -0
  33. package/dist/checkout-core/models/checkout.constants.js +142 -0
  34. package/dist/checkout-core/models/checkout.enum.d.ts +131 -0
  35. package/dist/checkout-core/models/checkout.enum.js +148 -0
  36. package/dist/checkout-core/models/checkout.interface.d.ts +417 -0
  37. package/dist/checkout-core/models/checkout.interface.js +1 -0
  38. package/dist/checkout-core/models/checkout.money.utils.d.ts +7 -0
  39. package/dist/checkout-core/models/checkout.money.utils.js +21 -0
  40. package/dist/checkout-core/models/checkout.phone.utils.d.ts +33 -0
  41. package/dist/checkout-core/models/checkout.phone.utils.js +159 -0
  42. package/dist/checkout-core/models/checkout.view.utils.d.ts +34 -0
  43. package/dist/checkout-core/models/checkout.view.utils.js +205 -0
  44. package/dist/checkout-core/models/domain.enum.d.ts +56 -0
  45. package/dist/checkout-core/models/domain.enum.js +62 -0
  46. package/dist/components/BrissotoPayProvider.d.ts +6 -0
  47. package/dist/components/BrissotoPayProvider.js +41 -0
  48. package/dist/components/PaymentSheetModal.d.ts +8 -0
  49. package/dist/components/PaymentSheetModal.js +72 -0
  50. package/dist/components/SheetBone.d.ts +3 -0
  51. package/dist/components/SheetBone.js +12 -0
  52. package/dist/components/SheetButton.d.ts +3 -0
  53. package/dist/components/SheetButton.js +33 -0
  54. package/dist/components/SheetCardFields.d.ts +8 -0
  55. package/dist/components/SheetCardFields.js +66 -0
  56. package/dist/components/SheetCodeField.d.ts +8 -0
  57. package/dist/components/SheetCodeField.js +95 -0
  58. package/dist/components/SheetContent.d.ts +3 -0
  59. package/dist/components/SheetContent.js +106 -0
  60. package/dist/components/SheetFailed.d.ts +3 -0
  61. package/dist/components/SheetFailed.js +43 -0
  62. package/dist/components/SheetForm.d.ts +7 -0
  63. package/dist/components/SheetForm.js +100 -0
  64. package/dist/components/SheetHeader.d.ts +6 -0
  65. package/dist/components/SheetHeader.js +69 -0
  66. package/dist/components/SheetIcon.d.ts +3 -0
  67. package/dist/components/SheetIcon.js +70 -0
  68. package/dist/components/SheetLayout.d.ts +8 -0
  69. package/dist/components/SheetLayout.js +35 -0
  70. package/dist/components/SheetLogo.d.ts +3 -0
  71. package/dist/components/SheetLogo.js +20 -0
  72. package/dist/components/SheetMessage.d.ts +3 -0
  73. package/dist/components/SheetMessage.js +15 -0
  74. package/dist/components/SheetMethodCard.d.ts +3 -0
  75. package/dist/components/SheetMethodCard.js +39 -0
  76. package/dist/components/SheetPhoneField.d.ts +3 -0
  77. package/dist/components/SheetPhoneField.js +56 -0
  78. package/dist/components/SheetRow.d.ts +3 -0
  79. package/dist/components/SheetRow.js +28 -0
  80. package/dist/components/SheetSimulator.d.ts +6 -0
  81. package/dist/components/SheetSimulator.js +39 -0
  82. package/dist/components/SheetSkeleton.d.ts +5 -0
  83. package/dist/components/SheetSkeleton.js +23 -0
  84. package/dist/components/SheetSuccess.d.ts +3 -0
  85. package/dist/components/SheetSuccess.js +51 -0
  86. package/dist/components/SheetSummary.d.ts +3 -0
  87. package/dist/components/SheetSummary.js +32 -0
  88. package/dist/components/SheetTerminal.d.ts +3 -0
  89. package/dist/components/SheetTerminal.js +21 -0
  90. package/dist/components/SheetText.d.ts +5 -0
  91. package/dist/components/SheetText.js +25 -0
  92. package/dist/components/SheetToast.d.ts +3 -0
  93. package/dist/components/SheetToast.js +24 -0
  94. package/dist/components/SheetWaiting.d.ts +7 -0
  95. package/dist/components/SheetWaiting.js +77 -0
  96. package/dist/hooks/use-native-platform.d.ts +10 -0
  97. package/dist/hooks/use-native-platform.js +47 -0
  98. package/dist/hooks/use-payment-sheet.d.ts +4 -0
  99. package/dist/hooks/use-payment-sheet.js +10 -0
  100. package/dist/hooks/use-sheet-motion.d.ts +7 -0
  101. package/dist/hooks/use-sheet-motion.js +62 -0
  102. package/dist/hooks/use-sheet-resize.d.ts +6 -0
  103. package/dist/hooks/use-sheet-resize.js +15 -0
  104. package/dist/hooks/use-sheet-theme.d.ts +4 -0
  105. package/dist/hooks/use-sheet-theme.js +12 -0
  106. package/dist/hooks/use-watched-payment.d.ts +6 -0
  107. package/dist/hooks/use-watched-payment.js +17 -0
  108. package/dist/index.d.ts +3 -0
  109. package/dist/index.js +2 -0
  110. package/dist/models/sheet.constants.d.ts +39 -0
  111. package/dist/models/sheet.constants.js +78 -0
  112. package/dist/models/sheet.enum.d.ts +16 -0
  113. package/dist/models/sheet.enum.js +18 -0
  114. package/dist/models/sheet.interface.d.ts +225 -0
  115. package/dist/models/sheet.interface.js +1 -0
  116. package/dist/models/sheet.utils.d.ts +43 -0
  117. package/dist/models/sheet.utils.js +132 -0
  118. package/dist/services/checkout.service.d.ts +7 -0
  119. package/dist/services/checkout.service.js +39 -0
  120. package/package.json +58 -4
@@ -0,0 +1,131 @@
1
+ export declare enum CheckoutScreenEnum {
2
+ LOADING = "loading",
3
+ FORM = "form",
4
+ SUBMITTING = "submitting",
5
+ WAITING = "waiting",
6
+ /** The last attempt failed: why, a retry and another method. */
7
+ FAILED = "failed",
8
+ SUCCESS = "success",
9
+ EXPIRED = "expired",
10
+ CANCELLED = "cancelled",
11
+ LOCKED = "locked",
12
+ INVALID = "invalid",
13
+ /** Every method went off since the link was made: nothing to pay with. */
14
+ NO_METHOD = "no_method",
15
+ REDIRECT = "redirect"
16
+ }
17
+ /** Values are the `preferredTab` an app may send. */
18
+ export declare enum CheckoutTabEnum {
19
+ MOBILE_MONEY = "mobile_money",
20
+ CARD = "card"
21
+ }
22
+ /** GLOSSARY: Payment. Values are the API's. */
23
+ export declare enum CheckoutPaymentStatusEnum {
24
+ PENDING = "pending",
25
+ PAID = "paid",
26
+ EXPIRED = "expired",
27
+ LOCKED = "locked",
28
+ CANCELLED = "cancelled"
29
+ }
30
+ /** Where a method stands on this payment: payable, greyed with a note, or not built yet. */
31
+ export declare enum MethodStateEnum {
32
+ AVAILABLE = "available",
33
+ MAINTENANCE = "maintenance",
34
+ SOON = "soon"
35
+ }
36
+ export declare enum MethodKindEnum {
37
+ MOBILE_MONEY = "mobile_money",
38
+ CARD = "card"
39
+ }
40
+ /** How the payer approves: a prompt on the phone, a one-time code, or card fields. Values are the backend's. */
41
+ export declare enum MethodFlowEnum {
42
+ USSD_PUSH = "ussd_push",
43
+ OTP = "otp",
44
+ CARD_FIELDS = "card_fields"
45
+ }
46
+ /** The network a Mobile Money number belongs to, from its first digits. Values are logo names. */
47
+ export declare enum MethodBrandEnum {
48
+ ORANGE = "orange",
49
+ MTN = "mtn",
50
+ MOOV = "moov"
51
+ }
52
+ /** Why Pay was refused. Values are the backend's. */
53
+ export declare enum PayRefusalEnum {
54
+ CLOSED = "closed",
55
+ METHOD = "method",
56
+ PHONE = "phone",
57
+ /** An OTP method came without a valid code. */
58
+ CODE = "code"
59
+ }
60
+ /**
61
+ * What a provider's card fields page and the checkout tell each other through
62
+ * `postMessage`. The card itself never crosses: only whether it is complete,
63
+ * the page's height, and how a Pay went.
64
+ */
65
+ export declare enum CardFieldsMessageEnum {
66
+ /** Page → checkout: `complete` says whether Pay can go. */
67
+ STATE = "card-fields:state",
68
+ /** Page → checkout: its content height, so the frame never scrolls. */
69
+ HEIGHT = "card-fields:height",
70
+ /** Checkout → page: Pay was pressed. */
71
+ SUBMIT = "card-fields:submit",
72
+ /** Page → checkout: the card is with the provider; the checkout waits for the status checks. */
73
+ DONE = "card-fields:done",
74
+ /** Page → checkout: Pay was refused (`reason`), or could not reach us (none). */
75
+ REFUSED = "card-fields:refused"
76
+ }
77
+ export declare enum CardFieldEnum {
78
+ NUMBER = "number",
79
+ EXPIRY = "expiry",
80
+ CVC = "cvc"
81
+ }
82
+ /** What a tester makes the Simulator answer. Values are the backend's. */
83
+ export declare enum SimulatorOutcomeEnum {
84
+ APPROVED = "approved",
85
+ DECLINED = "declined",
86
+ INSUFFICIENT_FUNDS = "insufficient_funds",
87
+ NO_ACCOUNT = "no_account",
88
+ WRONG_PIN = "wrong_pin",
89
+ WRONG_CODE = "wrong_code",
90
+ PROVIDER_ERROR = "provider_error",
91
+ WRONG_AMOUNT = "wrong_amount",
92
+ APPROVED_LATE = "approved_late",
93
+ REVERSED = "reversed"
94
+ }
95
+ export declare enum PhoneErrorEnum {
96
+ START = "start",
97
+ SHORT = "short",
98
+ INVALID = "invalid",
99
+ EMPTY = "empty",
100
+ OPERATOR = "operator",
101
+ /** An international number of a country the payment is not offered in. */
102
+ COUNTRY = "country"
103
+ }
104
+ export declare enum SupportChannelEnum {
105
+ WHATSAPP = "whatsapp",
106
+ EMAIL = "email"
107
+ }
108
+ /** Values are the keys of `faqs` in the checkout catalog. */
109
+ export declare enum FaqEnum {
110
+ NOT_RECEIVED = "not_received",
111
+ DEBITED = "debited"
112
+ }
113
+ /** Screens the payer cannot act on, each with its copy. Values are catalog keys. */
114
+ export declare enum TerminalKindEnum {
115
+ EXPIRED = "expired",
116
+ CANCELLED = "cancelled",
117
+ LOCKED = "locked",
118
+ INVALID = "invalid",
119
+ NO_METHOD = "no_method"
120
+ }
121
+ export declare enum CheckoutButtonVariantEnum {
122
+ PRIMARY = "primary",
123
+ SECONDARY = "secondary",
124
+ /** Gives something up: cancelling the payment. */
125
+ DANGER = "danger"
126
+ }
127
+ /** Values are the `theme` an app may send. */
128
+ export declare enum CheckoutThemeEnum {
129
+ LIGHT = "light",
130
+ DARK = "dark"
131
+ }
@@ -0,0 +1,148 @@
1
+ export var CheckoutScreenEnum;
2
+ (function (CheckoutScreenEnum) {
3
+ CheckoutScreenEnum["LOADING"] = "loading";
4
+ CheckoutScreenEnum["FORM"] = "form";
5
+ CheckoutScreenEnum["SUBMITTING"] = "submitting";
6
+ CheckoutScreenEnum["WAITING"] = "waiting";
7
+ /** The last attempt failed: why, a retry and another method. */
8
+ CheckoutScreenEnum["FAILED"] = "failed";
9
+ CheckoutScreenEnum["SUCCESS"] = "success";
10
+ CheckoutScreenEnum["EXPIRED"] = "expired";
11
+ CheckoutScreenEnum["CANCELLED"] = "cancelled";
12
+ CheckoutScreenEnum["LOCKED"] = "locked";
13
+ CheckoutScreenEnum["INVALID"] = "invalid";
14
+ /** Every method went off since the link was made: nothing to pay with. */
15
+ CheckoutScreenEnum["NO_METHOD"] = "no_method";
16
+ CheckoutScreenEnum["REDIRECT"] = "redirect";
17
+ })(CheckoutScreenEnum || (CheckoutScreenEnum = {}));
18
+ /** Values are the `preferredTab` an app may send. */
19
+ export var CheckoutTabEnum;
20
+ (function (CheckoutTabEnum) {
21
+ CheckoutTabEnum["MOBILE_MONEY"] = "mobile_money";
22
+ CheckoutTabEnum["CARD"] = "card";
23
+ })(CheckoutTabEnum || (CheckoutTabEnum = {}));
24
+ /** GLOSSARY: Payment. Values are the API's. */
25
+ export var CheckoutPaymentStatusEnum;
26
+ (function (CheckoutPaymentStatusEnum) {
27
+ CheckoutPaymentStatusEnum["PENDING"] = "pending";
28
+ CheckoutPaymentStatusEnum["PAID"] = "paid";
29
+ CheckoutPaymentStatusEnum["EXPIRED"] = "expired";
30
+ CheckoutPaymentStatusEnum["LOCKED"] = "locked";
31
+ CheckoutPaymentStatusEnum["CANCELLED"] = "cancelled";
32
+ })(CheckoutPaymentStatusEnum || (CheckoutPaymentStatusEnum = {}));
33
+ /** Where a method stands on this payment: payable, greyed with a note, or not built yet. */
34
+ export var MethodStateEnum;
35
+ (function (MethodStateEnum) {
36
+ MethodStateEnum["AVAILABLE"] = "available";
37
+ MethodStateEnum["MAINTENANCE"] = "maintenance";
38
+ MethodStateEnum["SOON"] = "soon";
39
+ })(MethodStateEnum || (MethodStateEnum = {}));
40
+ export var MethodKindEnum;
41
+ (function (MethodKindEnum) {
42
+ MethodKindEnum["MOBILE_MONEY"] = "mobile_money";
43
+ MethodKindEnum["CARD"] = "card";
44
+ })(MethodKindEnum || (MethodKindEnum = {}));
45
+ /** How the payer approves: a prompt on the phone, a one-time code, or card fields. Values are the backend's. */
46
+ export var MethodFlowEnum;
47
+ (function (MethodFlowEnum) {
48
+ MethodFlowEnum["USSD_PUSH"] = "ussd_push";
49
+ MethodFlowEnum["OTP"] = "otp";
50
+ MethodFlowEnum["CARD_FIELDS"] = "card_fields";
51
+ })(MethodFlowEnum || (MethodFlowEnum = {}));
52
+ /** The network a Mobile Money number belongs to, from its first digits. Values are logo names. */
53
+ export var MethodBrandEnum;
54
+ (function (MethodBrandEnum) {
55
+ MethodBrandEnum["ORANGE"] = "orange";
56
+ MethodBrandEnum["MTN"] = "mtn";
57
+ MethodBrandEnum["MOOV"] = "moov";
58
+ })(MethodBrandEnum || (MethodBrandEnum = {}));
59
+ /** Why Pay was refused. Values are the backend's. */
60
+ export var PayRefusalEnum;
61
+ (function (PayRefusalEnum) {
62
+ PayRefusalEnum["CLOSED"] = "closed";
63
+ PayRefusalEnum["METHOD"] = "method";
64
+ PayRefusalEnum["PHONE"] = "phone";
65
+ /** An OTP method came without a valid code. */
66
+ PayRefusalEnum["CODE"] = "code";
67
+ })(PayRefusalEnum || (PayRefusalEnum = {}));
68
+ /**
69
+ * What a provider's card fields page and the checkout tell each other through
70
+ * `postMessage`. The card itself never crosses: only whether it is complete,
71
+ * the page's height, and how a Pay went.
72
+ */
73
+ export var CardFieldsMessageEnum;
74
+ (function (CardFieldsMessageEnum) {
75
+ /** Page → checkout: `complete` says whether Pay can go. */
76
+ CardFieldsMessageEnum["STATE"] = "card-fields:state";
77
+ /** Page → checkout: its content height, so the frame never scrolls. */
78
+ CardFieldsMessageEnum["HEIGHT"] = "card-fields:height";
79
+ /** Checkout → page: Pay was pressed. */
80
+ CardFieldsMessageEnum["SUBMIT"] = "card-fields:submit";
81
+ /** Page → checkout: the card is with the provider; the checkout waits for the status checks. */
82
+ CardFieldsMessageEnum["DONE"] = "card-fields:done";
83
+ /** Page → checkout: Pay was refused (`reason`), or could not reach us (none). */
84
+ CardFieldsMessageEnum["REFUSED"] = "card-fields:refused";
85
+ })(CardFieldsMessageEnum || (CardFieldsMessageEnum = {}));
86
+ export var CardFieldEnum;
87
+ (function (CardFieldEnum) {
88
+ CardFieldEnum["NUMBER"] = "number";
89
+ CardFieldEnum["EXPIRY"] = "expiry";
90
+ CardFieldEnum["CVC"] = "cvc";
91
+ })(CardFieldEnum || (CardFieldEnum = {}));
92
+ /** What a tester makes the Simulator answer. Values are the backend's. */
93
+ export var SimulatorOutcomeEnum;
94
+ (function (SimulatorOutcomeEnum) {
95
+ SimulatorOutcomeEnum["APPROVED"] = "approved";
96
+ SimulatorOutcomeEnum["DECLINED"] = "declined";
97
+ SimulatorOutcomeEnum["INSUFFICIENT_FUNDS"] = "insufficient_funds";
98
+ SimulatorOutcomeEnum["NO_ACCOUNT"] = "no_account";
99
+ SimulatorOutcomeEnum["WRONG_PIN"] = "wrong_pin";
100
+ SimulatorOutcomeEnum["WRONG_CODE"] = "wrong_code";
101
+ SimulatorOutcomeEnum["PROVIDER_ERROR"] = "provider_error";
102
+ SimulatorOutcomeEnum["WRONG_AMOUNT"] = "wrong_amount";
103
+ SimulatorOutcomeEnum["APPROVED_LATE"] = "approved_late";
104
+ SimulatorOutcomeEnum["REVERSED"] = "reversed";
105
+ })(SimulatorOutcomeEnum || (SimulatorOutcomeEnum = {}));
106
+ export var PhoneErrorEnum;
107
+ (function (PhoneErrorEnum) {
108
+ PhoneErrorEnum["START"] = "start";
109
+ PhoneErrorEnum["SHORT"] = "short";
110
+ PhoneErrorEnum["INVALID"] = "invalid";
111
+ PhoneErrorEnum["EMPTY"] = "empty";
112
+ PhoneErrorEnum["OPERATOR"] = "operator";
113
+ /** An international number of a country the payment is not offered in. */
114
+ PhoneErrorEnum["COUNTRY"] = "country";
115
+ })(PhoneErrorEnum || (PhoneErrorEnum = {}));
116
+ export var SupportChannelEnum;
117
+ (function (SupportChannelEnum) {
118
+ SupportChannelEnum["WHATSAPP"] = "whatsapp";
119
+ SupportChannelEnum["EMAIL"] = "email";
120
+ })(SupportChannelEnum || (SupportChannelEnum = {}));
121
+ /** Values are the keys of `faqs` in the checkout catalog. */
122
+ export var FaqEnum;
123
+ (function (FaqEnum) {
124
+ FaqEnum["NOT_RECEIVED"] = "not_received";
125
+ FaqEnum["DEBITED"] = "debited";
126
+ })(FaqEnum || (FaqEnum = {}));
127
+ /** Screens the payer cannot act on, each with its copy. Values are catalog keys. */
128
+ export var TerminalKindEnum;
129
+ (function (TerminalKindEnum) {
130
+ TerminalKindEnum["EXPIRED"] = "expired";
131
+ TerminalKindEnum["CANCELLED"] = "cancelled";
132
+ TerminalKindEnum["LOCKED"] = "locked";
133
+ TerminalKindEnum["INVALID"] = "invalid";
134
+ TerminalKindEnum["NO_METHOD"] = "no_method";
135
+ })(TerminalKindEnum || (TerminalKindEnum = {}));
136
+ export var CheckoutButtonVariantEnum;
137
+ (function (CheckoutButtonVariantEnum) {
138
+ CheckoutButtonVariantEnum["PRIMARY"] = "primary";
139
+ CheckoutButtonVariantEnum["SECONDARY"] = "secondary";
140
+ /** Gives something up: cancelling the payment. */
141
+ CheckoutButtonVariantEnum["DANGER"] = "danger";
142
+ })(CheckoutButtonVariantEnum || (CheckoutButtonVariantEnum = {}));
143
+ /** Values are the `theme` an app may send. */
144
+ export var CheckoutThemeEnum;
145
+ (function (CheckoutThemeEnum) {
146
+ CheckoutThemeEnum["LIGHT"] = "light";
147
+ CheckoutThemeEnum["DARK"] = "dark";
148
+ })(CheckoutThemeEnum || (CheckoutThemeEnum = {}));
@@ -0,0 +1,417 @@
1
+ import type { CardFieldsMessageEnum, CheckoutPaymentStatusEnum, CheckoutScreenEnum, CheckoutTabEnum, CheckoutThemeEnum, MethodBrandEnum, MethodFlowEnum, MethodKindEnum, MethodStateEnum, PayRefusalEnum, PhoneErrorEnum, SimulatorOutcomeEnum, SupportChannelEnum } from './checkout.enum.js';
2
+ import type { AttemptStatusEnum, CountryEnum, CurrencyEnum, FailureReasonEnum, LangEnum, ProviderLogoEnum } from './domain.enum.js';
3
+ export interface CheckoutApp {
4
+ name: string;
5
+ color: string;
6
+ logoUrl: string | null;
7
+ termsUrl: string | null;
8
+ privacyUrl: string | null;
9
+ supportEmail: string | null;
10
+ /** E.164. */
11
+ supportWhatsapp: string | null;
12
+ }
13
+ export interface CheckoutItem {
14
+ name: string;
15
+ quantity: number;
16
+ /** Minor units. */
17
+ unitAmount: number;
18
+ }
19
+ /** A payment method this payment can be paid with, in the admin's order. */
20
+ export interface CheckoutMethod {
21
+ id: string;
22
+ name: string;
23
+ kind: MethodKindEnum;
24
+ country: CountryEnum;
25
+ /** The network that runs it ("Orange Cameroun"). */
26
+ network: string;
27
+ flow: MethodFlowEnum;
28
+ /** The code a payer dials to see payments waiting for approval. */
29
+ pendingCode: string | null;
30
+ /** OTP methods: what the payer dials to get a payment code for this amount. */
31
+ otpCode: string | null;
32
+ /** Card methods: the provider's page hosting its card fields, shown in an iframe. */
33
+ cardFieldsPath: string | null;
34
+ logos: Array<ProviderLogoEnum>;
35
+ state: MethodStateEnum;
36
+ /** Why it is in maintenance, for the payer. */
37
+ note: string | null;
38
+ }
39
+ /**
40
+ * A paid card as its provider reported it: never more than the last 4
41
+ * digits. The brand is the provider's own word, whatever the network.
42
+ */
43
+ export interface CardSummary {
44
+ brand: string;
45
+ last4: string;
46
+ }
47
+ export interface CheckoutAttempt {
48
+ reference: string;
49
+ method: string;
50
+ /** As the payer read it when paying. */
51
+ methodName: string;
52
+ logos: Array<ProviderLogoEnum>;
53
+ flow: MethodFlowEnum;
54
+ pendingCode: string | null;
55
+ status: AttemptStatusEnum;
56
+ failureReason: FailureReasonEnum | null;
57
+ /** E.164; a card has none. */
58
+ phone: string | null;
59
+ /** A paid card: its brand and last 4 digits. */
60
+ card: CardSummary | null;
61
+ startedAt: number;
62
+ /** A test attempt the Simulator took: the tester picks its outcome. */
63
+ simulated: boolean;
64
+ }
65
+ export interface CheckoutPayer {
66
+ name: string | null;
67
+ phone: string | null;
68
+ email: string | null;
69
+ }
70
+ /** One payment as the checkout shows it (`checkout.queries.get`). */
71
+ export interface CheckoutView {
72
+ id: string;
73
+ status: CheckoutPaymentStatusEnum;
74
+ test: boolean;
75
+ /** Minor units. */
76
+ amount: number;
77
+ currency: CurrencyEnum;
78
+ orderRef: string | null;
79
+ items: Array<CheckoutItem>;
80
+ returnUrl: string;
81
+ expiresAt: number;
82
+ paidAt: number | null;
83
+ payer: CheckoutPayer;
84
+ /** The app's hint for the payer's country. */
85
+ country: CountryEnum | null;
86
+ language: LangEnum | null;
87
+ theme: CheckoutThemeEnum | null;
88
+ preferredMethod: string | null;
89
+ preferredTab: CheckoutTabEnum | null;
90
+ app: CheckoutApp;
91
+ methods: Array<CheckoutMethod>;
92
+ /** Payer-caused failures it still takes before it locks, out of `maxAttempts`. */
93
+ attemptsLeft: number;
94
+ maxAttempts: number;
95
+ attempt: CheckoutAttempt | null;
96
+ /**
97
+ * Where the checkout is served, without a trailing slash: the payment
98
+ * sheet loads card fields pages (`cardFieldsPath`) from it.
99
+ */
100
+ siteUrl: string;
101
+ }
102
+ /** Where the request came from, for picking the payer's country. */
103
+ export interface CountryClues {
104
+ /** From the proxy's country header, when it sends one. */
105
+ ipCountry: string | null;
106
+ /** Browser languages in preference order (`fr-CM`). */
107
+ languages: Array<string>;
108
+ }
109
+ /** A greyed row on the Card tab for a wallet no provider offers yet. */
110
+ export interface ComingSoonWallet {
111
+ /** Catalog key under `wallets` and logo name. */
112
+ id: ProviderLogoEnum;
113
+ }
114
+ export interface OperatorDetection {
115
+ /** The operator the number belongs to, once enough digits say so. */
116
+ operator: MethodBrandEnum | null;
117
+ /** Enough digits were typed and no known operator matches. */
118
+ unrecognized: boolean;
119
+ }
120
+ export interface PhoneInputs {
121
+ country: CountryEnum;
122
+ /** Digits of the national number, no dial code and no spaces. */
123
+ digits: string;
124
+ /** A full international number of a country the payment is not offered in. */
125
+ foreign: boolean;
126
+ touched: boolean;
127
+ focused: boolean;
128
+ submitTried: boolean;
129
+ }
130
+ export interface PhoneStatus {
131
+ error: PhoneErrorEnum | null;
132
+ valid: boolean;
133
+ operator: MethodBrandEnum | null;
134
+ }
135
+ /** What the payer typed, read: its country and national digits. */
136
+ export interface TypedNumber {
137
+ country: CountryEnum;
138
+ digits: string;
139
+ /** A `+…` number kept as typed while its country is unknown or not offered. */
140
+ pending: string | null;
141
+ }
142
+ export interface PhoneNumberOptions {
143
+ country: CountryEnum;
144
+ /** Countries of this payment's Mobile Money methods. */
145
+ countries: Array<CountryEnum>;
146
+ /** The payer typed or pasted a full number of another offered country. */
147
+ onCountryChange: (country: CountryEnum) => void;
148
+ }
149
+ /** The Mobile Money number without its field: each platform draws and wires its own input. */
150
+ export interface PhoneNumber {
151
+ /** What the field shows: the number grouped the country's way. */
152
+ value: string;
153
+ /**
154
+ * The field's new text and where its caret was; answers where the caret
155
+ * goes in the grouped number, or null to leave it (an international number).
156
+ */
157
+ type: (text: string, caret: number) => number | null;
158
+ /** E.164, empty until the number is complete. */
159
+ e164: string;
160
+ dial: string;
161
+ placeholder: string;
162
+ status: PhoneStatus;
163
+ focused: boolean;
164
+ onFocus: () => void;
165
+ onBlur: () => void;
166
+ /** Marks the field as submitted, so its error shows. */
167
+ reject: () => void;
168
+ /** The app's number for the payer, when it is of the page's country. */
169
+ fill: (e164: string) => void;
170
+ }
171
+ /** What the payer did on this page; the payment itself comes from the gateway. */
172
+ export interface CheckoutUi {
173
+ tab: CheckoutTabEnum;
174
+ country: CountryEnum;
175
+ /** The Mobile Money method picked, if any. */
176
+ method: string | null;
177
+ /** The payment code typed for an OTP method; cleared when the method changes. */
178
+ code: string;
179
+ /** A card method's fields say the card is complete. */
180
+ cardComplete: boolean;
181
+ /** Pay went to the card fields page: the form stays until it says how it went. */
182
+ cardPaying: boolean;
183
+ pickerOpen: boolean;
184
+ summaryOpen: boolean;
185
+ submitting: boolean;
186
+ /** An attempt the payer walked away from: the form shows again. */
187
+ dismissed: string | null;
188
+ redirecting: boolean;
189
+ }
190
+ /** Everything the screens show that follows from the payment and the page, worked out once. */
191
+ export interface CheckoutDerived {
192
+ screen: CheckoutScreenEnum;
193
+ /** Countries with Mobile Money methods, in the admin's order. */
194
+ countries: Array<CountryEnum>;
195
+ wallets: Array<CheckoutMethod>;
196
+ cards: Array<CheckoutMethod>;
197
+ /** The picked method, while it can still be used. */
198
+ selected: CheckoutMethod | null;
199
+ canPay: boolean;
200
+ /** The number belongs to another method of the country than the one picked. */
201
+ mismatch: CheckoutMethod | null;
202
+ /** After a failure: another method of the same country the payer can use now. */
203
+ suggestion: CheckoutMethod | null;
204
+ }
205
+ export interface CheckoutCoreActions {
206
+ toggleSummary: () => void;
207
+ setTab: (tab: CheckoutTabEnum) => void;
208
+ setCountry: (country: CountryEnum) => void;
209
+ selectMethod: (method: CheckoutMethod) => void;
210
+ /** A greyed wallet no provider offers yet was tapped. */
211
+ comingSoon: (name: string) => void;
212
+ openPicker: () => void;
213
+ switchToDetected: () => void;
214
+ pay: () => void;
215
+ /** The failed attempt again: same method, same number. An OTP method asks for a new code first. */
216
+ retry: () => void;
217
+ setCode: (code: string) => void;
218
+ /** The phone could not open its dialler on the OTP method's code: dial it by hand. */
219
+ cannotDial: () => void;
220
+ /** Leaves the failure screen for the suggested method, or the list. */
221
+ useAnother: () => void;
222
+ /** "Didn't get it?": the prompt again. */
223
+ resend: () => void;
224
+ cancel: () => void;
225
+ returnNow: () => void;
226
+ stayHere: () => void;
227
+ openHelp: () => void;
228
+ closeHelp: () => void;
229
+ copyReference: () => void;
230
+ downloadReceipt: () => void;
231
+ simulate: (outcome: SimulatorOutcomeEnum) => void;
232
+ }
233
+ /** The checkout's state and actions, the same on the web page and in the payment sheet. */
234
+ export interface CheckoutCore {
235
+ /** Null for a link that matches no payment. */
236
+ view: CheckoutView | null;
237
+ ui: CheckoutUi;
238
+ derived: CheckoutDerived;
239
+ phone: PhoneNumber;
240
+ /** Seconds left on the waiting screen's clock. */
241
+ waitLeft: number;
242
+ /** Seconds before the success screen sends the payer back, null once stopped. */
243
+ returnLeft: number | null;
244
+ helpOpen: boolean;
245
+ toastMessage: string | null;
246
+ copied: boolean;
247
+ /** The Branding tab's preview: nothing can be paid. */
248
+ preview: boolean;
249
+ /** The card fields' content height, as their page last said; null until it loaded. */
250
+ cardHeight: number | null;
251
+ actions: CheckoutCoreActions;
252
+ }
253
+ /**
254
+ * What only the platform can do, handed to the controller. Pass one stable
255
+ * object: a new one each render subscribes again.
256
+ */
257
+ export interface CheckoutPlatform {
258
+ /** Calls `listener` each time the payer comes back to the page or the app; answers how to stop. */
259
+ onReturn: (listener: () => void) => () => void;
260
+ copyText: (text: string) => void;
261
+ /** Leaves for the app's return URL. */
262
+ openUrl: (url: string) => void;
263
+ /** Calls `listener` with each message the card fields page sends; answers how to stop. */
264
+ onCardMessage: (listener: (message: CardFieldsMessage) => void) => () => void;
265
+ /** Tells the card fields page that Pay was pressed. */
266
+ submitCard: () => void;
267
+ /** Hands the receipt to the payer as a text file. */
268
+ saveReceipt: (fileName: string, text: string) => void;
269
+ /** Pay found the number wrong: draw the payer's eye to the field. */
270
+ onPhoneRejected: () => void;
271
+ }
272
+ export interface CheckoutControllerOptions {
273
+ clues: CountryClues;
274
+ /** Null on the Branding tab's preview: nothing is paid there. */
275
+ mutations: CheckoutMutations | null;
276
+ platform: CheckoutPlatform;
277
+ }
278
+ /** What Pay answers: refused with a reason, or an attempt started. */
279
+ export interface PayResult {
280
+ ok: boolean;
281
+ reason?: PayRefusalEnum;
282
+ }
283
+ /** The gateway calls the page makes; none on the Branding tab's preview. */
284
+ export interface CheckoutMutations {
285
+ pay: (args: {
286
+ paymentId: string;
287
+ method: string;
288
+ phone: string;
289
+ }) => Promise<PayResult>;
290
+ /** OTP methods: Pay with the payment code, which the server never stores. */
291
+ payWithCode: (args: {
292
+ paymentId: string;
293
+ method: string;
294
+ phone: string;
295
+ otp: string;
296
+ }) => Promise<PayResult>;
297
+ checkNow: (args: {
298
+ paymentId: string;
299
+ }) => Promise<null>;
300
+ /** The payer opened the link; the funnel counts the first time only. */
301
+ open: (args: {
302
+ paymentId: string;
303
+ }) => Promise<null>;
304
+ cancel: (args: {
305
+ paymentId: string;
306
+ }) => Promise<null>;
307
+ resend: (args: {
308
+ paymentId: string;
309
+ }) => Promise<{
310
+ ok: boolean;
311
+ }>;
312
+ simulate: (args: {
313
+ paymentId: string;
314
+ outcome: SimulatorOutcomeEnum;
315
+ }) => Promise<null>;
316
+ }
317
+ /** What the payer typed in the Simulator's stand-in card fields; it never leaves that page. */
318
+ export interface CardEntry {
319
+ number: string;
320
+ expiry: string;
321
+ cvc: string;
322
+ }
323
+ /** A card fields page's address: the payment, its method, and the look of the checkout that shows it. */
324
+ export interface CardFieldsSearch {
325
+ payment?: string;
326
+ method?: string;
327
+ /** The app colour, a hex code. */
328
+ color?: string;
329
+ theme?: CheckoutThemeEnum.DARK;
330
+ }
331
+ /** The Simulator's stand-in card fields page, from its address. */
332
+ export interface SimulatorCardFieldsProps {
333
+ /** Null when the page is opened on its own: nothing can be paid. */
334
+ paymentId: string | null;
335
+ method: string | null;
336
+ /** The app colour, a hex code. */
337
+ color: string | null;
338
+ dark: boolean;
339
+ }
340
+ /** What a card fields page and the checkout send each other (`CardFieldsMessageEnum`). */
341
+ export interface CardFieldsMessage {
342
+ type: CardFieldsMessageEnum;
343
+ complete?: boolean;
344
+ height?: number;
345
+ reason?: PayRefusalEnum;
346
+ }
347
+ /** How a Pay goes: the number, and the payment code of an OTP method. */
348
+ export interface PayVia {
349
+ phone: string;
350
+ otp?: string;
351
+ }
352
+ /** The Convex calls of the stand-in card fields page. */
353
+ export interface SimulatorCardFieldsCalls {
354
+ startCard: (args: {
355
+ paymentId: string;
356
+ method: string;
357
+ }) => Promise<{
358
+ ok: true;
359
+ reference: string;
360
+ providerReference: string | null;
361
+ } | {
362
+ ok: false;
363
+ reason: PayRefusalEnum;
364
+ }>;
365
+ receiveCard: (args: {
366
+ reference: string;
367
+ brand: string;
368
+ last4: string;
369
+ }) => Promise<null>;
370
+ checkNow: (args: {
371
+ paymentId: string;
372
+ }) => Promise<null>;
373
+ }
374
+ /** What each way of approving changes on the screens. */
375
+ export interface FlowTraits {
376
+ /** The tab its methods are on. */
377
+ tab: CheckoutTabEnum;
378
+ /** A prompt on the phone: the waiting screen's steps and "send it again". */
379
+ prompt: boolean;
380
+ /** What the Simulator offers that this flow's payer cannot do. */
381
+ hiddenOutcomes: Array<SimulatorOutcomeEnum>;
382
+ }
383
+ /** The checkout's themed colours (`--ck-*` in `checkout.css`), for a platform without the stylesheet. */
384
+ export interface CheckoutColors {
385
+ page: string;
386
+ surface: string;
387
+ tabOn: string;
388
+ fill: string;
389
+ fill2: string;
390
+ fill3: string;
391
+ ink: string;
392
+ inkStrong: string;
393
+ ink2: string;
394
+ muted: string;
395
+ faint: string;
396
+ line: string;
397
+ line2: string;
398
+ line3: string;
399
+ line4: string;
400
+ danger: string;
401
+ dangerSoft: string;
402
+ warnSoft: string;
403
+ warnLine: string;
404
+ warnInk: string;
405
+ warnInk2: string;
406
+ successInk: string;
407
+ }
408
+ export interface CheckoutPreviewApp {
409
+ name: string;
410
+ color: string;
411
+ logoUrl: string | null;
412
+ }
413
+ export interface SupportContact {
414
+ channel: SupportChannelEnum;
415
+ value: string;
416
+ href: string;
417
+ }
@@ -0,0 +1 @@
1
+ export {};