@brissoto/pay-react-native 1.6.1 → 1.6.3
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/dist/checkout-core/models/checkout.view.utils.d.ts +2 -2
- package/dist/checkout-core/models/checkout.view.utils.js +17 -7
- package/dist/components/SheetContent.js +5 -1
- package/dist/components/SheetMethodCard.js +7 -1
- package/dist/components/SheetSummary.d.ts +5 -2
- package/dist/components/SheetSummary.js +6 -3
- package/dist/models/sheet.interface.d.ts +2 -0
- package/package.json +1 -1
|
@@ -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
|
|
@@ -54,6 +54,10 @@ export function SheetContent({ payment, fontsReady, deviceLocale, ipCountry, onC
|
|
|
54
54
|
const terminal = TERMINAL_KIND[screen];
|
|
55
55
|
const { step } = derived;
|
|
56
56
|
const details = step === CheckoutStepEnum.DETAILS;
|
|
57
|
+
// PayPal's own button names no amount: the summary stays over its details.
|
|
58
|
+
const paysOwnWay = details &&
|
|
59
|
+
!!derived.selected &&
|
|
60
|
+
FLOW_TRAITS[derived.selected.flow].ownButton;
|
|
57
61
|
const busy = ui.submitting || ui.cardPaying;
|
|
58
62
|
// The form shows: the methods, or the details of the method picked.
|
|
59
63
|
const onForm = !loading &&
|
|
@@ -116,7 +120,7 @@ export function SheetContent({ payment, fontsReady, deviceLocale, ipCountry, onC
|
|
|
116
120
|
: t('pay_plain', {
|
|
117
121
|
amount: formatAmount(derived.total.amount, derived.total.currency),
|
|
118
122
|
currency: CURRENCY_LABEL[derived.total.currency],
|
|
119
|
-
}), busy: busy, inactive: !derived.canPay, onPress: actions.pay })) : (_jsx(SheetButton, { label: t('continue'), inactive: !derived.selected, onPress: actions.continueToDetails })), children: _jsxs(SheetStep, { core: core, phoneRef: phoneRef, children: [!details && _jsx(SheetSummary, { total: derived.total }), _jsx(SheetForm, { core: core, phoneRef: phoneRef, cardFields: cardFields, store: store })] }) }));
|
|
123
|
+
}), busy: busy, inactive: !derived.canPay, onPress: actions.pay })) : (_jsx(SheetButton, { label: t('continue'), inactive: !derived.selected, onPress: actions.continueToDetails })), children: _jsxs(SheetStep, { core: core, phoneRef: phoneRef, children: [(!details || paysOwnWay) && (_jsx(SheetSummary, { total: derived.total, storePrice: onStore ? store.offer.displayPrice : undefined })), _jsx(SheetForm, { core: core, phoneRef: phoneRef, cardFields: cardFields, store: store })] }) }));
|
|
120
124
|
}
|
|
121
125
|
return (_jsxs(View, { testID: "payment-sheet", accessibilityViewIsModal: true, onAccessibilityEscape: onClose, style: [styles.sheet, { backgroundColor: colors.surface }], children: [_jsx(SheetHeader, { view: view, loading: loading, onClose: onClose, onBack: canGoBack ? back : undefined, dragHandlers: dragHandlers }), body, _jsx(SheetToast, { toast: core.toast })] }));
|
|
122
126
|
}
|
|
@@ -11,7 +11,13 @@ export function SheetMethodCard({ logo, name, sub, muted, checked, missing, alon
|
|
|
11
11
|
const { colors, brand } = useSheetTheme();
|
|
12
12
|
const red = missing && !muted && !checked;
|
|
13
13
|
const texts = (_jsxs(_Fragment, { children: [_jsx(SheetText, { weight: FigtreeEnum.BOLD, size: 15, numberOfLines: 1, color: muted ? colors.muted : colors.ink, children: name }), _jsx(SheetText, { size: 12.5, numberOfLines: 1, color: muted ? colors.warnInk : colors.muted, children: sub })] }));
|
|
14
|
-
return (_jsxs(TouchableOpacity
|
|
14
|
+
return (_jsxs(TouchableOpacity
|
|
15
|
+
// Greyed, it still takes a tap: the controller says why it cannot be picked.
|
|
16
|
+
, {
|
|
17
|
+
// Greyed, it still takes a tap: the controller says why it cannot be picked.
|
|
18
|
+
onPress: onSelect, activeOpacity: muted ? 1 : PRESSED_OPACITY, accessibilityRole: "radio", accessibilityLabel: `${name}, ${sub}`,
|
|
19
|
+
// Not `disabled`: React Native would drop the tap that says why.
|
|
20
|
+
accessibilityState: { checked }, style: [
|
|
15
21
|
styles.card,
|
|
16
22
|
checked
|
|
17
23
|
? [styles.cardRinged, { borderColor: brand }]
|
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
import type { SheetSummaryProps } from '../models/sheet.interface.js';
|
|
2
|
-
/**
|
|
3
|
-
|
|
2
|
+
/**
|
|
3
|
+
* The amount to pay, in PayPal's currency while it is picked, or the store's
|
|
4
|
+
* own price on its tab. The order and its lines stay on the web checkout.
|
|
5
|
+
*/
|
|
6
|
+
export declare function SheetSummary({ total, storePrice }: SheetSummaryProps): import("react").JSX.Element;
|
|
@@ -6,12 +6,15 @@ import { formatAmount } from "../checkout-core/models/checkout.money.utils.js";
|
|
|
6
6
|
import { useSheetTheme } from "../hooks/use-sheet-theme.js";
|
|
7
7
|
import { FigtreeEnum } from "../models/sheet.enum.js";
|
|
8
8
|
import { SheetText } from "./SheetText.js";
|
|
9
|
-
/**
|
|
10
|
-
|
|
9
|
+
/**
|
|
10
|
+
* The amount to pay, in PayPal's currency while it is picked, or the store's
|
|
11
|
+
* own price on its tab. The order and its lines stay on the web checkout.
|
|
12
|
+
*/
|
|
13
|
+
export function SheetSummary({ total, storePrice }) {
|
|
11
14
|
const t = useTranslations('checkout');
|
|
12
15
|
const { colors } = useSheetTheme();
|
|
13
16
|
const { amount, currency } = total;
|
|
14
|
-
return (_jsxs(View, { style: [styles.summary, { borderColor: colors.line }], children: [_jsx(SheetText, { size: 13, color: colors.muted, children: t('total_label') }), _jsxs(View, { style: styles.amountRow, children: [_jsx(SheetText, { weight: FigtreeEnum.EXTRA_BOLD, size: 34, style: styles.amount, children: formatAmount(amount, currency) }), _jsx(SheetText, { weight: FigtreeEnum.SEMI_BOLD, size: 16, color: colors.ink2, children: CURRENCY_LABEL[currency] })] })] }));
|
|
17
|
+
return (_jsxs(View, { style: [styles.summary, { borderColor: colors.line }], children: [_jsx(SheetText, { size: 13, color: colors.muted, children: t('total_label') }), _jsxs(View, { testID: "sheet-amount", style: styles.amountRow, children: [_jsx(SheetText, { weight: FigtreeEnum.EXTRA_BOLD, size: 34, style: styles.amount, children: storePrice ?? formatAmount(amount, currency) }), !storePrice && (_jsx(SheetText, { weight: FigtreeEnum.SEMI_BOLD, size: 16, color: colors.ink2, children: CURRENCY_LABEL[currency] }))] })] }));
|
|
15
18
|
}
|
|
16
19
|
const styles = StyleSheet.create({
|
|
17
20
|
summary: {
|
|
@@ -139,6 +139,8 @@ export interface SheetHeaderProps {
|
|
|
139
139
|
export interface SheetSummaryProps {
|
|
140
140
|
/** What the payer pays: the picked method's price (ADR 0012). */
|
|
141
141
|
total: Price;
|
|
142
|
+
/** On a store's tab: the store's own price, as it writes it (`$1.99`). */
|
|
143
|
+
storePrice?: string;
|
|
142
144
|
}
|
|
143
145
|
export interface SheetPaypalButtonProps {
|
|
144
146
|
busy: boolean;
|