@brissoto/pay-react-native 1.6.0 → 1.6.2
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.
|
@@ -13,8 +13,8 @@ export declare function pickCountry(view: CheckoutView, clues: CountryClues, cou
|
|
|
13
13
|
/**
|
|
14
14
|
* How the page opens: on the details of the app's preferred method when it
|
|
15
15
|
* can be paid with, or of the only one that can; else on the methods, on its
|
|
16
|
-
* preferred tab. Without one, a payer country with no Mobile Money
|
|
17
|
-
* Card tab, when there is a card to pay with.
|
|
16
|
+
* preferred tab. Without one, a payer country with no Mobile Money, or a
|
|
17
|
+
* payment with none at all, opens the Card tab, when there is a card to pay with.
|
|
18
18
|
*/
|
|
19
19
|
export declare function initialUi(view: CheckoutView, clues: CountryClues): CheckoutUi;
|
|
20
20
|
/** Which screen shows: the payment's status first, then what the payer is doing. */
|
|
@@ -22,8 +22,8 @@ export function pickCountry(view, clues, countries) {
|
|
|
22
22
|
/**
|
|
23
23
|
* How the page opens: on the details of the app's preferred method when it
|
|
24
24
|
* can be paid with, or of the only one that can; else on the methods, on its
|
|
25
|
-
* preferred tab. Without one, a payer country with no Mobile Money
|
|
26
|
-
* Card tab, when there is a card to pay with.
|
|
25
|
+
* preferred tab. Without one, a payer country with no Mobile Money, or a
|
|
26
|
+
* payment with none at all, opens the Card tab, when there is a card to pay with.
|
|
27
27
|
*/
|
|
28
28
|
export function initialUi(view, clues) {
|
|
29
29
|
const countries = countriesOf(view.methods);
|
|
@@ -31,9 +31,12 @@ export function initialUi(view, clues) {
|
|
|
31
31
|
const opening = available.find((method) => method.id === view.preferredMethod) ??
|
|
32
32
|
(available.length === 1 ? available[0] : undefined);
|
|
33
33
|
const payer = payerCountryOf(view, clues);
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
const hasCard = view.methods.some((method) => method.kind === MethodKindEnum.CARD);
|
|
35
|
+
// Away: the payer's country has no Mobile Money here, or none has.
|
|
36
|
+
const away = hasCard &&
|
|
37
|
+
(countries.length === 0 ||
|
|
38
|
+
(!!payer.payerCountry &&
|
|
39
|
+
!countries.some((country) => country === payer.payerCountry)));
|
|
37
40
|
const base = {
|
|
38
41
|
tab: view.preferredTab ??
|
|
39
42
|
(away && !view.preferredMethod
|
|
@@ -168,8 +171,12 @@ export function deriveCheckout(view, ui, phone) {
|
|
|
168
171
|
method.state === MethodStateEnum.AVAILABLE &&
|
|
169
172
|
method.country === failed?.country &&
|
|
170
173
|
method.id !== failed.id) ?? null;
|
|
174
|
+
const screen = screenOf(view, ui);
|
|
175
|
+
// On the methods, nothing picked: the payment's amount, never a past attempt's.
|
|
176
|
+
const choosing = screen === CheckoutScreenEnum.FORM ||
|
|
177
|
+
screen === CheckoutScreenEnum.SUBMITTING;
|
|
171
178
|
return {
|
|
172
|
-
screen
|
|
179
|
+
screen,
|
|
173
180
|
countries: countriesOf(view.methods),
|
|
174
181
|
wallets,
|
|
175
182
|
cards,
|
|
@@ -183,7 +190,10 @@ export function deriveCheckout(view, ui, phone) {
|
|
|
183
190
|
canPay: !!selected && missing.length === 0 && !ui.submitting && !ui.cardPaying,
|
|
184
191
|
detected,
|
|
185
192
|
total: selected?.price ??
|
|
186
|
-
view.attempt?.price ?? {
|
|
193
|
+
(choosing ? null : view.attempt?.price) ?? {
|
|
194
|
+
amount: view.amount,
|
|
195
|
+
currency: view.currency,
|
|
196
|
+
},
|
|
187
197
|
// Only a Mobile Money method has a number to belong to another one.
|
|
188
198
|
mismatch: selected && !onCard && detected && detected.id !== selected.id
|
|
189
199
|
? detected
|
|
@@ -90,8 +90,9 @@ export function SheetForm({ core, phoneRef, cardFields, store, }) {
|
|
|
90
90
|
on && [styles.tabOn, { backgroundColor: colors.tabOn }],
|
|
91
91
|
], children: _jsx(SheetText, { weight: FigtreeEnum.SEMI_BOLD, size: 13.5, color: on ? colors.ink : colors.muted, numberOfLines: 1, adjustsFontSizeToFit: true, minimumFontScale: 0.8, children: label }) }));
|
|
92
92
|
};
|
|
93
|
-
// Only Mobile Money methods have a country
|
|
94
|
-
|
|
93
|
+
// Only Mobile Money methods have a country. Shown from one, as on the web:
|
|
94
|
+
// the payer sees where they pay from, whatever their own country.
|
|
95
|
+
const pickCountry = !onCard && !onStore && derived.countries.length > 0;
|
|
95
96
|
return (_jsxs(View, { style: styles.form, children: [_jsxs(View, { style: styles.payWith, children: [_jsx(SheetText, { weight: FigtreeEnum.BOLD, size: 15, children: t('pay_with') }), pickCountry && (_jsx(SheetPillSelect, { value: ui.country, options: derived.countries.map((country) => ({
|
|
96
97
|
value: country,
|
|
97
98
|
label: t(`countries.${country}`),
|
|
@@ -42,7 +42,9 @@ export function SheetLayout({ children, foot, secure = true, }) {
|
|
|
42
42
|
];
|
|
43
43
|
return () => listeners.forEach((listener) => listener.remove());
|
|
44
44
|
}, []);
|
|
45
|
-
return (_jsxs(_Fragment, { children: [_jsx(ScrollView, { ref: scroller, style: styles.body, contentContainerStyle: styles.content, keyboardShouldPersistTaps: "handled", keyboardDismissMode: "interactive", scrollEnabled: !pinned,
|
|
45
|
+
return (_jsxs(_Fragment, { children: [_jsx(ScrollView, { ref: scroller, style: styles.body, contentContainerStyle: styles.content, keyboardShouldPersistTaps: "handled", keyboardDismissMode: "interactive", scrollEnabled: !pinned,
|
|
46
|
+
// iOS: the content stops at its ends; the sheet itself does not stretch.
|
|
47
|
+
bounces: false, onLayout: ({ nativeEvent }) => setHeight(nativeEvent.layout.height), onContentSizeChange: (_width, tall) => setContent(tall), testID: "sheet-body", children: _jsx(SheetRoomContext, { value: sheetRoom, children: children }) }), (foot || secure) && (_jsxs(View, { testID: "sheet-foot", style: [
|
|
46
48
|
styles.foot,
|
|
47
49
|
keyboard && styles.footOnKeyboard,
|
|
48
50
|
{ borderColor: colors.line },
|