@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.
- package/LICENSE +21 -0
- package/README.md +180 -2
- package/assets/brand/paypal-wordmark.png +0 -0
- package/assets/fonts/Figtree-Bold.ttf +0 -0
- package/assets/fonts/Figtree-ExtraBold.ttf +0 -0
- package/assets/fonts/Figtree-Medium.ttf +0 -0
- package/assets/fonts/Figtree-Regular.ttf +0 -0
- package/assets/fonts/Figtree-SemiBold.ttf +0 -0
- package/assets/fonts/OFL.txt +93 -0
- package/assets/logos/airtel.png +0 -0
- package/assets/logos/app-store.png +0 -0
- package/assets/logos/apple-pay.png +0 -0
- package/assets/logos/at.png +0 -0
- package/assets/logos/bancontact.png +0 -0
- package/assets/logos/card.png +0 -0
- package/assets/logos/cb.png +0 -0
- package/assets/logos/celtiis.png +0 -0
- package/assets/logos/eps.png +0 -0
- package/assets/logos/feexpay.png +0 -0
- package/assets/logos/google-pay.png +0 -0
- package/assets/logos/google-play.png +0 -0
- package/assets/logos/iapkit.png +0 -0
- package/assets/logos/ideal.png +0 -0
- package/assets/logos/mastercard.png +0 -0
- package/assets/logos/mixx.png +0 -0
- package/assets/logos/moov.png +0 -0
- package/assets/logos/mtn.png +0 -0
- package/assets/logos/mybank.png +0 -0
- package/assets/logos/nexus.png +0 -0
- package/assets/logos/orange.png +0 -0
- package/assets/logos/pawapay.png +0 -0
- package/assets/logos/paypal.png +0 -0
- package/assets/logos/telecel.png +0 -0
- package/assets/logos/tnm.png +0 -0
- package/assets/logos/visa.png +0 -0
- package/assets/logos/vodacom.png +0 -0
- package/assets/logos/wave.png +0 -0
- package/dist/checkout-core/hooks/use-checkout-controller.d.ts +9 -0
- package/dist/checkout-core/hooks/use-checkout-controller.js +563 -0
- package/dist/checkout-core/hooks/use-checkout-payment.d.ts +9 -0
- package/dist/checkout-core/hooks/use-checkout-payment.js +136 -0
- package/dist/checkout-core/hooks/use-checkout-timers.d.ts +15 -0
- package/dist/checkout-core/hooks/use-checkout-timers.js +44 -0
- package/dist/checkout-core/hooks/use-phone-number.d.ts +7 -0
- package/dist/checkout-core/hooks/use-phone-number.js +82 -0
- package/dist/checkout-core/messages/en.d.ts +297 -0
- package/dist/checkout-core/messages/en.js +296 -0
- package/dist/checkout-core/messages/fr.d.ts +4 -0
- package/dist/checkout-core/messages/fr.js +297 -0
- package/dist/checkout-core/models/checkout.card.utils.d.ts +7 -0
- package/dist/checkout-core/models/checkout.card.utils.js +25 -0
- package/dist/checkout-core/models/checkout.constants.d.ts +101 -0
- package/dist/checkout-core/models/checkout.constants.js +339 -0
- package/dist/checkout-core/models/checkout.country.utils.d.ts +17 -0
- package/dist/checkout-core/models/checkout.country.utils.js +45 -0
- package/dist/checkout-core/models/checkout.enum.d.ts +230 -0
- package/dist/checkout-core/models/checkout.enum.js +256 -0
- package/dist/checkout-core/models/checkout.fetch.utils.d.ts +6 -0
- package/dist/checkout-core/models/checkout.fetch.utils.js +22 -0
- package/dist/checkout-core/models/checkout.interface.d.ts +696 -0
- package/dist/checkout-core/models/checkout.interface.js +1 -0
- package/dist/checkout-core/models/checkout.money.utils.d.ts +7 -0
- package/dist/checkout-core/models/checkout.money.utils.js +21 -0
- package/dist/checkout-core/models/checkout.phone.utils.d.ts +33 -0
- package/dist/checkout-core/models/checkout.phone.utils.js +159 -0
- package/dist/checkout-core/models/checkout.view.utils.d.ts +77 -0
- package/dist/checkout-core/models/checkout.view.utils.js +328 -0
- package/dist/checkout-core/models/domain.enum.d.ts +106 -0
- package/dist/checkout-core/models/domain.enum.js +113 -0
- package/dist/components/BrissotoPayProvider.d.ts +8 -0
- package/dist/components/BrissotoPayProvider.js +39 -0
- package/dist/components/PaymentSheetModal.d.ts +9 -0
- package/dist/components/PaymentSheetModal.js +106 -0
- package/dist/components/SheetBone.d.ts +3 -0
- package/dist/components/SheetBone.js +12 -0
- package/dist/components/SheetButton.d.ts +7 -0
- package/dist/components/SheetButton.js +47 -0
- package/dist/components/SheetCardFields.d.ts +10 -0
- package/dist/components/SheetCardFields.js +86 -0
- package/dist/components/SheetChosenMethod.d.ts +3 -0
- package/dist/components/SheetChosenMethod.js +60 -0
- package/dist/components/SheetCodeField.d.ts +8 -0
- package/dist/components/SheetCodeField.js +98 -0
- package/dist/components/SheetContent.d.ts +3 -0
- package/dist/components/SheetContent.js +132 -0
- package/dist/components/SheetDial.d.ts +7 -0
- package/dist/components/SheetDial.js +36 -0
- package/dist/components/SheetFailed.d.ts +3 -0
- package/dist/components/SheetFailed.js +44 -0
- package/dist/components/SheetForm.d.ts +8 -0
- package/dist/components/SheetForm.js +139 -0
- package/dist/components/SheetGrabber.d.ts +2 -0
- package/dist/components/SheetGrabber.js +17 -0
- package/dist/components/SheetHeader.d.ts +7 -0
- package/dist/components/SheetHeader.js +83 -0
- package/dist/components/SheetIcon.d.ts +3 -0
- package/dist/components/SheetIcon.js +78 -0
- package/dist/components/SheetLayout.d.ts +11 -0
- package/dist/components/SheetLayout.js +63 -0
- package/dist/components/SheetLogo.d.ts +3 -0
- package/dist/components/SheetLogo.js +20 -0
- package/dist/components/SheetMessage.d.ts +3 -0
- package/dist/components/SheetMessage.js +15 -0
- package/dist/components/SheetMethodCard.d.ts +3 -0
- package/dist/components/SheetMethodCard.js +71 -0
- package/dist/components/SheetNameField.d.ts +7 -0
- package/dist/components/SheetNameField.js +48 -0
- package/dist/components/SheetPaypalButton.d.ts +3 -0
- package/dist/components/SheetPaypalButton.js +23 -0
- package/dist/components/SheetPhoneField.d.ts +3 -0
- package/dist/components/SheetPhoneField.js +59 -0
- package/dist/components/SheetPillSelect.d.ts +7 -0
- package/dist/components/SheetPillSelect.js +134 -0
- package/dist/components/SheetRow.d.ts +3 -0
- package/dist/components/SheetRow.js +28 -0
- package/dist/components/SheetSimulator.d.ts +6 -0
- package/dist/components/SheetSimulator.js +40 -0
- package/dist/components/SheetSkeleton.d.ts +5 -0
- package/dist/components/SheetSkeleton.js +23 -0
- package/dist/components/SheetStep.d.ts +6 -0
- package/dist/components/SheetStep.js +21 -0
- package/dist/components/SheetStoreTab.d.ts +7 -0
- package/dist/components/SheetStoreTab.js +27 -0
- package/dist/components/SheetSuccess.d.ts +3 -0
- package/dist/components/SheetSuccess.js +51 -0
- package/dist/components/SheetSummary.d.ts +3 -0
- package/dist/components/SheetSummary.js +32 -0
- package/dist/components/SheetTerminal.d.ts +3 -0
- package/dist/components/SheetTerminal.js +21 -0
- package/dist/components/SheetText.d.ts +5 -0
- package/dist/components/SheetText.js +27 -0
- package/dist/components/SheetToast.d.ts +7 -0
- package/dist/components/SheetToast.js +71 -0
- package/dist/components/SheetWaiting.d.ts +7 -0
- package/dist/components/SheetWaiting.js +88 -0
- package/dist/hooks/use-native-platform.d.ts +10 -0
- package/dist/hooks/use-native-platform.js +71 -0
- package/dist/hooks/use-payment-sheet.d.ts +4 -0
- package/dist/hooks/use-payment-sheet.js +10 -0
- package/dist/hooks/use-shake.d.ts +3 -0
- package/dist/hooks/use-shake.js +18 -0
- package/dist/hooks/use-sheet-motion.d.ts +7 -0
- package/dist/hooks/use-sheet-motion.js +62 -0
- package/dist/hooks/use-sheet-resize.d.ts +6 -0
- package/dist/hooks/use-sheet-resize.js +15 -0
- package/dist/hooks/use-sheet-room.d.ts +4 -0
- package/dist/hooks/use-sheet-room.js +8 -0
- package/dist/hooks/use-sheet-theme.d.ts +4 -0
- package/dist/hooks/use-sheet-theme.js +12 -0
- package/dist/hooks/use-step-slide.d.ts +16 -0
- package/dist/hooks/use-step-slide.js +50 -0
- package/dist/hooks/use-store-recovery.d.ts +9 -0
- package/dist/hooks/use-store-recovery.js +50 -0
- package/dist/hooks/use-store-tab.d.ts +11 -0
- package/dist/hooks/use-store-tab.js +112 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +2 -0
- package/dist/models/sheet.constants.d.ts +125 -0
- package/dist/models/sheet.constants.js +204 -0
- package/dist/models/sheet.enum.d.ts +46 -0
- package/dist/models/sheet.enum.js +53 -0
- package/dist/models/sheet.interface.d.ts +423 -0
- package/dist/models/sheet.interface.js +1 -0
- package/dist/models/sheet.utils.d.ts +68 -0
- package/dist/models/sheet.utils.js +211 -0
- package/dist/services/checkout.service.d.ts +15 -0
- package/dist/services/checkout.service.js +96 -0
- package/dist/services/provider-window.service.d.ts +13 -0
- package/dist/services/provider-window.service.js +53 -0
- package/dist/services/store.service.d.ts +36 -0
- package/dist/services/store.service.js +107 -0
- package/package.json +73 -4
|
@@ -0,0 +1,423 @@
|
|
|
1
|
+
import type { ReactNode, Ref, RefObject } from 'react';
|
|
2
|
+
import type { Animated, DimensionValue, GestureResponderHandlers, StyleProp, TextInputInstance, TextInputProps, TextProps, TextStyle } from 'react-native';
|
|
3
|
+
import type { WebView } from 'react-native-webview';
|
|
4
|
+
import type { CheckoutButtonVariantEnum, PhoneStoreEnum, TerminalKindEnum } from '../checkout-core/models/checkout.enum.js';
|
|
5
|
+
import type { LangEnum, ProviderLogoEnum } from '../checkout-core/models/domain.enum.js';
|
|
6
|
+
import type { CardFieldsMessage, CheckoutColors, CheckoutCore, CheckoutToast, CheckoutConnection, CheckoutPayment, CheckoutPlatform, CheckoutView, Price } from '../checkout-core/models/checkout.interface.js';
|
|
7
|
+
import type { FigtreeEnum, SheetIconEnum, StoreProductTypeEnum, WebBrowserResultEnum } from './sheet.enum.js';
|
|
8
|
+
/**
|
|
9
|
+
* How the sheet ended. `closed`: the payer closed it with the payment still
|
|
10
|
+
* open. A hint only: ship on `payment.paid` from the webhook or `getPayment`.
|
|
11
|
+
*/
|
|
12
|
+
export type PaymentSheetStatus = 'paid' | 'pending' | 'cancelled' | 'expired' | 'locked' | 'refunded' | 'closed';
|
|
13
|
+
/** Why the sheet could not show the payment: no payment has this id, or it could not load. */
|
|
14
|
+
export type PaymentSheetError = 'not_found' | 'network';
|
|
15
|
+
export interface PaymentSheetResult {
|
|
16
|
+
status: PaymentSheetStatus;
|
|
17
|
+
error?: PaymentSheetError;
|
|
18
|
+
}
|
|
19
|
+
export interface PresentPaymentOptions {
|
|
20
|
+
/** The payment id the app's server got from the server SDK (`pay_…`). */
|
|
21
|
+
paymentId: string;
|
|
22
|
+
}
|
|
23
|
+
export interface PaymentSheet {
|
|
24
|
+
/** Opens the sheet for one payment; resolves when it closes. A second call while one is open rejects. */
|
|
25
|
+
presentPayment: (options: PresentPaymentOptions) => Promise<PaymentSheetResult>;
|
|
26
|
+
}
|
|
27
|
+
export interface BrissotoPayProviderProps {
|
|
28
|
+
/** The Brissoto Pay backend; the production one by default. One backend serves Live and Test. */
|
|
29
|
+
url?: string;
|
|
30
|
+
children?: ReactNode;
|
|
31
|
+
}
|
|
32
|
+
/** The sheet the app asked for, and how to answer it. */
|
|
33
|
+
export interface SheetRequest {
|
|
34
|
+
paymentId: string;
|
|
35
|
+
/** False once closed: the sheet slides away showing its last screen. */
|
|
36
|
+
open: boolean;
|
|
37
|
+
resolve: (result: PaymentSheetResult) => void;
|
|
38
|
+
}
|
|
39
|
+
/** The sheet's calls: the checkout's, and the payer's country, which the web reads on its own server. */
|
|
40
|
+
export interface SheetConnection extends CheckoutConnection {
|
|
41
|
+
/** The country of the payer's connection, from Cloudflare (`be`); null when unknown, failed or late. */
|
|
42
|
+
ipCountry: () => Promise<string | null>;
|
|
43
|
+
}
|
|
44
|
+
export interface PaymentSheetModalProps {
|
|
45
|
+
connection: SheetConnection;
|
|
46
|
+
request: SheetRequest;
|
|
47
|
+
onClose: (result: PaymentSheetResult) => void;
|
|
48
|
+
}
|
|
49
|
+
export interface SheetContentProps {
|
|
50
|
+
payment: CheckoutPayment;
|
|
51
|
+
/** Fonts still loading: the sheet shows its skeleton. */
|
|
52
|
+
fontsReady: boolean;
|
|
53
|
+
deviceLocale: string;
|
|
54
|
+
/** The connection's country (`be`), null without one; `undefined` while it is asked: the sheet shows its skeleton. */
|
|
55
|
+
ipCountry: string | null | undefined;
|
|
56
|
+
onClose: () => void;
|
|
57
|
+
/** On the sheet's top: dragged down, the sheet follows, and far enough it closes. */
|
|
58
|
+
dragHandlers: GestureResponderHandlers;
|
|
59
|
+
/** Set by the sheet: Android's back, first offered to it; true when it went back a step. */
|
|
60
|
+
backRef: RefObject<(() => boolean) | null>;
|
|
61
|
+
}
|
|
62
|
+
/** How the bottom sheet moves: up when it opens, with the finger, away once closed. */
|
|
63
|
+
export interface SheetMotion {
|
|
64
|
+
/** Still on screen: open, or sliding away. */
|
|
65
|
+
shown: boolean;
|
|
66
|
+
/** How far below its place the sheet is drawn. */
|
|
67
|
+
translateY: Animated.AnimatedAddition;
|
|
68
|
+
/** The dim over the app, lighter as the sheet goes down. */
|
|
69
|
+
dim: Animated.AnimatedInterpolation<number>;
|
|
70
|
+
dragHandlers: GestureResponderHandlers;
|
|
71
|
+
/** Room left above the sheet at its tallest, in points. */
|
|
72
|
+
topGap: number;
|
|
73
|
+
}
|
|
74
|
+
/** The sheet's look: the checkout colours of its theme and the app's colour. */
|
|
75
|
+
export interface SheetTheme {
|
|
76
|
+
colors: CheckoutColors;
|
|
77
|
+
brand: string;
|
|
78
|
+
dark: boolean;
|
|
79
|
+
}
|
|
80
|
+
export interface SheetTextProps extends TextProps {
|
|
81
|
+
weight?: FigtreeEnum;
|
|
82
|
+
size?: number;
|
|
83
|
+
color?: string;
|
|
84
|
+
/** Text that may wrap: lines spaced as on the web checkout. */
|
|
85
|
+
paragraph?: boolean;
|
|
86
|
+
style?: StyleProp<TextStyle>;
|
|
87
|
+
}
|
|
88
|
+
export interface SheetHeaderProps {
|
|
89
|
+
view: CheckoutView | null | undefined;
|
|
90
|
+
/** Bones for the logo and name; close works from the first frame. */
|
|
91
|
+
loading: boolean;
|
|
92
|
+
onClose: () => void;
|
|
93
|
+
/** On the details: back to the methods, by an arrow before the app. */
|
|
94
|
+
onBack?: () => void;
|
|
95
|
+
dragHandlers: GestureResponderHandlers;
|
|
96
|
+
}
|
|
97
|
+
export interface SheetSummaryProps {
|
|
98
|
+
/** What the payer pays: the picked method's price (ADR 0012). */
|
|
99
|
+
total: Price;
|
|
100
|
+
}
|
|
101
|
+
export interface SheetPaypalButtonProps {
|
|
102
|
+
busy: boolean;
|
|
103
|
+
onPress: () => void;
|
|
104
|
+
}
|
|
105
|
+
export interface SheetInputProps extends TextInputProps {
|
|
106
|
+
ref?: Ref<TextInputInstance>;
|
|
107
|
+
}
|
|
108
|
+
/** A dead end: what happened, why, and its sign. */
|
|
109
|
+
export interface SheetMessageProps {
|
|
110
|
+
title: string;
|
|
111
|
+
body: string;
|
|
112
|
+
/** A ban sign by default: a payment the sheet cannot show. */
|
|
113
|
+
icon?: SheetIconEnum;
|
|
114
|
+
/** The lock is red. */
|
|
115
|
+
danger?: boolean;
|
|
116
|
+
}
|
|
117
|
+
/** A screen the payer cannot act on (expired, cancelled, locked, nothing to pay with). */
|
|
118
|
+
export interface SheetTerminalProps extends SheetClosingProps {
|
|
119
|
+
kind: TerminalKindEnum;
|
|
120
|
+
}
|
|
121
|
+
/** The room the sheet has for what scrolls, as its parts read it. */
|
|
122
|
+
export interface SheetRoom {
|
|
123
|
+
/** How tall a part at the end may be and still show whole: null while everything shows. */
|
|
124
|
+
room: number | null;
|
|
125
|
+
/** Holds what scrolls at its end, where the part that grew is, until let go: that part scrolls itself. */
|
|
126
|
+
pinEnd: (pinned: boolean) => void;
|
|
127
|
+
}
|
|
128
|
+
/** A screen of the sheet: what scrolls, then what stays pinned at the bottom above "Payment secured by". */
|
|
129
|
+
export interface SheetLayoutProps {
|
|
130
|
+
children: ReactNode;
|
|
131
|
+
foot?: ReactNode;
|
|
132
|
+
/** "Payment secured by Brissoto Pay" under the foot: once a payment shows. */
|
|
133
|
+
secure?: boolean;
|
|
134
|
+
}
|
|
135
|
+
/** A screen drawn from the shared checkout controller. */
|
|
136
|
+
export interface SheetScreenProps {
|
|
137
|
+
core: CheckoutCore;
|
|
138
|
+
}
|
|
139
|
+
/** A screen that can close the sheet itself (Done, Return to the app). */
|
|
140
|
+
export interface SheetClosingProps extends SheetScreenProps {
|
|
141
|
+
onClose: () => void;
|
|
142
|
+
}
|
|
143
|
+
export interface SheetPhoneFieldProps extends SheetScreenProps {
|
|
144
|
+
/** The number field, so a Pay with a wrong number can bring it to the payer. */
|
|
145
|
+
phoneRef: Ref<TextInputInstance>;
|
|
146
|
+
}
|
|
147
|
+
export interface SheetStepProps extends SheetScreenProps {
|
|
148
|
+
/** The number field, brought up once the payer moves on to it. */
|
|
149
|
+
phoneRef: RefObject<TextInputInstance | null>;
|
|
150
|
+
children: ReactNode;
|
|
151
|
+
}
|
|
152
|
+
export interface SheetFormProps extends SheetPhoneFieldProps {
|
|
153
|
+
cardFields: CardFieldsBridge;
|
|
154
|
+
/** The phone's store, when it sells the payment's product: a third tab. */
|
|
155
|
+
store: StoreTab | null;
|
|
156
|
+
}
|
|
157
|
+
/** The card fields' WebView, and the way what its page says reaches the core. */
|
|
158
|
+
export interface CardFieldsBridge {
|
|
159
|
+
/** `WebView<object>`: its default `WebView<undefined>` types no props. */
|
|
160
|
+
page: RefObject<WebView<object> | null>;
|
|
161
|
+
/** A message the card fields page sent, already checked to come from it. */
|
|
162
|
+
receive: (message: CardFieldsMessage) => void;
|
|
163
|
+
}
|
|
164
|
+
/** What only the phone does for the checkout core, and the card fields' end of it. */
|
|
165
|
+
export interface NativePlatform {
|
|
166
|
+
platform: CheckoutPlatform;
|
|
167
|
+
cardFields: CardFieldsBridge;
|
|
168
|
+
}
|
|
169
|
+
export interface SheetCardFieldsProps extends SheetScreenProps {
|
|
170
|
+
bridge: CardFieldsBridge;
|
|
171
|
+
}
|
|
172
|
+
export interface SheetButtonProps {
|
|
173
|
+
label: string;
|
|
174
|
+
onPress: () => void;
|
|
175
|
+
variant?: CheckoutButtonVariantEnum;
|
|
176
|
+
/** On its way: a spinner, and no second press. */
|
|
177
|
+
busy?: boolean;
|
|
178
|
+
disabled?: boolean;
|
|
179
|
+
/** Looks off but still answers: Pay says what is missing. */
|
|
180
|
+
inactive?: boolean;
|
|
181
|
+
}
|
|
182
|
+
/** A brand tile: the provider's logo, square, at one of `LOGO_SIZE`. */
|
|
183
|
+
export interface SheetLogoProps {
|
|
184
|
+
logo: ProviderLogoEnum;
|
|
185
|
+
size?: number;
|
|
186
|
+
/** Greyed with its method. */
|
|
187
|
+
muted?: boolean;
|
|
188
|
+
}
|
|
189
|
+
/** One method in the grid: its logo, name, network or why it is greyed, and a radio dot. */
|
|
190
|
+
export interface MethodCardProps {
|
|
191
|
+
logo: ProviderLogoEnum;
|
|
192
|
+
name: string;
|
|
193
|
+
sub: string;
|
|
194
|
+
/** Greyed and not pressable: in maintenance, or not offered yet. */
|
|
195
|
+
muted: boolean;
|
|
196
|
+
/** The method picked: ringed in the brand colour, its dot ticked. */
|
|
197
|
+
checked: boolean;
|
|
198
|
+
/** Continue was pressed with no method picked: the card is ringed in red. */
|
|
199
|
+
missing?: boolean;
|
|
200
|
+
/** The only method of the tab: a full-width row. */
|
|
201
|
+
alone?: boolean;
|
|
202
|
+
onSelect?: () => void;
|
|
203
|
+
}
|
|
204
|
+
export interface ChosenMethodProps {
|
|
205
|
+
logo: ProviderLogoEnum;
|
|
206
|
+
name: string;
|
|
207
|
+
/** Its network. */
|
|
208
|
+
sub: string;
|
|
209
|
+
/** Back to the methods. */
|
|
210
|
+
onChange: () => void;
|
|
211
|
+
}
|
|
212
|
+
export interface MethodGridCard extends MethodCardProps {
|
|
213
|
+
id: string;
|
|
214
|
+
}
|
|
215
|
+
/** The other countries' bank redirects, under "Paying from another country?" (ADR 0014). */
|
|
216
|
+
export interface OtherBanks {
|
|
217
|
+
cards: Array<MethodGridCard>;
|
|
218
|
+
/** Shown: the link was pressed, or one of them is picked. */
|
|
219
|
+
open: boolean;
|
|
220
|
+
onOpen: () => void;
|
|
221
|
+
}
|
|
222
|
+
export interface MethodGridProps {
|
|
223
|
+
cards: Array<MethodGridCard>;
|
|
224
|
+
/** On the Card tab of a guessed payer country only. */
|
|
225
|
+
others?: OtherBanks;
|
|
226
|
+
/** Continue presses with no method picked: red, and a shake per press. */
|
|
227
|
+
missing: number;
|
|
228
|
+
}
|
|
229
|
+
export interface GridRowsProps {
|
|
230
|
+
cards: Array<MethodGridCard>;
|
|
231
|
+
missing: boolean;
|
|
232
|
+
/** The only card: a full-width row. */
|
|
233
|
+
alone: boolean;
|
|
234
|
+
}
|
|
235
|
+
/** One choice of a pill's list: its value, its name and the flag before it. */
|
|
236
|
+
export interface SheetPillOption<T extends string> {
|
|
237
|
+
value: T;
|
|
238
|
+
label: string;
|
|
239
|
+
flag?: string;
|
|
240
|
+
}
|
|
241
|
+
/** What a pill and its list share: the choices, the current one, and what is chosen. */
|
|
242
|
+
export interface SheetPillChoices<T extends string> {
|
|
243
|
+
/** One of the options. */
|
|
244
|
+
value: T;
|
|
245
|
+
options: Array<SheetPillOption<T>>;
|
|
246
|
+
/** Called with a choice other than the current one. */
|
|
247
|
+
onChange: (value: T) => void;
|
|
248
|
+
/** What is chosen, read with the current value; the list's title. */
|
|
249
|
+
accessibilityLabel: string;
|
|
250
|
+
}
|
|
251
|
+
/** A rounded pill showing the current choice and a chevron; pressed, it lists the choices over the sheet. */
|
|
252
|
+
export interface SheetPillSelectProps<T extends string> extends SheetPillChoices<T> {
|
|
253
|
+
disabled?: boolean;
|
|
254
|
+
}
|
|
255
|
+
/** The pill's list, over the sheet: the current choice filled and ticked. */
|
|
256
|
+
export interface SheetPillListProps<T extends string> extends SheetPillChoices<T> {
|
|
257
|
+
open: boolean;
|
|
258
|
+
onClose: () => void;
|
|
259
|
+
}
|
|
260
|
+
export interface SheetIconProps {
|
|
261
|
+
kind: SheetIconEnum;
|
|
262
|
+
color: string;
|
|
263
|
+
/** The disc behind it. */
|
|
264
|
+
background: string;
|
|
265
|
+
/** The disc's side; the sign grows with it. */
|
|
266
|
+
size?: number;
|
|
267
|
+
}
|
|
268
|
+
/** A label and its value, one row of a receipt or a waiting payment. */
|
|
269
|
+
export interface SheetRowProps {
|
|
270
|
+
label: string;
|
|
271
|
+
children: ReactNode;
|
|
272
|
+
/** The value in the danger colour: the last seconds of the clock. */
|
|
273
|
+
urgent?: boolean;
|
|
274
|
+
}
|
|
275
|
+
export interface SheetToastProps {
|
|
276
|
+
toast: CheckoutToast | null;
|
|
277
|
+
}
|
|
278
|
+
export interface BoneProps {
|
|
279
|
+
/** Points, or a share of the row (`100%`). */
|
|
280
|
+
width: DimensionValue;
|
|
281
|
+
height: number;
|
|
282
|
+
radius?: number;
|
|
283
|
+
}
|
|
284
|
+
/** What the card fields page's address carries. */
|
|
285
|
+
export interface CardFieldsAddress {
|
|
286
|
+
/** Where the checkout is served (`CheckoutView.siteUrl`). */
|
|
287
|
+
siteUrl: string;
|
|
288
|
+
/** The method's `cardFieldsPath`. */
|
|
289
|
+
path: string;
|
|
290
|
+
paymentId: string;
|
|
291
|
+
method: string;
|
|
292
|
+
/** The app colour, a hex code. */
|
|
293
|
+
color: string;
|
|
294
|
+
dark: boolean;
|
|
295
|
+
lang: LangEnum;
|
|
296
|
+
}
|
|
297
|
+
/** How an in-app browser closed, as expo-web-browser says it. */
|
|
298
|
+
export interface WebBrowserResult {
|
|
299
|
+
/** `opened` on Android, at once: closing is then seen as the app coming back. */
|
|
300
|
+
type: WebBrowserResultEnum;
|
|
301
|
+
}
|
|
302
|
+
/** What the sheet uses of expo-web-browser, when the app installed it: PayPal's window. */
|
|
303
|
+
export interface ExpoWebBrowser {
|
|
304
|
+
openBrowserAsync: (url: string) => Promise<WebBrowserResult>;
|
|
305
|
+
dismissBrowser: () => unknown;
|
|
306
|
+
}
|
|
307
|
+
/** What the sheet uses of expo-iap, when the app installed it. */
|
|
308
|
+
export interface ExpoIap {
|
|
309
|
+
/** Connects to the store's billing: Google Play reads its country through it. */
|
|
310
|
+
initConnection: () => Promise<boolean>;
|
|
311
|
+
/** The store account's country: alpha-3 on the App Store, alpha-2 on Google Play. */
|
|
312
|
+
getStorefront: () => Promise<string>;
|
|
313
|
+
/** The store's products with these ids; Google Play also answers for one it does not sell. */
|
|
314
|
+
fetchProducts: (request: StoreProductRequest) => Promise<Array<StoreProduct> | null>;
|
|
315
|
+
/** Opens the store's sheet; how it ends comes through the listeners. */
|
|
316
|
+
requestPurchase: (props: StorePurchaseRequest) => Promise<unknown>;
|
|
317
|
+
/** iOS: the App Store's unfinished transactions, replayed until finished. */
|
|
318
|
+
getPendingTransactionsIOS: () => Promise<Array<StorePurchase>>;
|
|
319
|
+
/** Android: Google Play's purchases not consumed yet. */
|
|
320
|
+
getAvailablePurchases: () => Promise<Array<StorePurchase>>;
|
|
321
|
+
/** Takes the purchase off the store's queue: a consumable can be bought again. */
|
|
322
|
+
finishTransaction: (args: {
|
|
323
|
+
purchase: StorePurchase;
|
|
324
|
+
isConsumable?: boolean;
|
|
325
|
+
}) => Promise<unknown>;
|
|
326
|
+
purchaseUpdatedListener: (listener: (purchase: StorePurchase) => void) => StoreSubscription;
|
|
327
|
+
purchaseErrorListener: (listener: (error: StorePurchaseError) => void) => StoreSubscription;
|
|
328
|
+
}
|
|
329
|
+
export interface StoreProductRequest {
|
|
330
|
+
skus: Array<string>;
|
|
331
|
+
type?: StoreProductTypeEnum;
|
|
332
|
+
}
|
|
333
|
+
/** A product as the store sells it on this phone (expo-iap's `Product`, the part read). */
|
|
334
|
+
export interface StoreProduct {
|
|
335
|
+
id: string;
|
|
336
|
+
/** The price as the store shows it: `$1.99`, `1 200 F CFA`. */
|
|
337
|
+
displayPrice: string;
|
|
338
|
+
/** Google Play: whether it sells it (`StoreProductStatusEnum`); unset on the App Store. */
|
|
339
|
+
productStatusAndroid?: string | null;
|
|
340
|
+
}
|
|
341
|
+
/** What a store's sheet gave (expo-iap's `Purchase`, the part read). */
|
|
342
|
+
export interface StorePurchase {
|
|
343
|
+
productId: string;
|
|
344
|
+
/** The App Store's JWS, or Google Play's purchase token. */
|
|
345
|
+
purchaseToken?: string | null;
|
|
346
|
+
/** `purchased`, or `pending` until someone approves it. */
|
|
347
|
+
purchaseState: string;
|
|
348
|
+
/** iOS: the token the sheet had the store carry. */
|
|
349
|
+
appAccountToken?: string | null;
|
|
350
|
+
/** Android: the same token. */
|
|
351
|
+
obfuscatedAccountIdAndroid?: string | null;
|
|
352
|
+
transactionId?: string | null;
|
|
353
|
+
}
|
|
354
|
+
export interface StorePurchaseError {
|
|
355
|
+
/** expo-iap's `ErrorCode`: `user-cancelled`, `deferred-payment`… */
|
|
356
|
+
code: string;
|
|
357
|
+
message: string;
|
|
358
|
+
}
|
|
359
|
+
/** One product bought once, for one attempt, on either store. */
|
|
360
|
+
export interface StorePurchaseRequest {
|
|
361
|
+
type: StoreProductTypeEnum;
|
|
362
|
+
request: {
|
|
363
|
+
apple: {
|
|
364
|
+
sku: string;
|
|
365
|
+
appAccountToken: string;
|
|
366
|
+
};
|
|
367
|
+
google: {
|
|
368
|
+
skus: Array<string>;
|
|
369
|
+
obfuscatedAccountId: string;
|
|
370
|
+
};
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
export interface StoreSubscription {
|
|
374
|
+
remove: () => void;
|
|
375
|
+
}
|
|
376
|
+
/** A store as its tab shows it: its own name (a brand) and tile. */
|
|
377
|
+
export interface StoreTabSpec {
|
|
378
|
+
name: string;
|
|
379
|
+
logo: ProviderLogoEnum;
|
|
380
|
+
}
|
|
381
|
+
/** What the store sells the payment's product for on this phone. */
|
|
382
|
+
export interface StoreOffer {
|
|
383
|
+
productId: string;
|
|
384
|
+
displayPrice: string;
|
|
385
|
+
}
|
|
386
|
+
/** The store tab, once this phone's store sells the payment's product. */
|
|
387
|
+
export interface StoreTab {
|
|
388
|
+
store: PhoneStoreEnum;
|
|
389
|
+
offer: StoreOffer;
|
|
390
|
+
/** Opens the store's sheet for a new attempt. */
|
|
391
|
+
buy: () => void;
|
|
392
|
+
/** The tab showed the refund consent line: the next attempt says so. */
|
|
393
|
+
onConsentShown: () => void;
|
|
394
|
+
}
|
|
395
|
+
/** Whether the store attempt a recovered purchase names has paid. */
|
|
396
|
+
export interface RecoveredPurchase {
|
|
397
|
+
paid: boolean;
|
|
398
|
+
}
|
|
399
|
+
/** A purchase the app never reported, as a start sends it again. */
|
|
400
|
+
export interface UnreportedPurchase {
|
|
401
|
+
/** The token of the attempt it was made for. */
|
|
402
|
+
token: string;
|
|
403
|
+
/** The App Store's JWS, or Google Play's purchase token. */
|
|
404
|
+
purchase: string;
|
|
405
|
+
}
|
|
406
|
+
/** The calls that recover unreported store purchases on start (ADR 0007). */
|
|
407
|
+
export interface StoreRecovery {
|
|
408
|
+
/** Sends one again; `ok` false when the gateway has no attempt for it. */
|
|
409
|
+
recover: (args: UnreportedPurchase) => Promise<{
|
|
410
|
+
ok: boolean;
|
|
411
|
+
}>;
|
|
412
|
+
/** Follows its attempt live, each answer to `onAnswer`; answers how to stop. */
|
|
413
|
+
follow: (token: string, onAnswer: (answer: RecoveredPurchase | null) => void) => () => void;
|
|
414
|
+
}
|
|
415
|
+
/** The attempt a store's sheet is open for. */
|
|
416
|
+
export interface StoreSheetAttempt {
|
|
417
|
+
reference: string;
|
|
418
|
+
token: string;
|
|
419
|
+
productId: string;
|
|
420
|
+
}
|
|
421
|
+
export interface SheetStoreTabProps {
|
|
422
|
+
store: StoreTab;
|
|
423
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { CheckoutThemeEnum, StoreSheetOutcomeEnum } from '../checkout-core/models/checkout.enum.js';
|
|
2
|
+
import { LangEnum } from '../checkout-core/models/domain.enum.js';
|
|
3
|
+
import type { CountryEnum } from '../checkout-core/models/domain.enum.js';
|
|
4
|
+
import type { CardFieldsMessage, CheckoutView } from '../checkout-core/models/checkout.interface.js';
|
|
5
|
+
import type { CardFieldsAddress, PaymentSheetResult, StorePurchase, StoreSheetAttempt, UnreportedPurchase } from './sheet.interface.js';
|
|
6
|
+
/** The payment's language, else the device's when the sheet speaks it, else English. */
|
|
7
|
+
export declare function sheetLanguage(payment: LangEnum | null, deviceLocale: string): LangEnum;
|
|
8
|
+
/** The payment's theme, else the device's scheme. */
|
|
9
|
+
export declare function sheetTheme(payment: CheckoutThemeEnum | null, scheme: string | null | undefined): CheckoutThemeEnum;
|
|
10
|
+
/** What `presentPayment` answers when the sheet closes on this payment. */
|
|
11
|
+
export declare function sheetResult(view: CheckoutView | null | undefined, failed: boolean): PaymentSheetResult;
|
|
12
|
+
/** `cm` → 🇨🇲: the country's flag, as the phone draws it. */
|
|
13
|
+
export declare function flagOf(country: CountryEnum): string;
|
|
14
|
+
/**
|
|
15
|
+
* Where a pill's list opens: the current row second from the top, the one
|
|
16
|
+
* before it showing there is more above, and never past the end, so a row
|
|
17
|
+
* near the end leaves no empty room under the list.
|
|
18
|
+
*/
|
|
19
|
+
export declare function pillListOffset(current: number, count: number, viewHeight: number): number;
|
|
20
|
+
/**
|
|
21
|
+
* The card fields page the sheet loads: English under `/en`, French the bare
|
|
22
|
+
* path asking for French (as the checkout link does), with the payment, the
|
|
23
|
+
* method and the sheet's look.
|
|
24
|
+
*/
|
|
25
|
+
export declare function cardFieldsUrl({ siteUrl, path, paymentId, method, color, dark, lang, }: CardFieldsAddress): string;
|
|
26
|
+
/** `https://pay.brissoto.com/en/checkout` → `https://pay.brissoto.com`; null for anything not on the web. */
|
|
27
|
+
export declare function originOf(url: string): string | null;
|
|
28
|
+
/** The card fields page itself, in either language: the one page its WebView may load. */
|
|
29
|
+
export declare function isCardFieldsPage(url: string, page: string): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* What the card fields page said, as the core reads it, when it is one of
|
|
32
|
+
* its messages; anything else, Pay itself included, is dropped.
|
|
33
|
+
*/
|
|
34
|
+
export declare function cardFieldsMessageOf(data: string): CardFieldsMessage | null;
|
|
35
|
+
/**
|
|
36
|
+
* Runs in the card fields page before it loads. At the top of a WebView the
|
|
37
|
+
* page tells its checkout by posting to itself: what it posts from its own
|
|
38
|
+
* origin goes on to the sheet, Pay (which only the sheet sends) aside. While
|
|
39
|
+
* a bank's 3D Secure page shows, the page keeps its size: on iOS its field
|
|
40
|
+
* under 16px would zoom it on focus, past the sheet's edges (the last
|
|
41
|
+
* viewport tag wins). Gone, the payer may pinch again.
|
|
42
|
+
*/
|
|
43
|
+
export declare function cardFieldsBridge(): string;
|
|
44
|
+
/** Tells the card fields page that Pay was pressed, as the web checkout does. */
|
|
45
|
+
export declare function cardFieldsSubmit(): string;
|
|
46
|
+
/** Letting go of the sheet's top `dy` points lower, at `vy` points per ms: far enough, or flicked, it closes. */
|
|
47
|
+
export declare function sheetSwipeCloses(dy: number, vy: number): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* A purchase is the attempt's when it is of its product and carries its
|
|
50
|
+
* token: any other (an earlier one the store replays) is left to the next
|
|
51
|
+
* start, which recovers it.
|
|
52
|
+
*/
|
|
53
|
+
export declare function isAttemptPurchase(purchase: StorePurchase, attempt: StoreSheetAttempt): boolean;
|
|
54
|
+
/**
|
|
55
|
+
* A purchase the store holds unfinished, as the gateway takes it again: a
|
|
56
|
+
* paid one carrying a token of ours. Null for any other (the app's own
|
|
57
|
+
* purchases, one still waiting for approval): it is left alone.
|
|
58
|
+
*/
|
|
59
|
+
export declare function unreportedPurchaseOf(purchase: StorePurchase): UnreportedPurchase | null;
|
|
60
|
+
/** How the store's sheet ended, from its error: closed, waiting for approval, or failed. */
|
|
61
|
+
export declare function sheetOutcomeOf(code: string): StoreSheetOutcomeEnum;
|
|
62
|
+
/**
|
|
63
|
+
* A call the sheet does not wait on: one that fails changes nothing, the
|
|
64
|
+
* next start (or status check) picks it up.
|
|
65
|
+
*/
|
|
66
|
+
export declare function quietly(call: Promise<unknown>): void;
|
|
67
|
+
/** What `read` answers within `ms`; null when it fails or is later. */
|
|
68
|
+
export declare function answerWithin<TAnswer>(read: () => Promise<TAnswer>, ms: number): Promise<TAnswer | null>;
|