@brissoto/pay-react-native 1.6.2 → 1.6.4

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.
@@ -284,7 +284,7 @@ export interface CheckoutDerived {
284
284
  mismatch: CheckoutMethod | null;
285
285
  /** After a failure: another method of the same country the payer can use now. */
286
286
  suggestion: CheckoutMethod | null;
287
- /** What the payer pays: the picked method's price, else the last attempt's, else the payment's amount (ADR 0012). */
287
+ /** What the payer pays: the picked method's price, else the open tab's while choosing, else the last attempt's, else the payment's amount (ADR 0012). */
288
288
  total: Price;
289
289
  }
290
290
  export interface CheckoutCoreActions {
@@ -157,7 +157,11 @@ export function deriveCheckout(view, ui, phone) {
157
157
  ? []
158
158
  : view.methods.filter((method) => FLOW_TRAITS[method.flow].countryScheme && !home(method));
159
159
  const onCard = ui.tab === CheckoutTabEnum.CARD;
160
- const picked = (onCard ? [...cards, ...otherBanks] : wallets).find((method) => method.id === ui.method);
160
+ const shown = onCard ? [...cards, ...otherBanks] : wallets;
161
+ const picked = shown.find((method) => method.id === ui.method);
162
+ // Nothing picked yet: the open tab's price (EUR on cards, XAF on Cameroon's wallets).
163
+ const tabPrice = (shown.find((method) => method.state === MethodStateEnum.AVAILABLE) ??
164
+ shown.at(0))?.price;
161
165
  const selected = picked?.state === MethodStateEnum.AVAILABLE ? picked : null;
162
166
  const missing = selected
163
167
  ? missingBeforePay(selected, payInputOf(ui, phone))
@@ -172,7 +176,7 @@ export function deriveCheckout(view, ui, phone) {
172
176
  method.country === failed?.country &&
173
177
  method.id !== failed.id) ?? null;
174
178
  const screen = screenOf(view, ui);
175
- // On the methods, nothing picked: the payment's amount, never a past attempt's.
179
+ // On the methods, nothing picked: the open tab's price, never a past attempt's.
176
180
  const choosing = screen === CheckoutScreenEnum.FORM ||
177
181
  screen === CheckoutScreenEnum.SUBMITTING;
178
182
  return {
@@ -190,7 +194,7 @@ export function deriveCheckout(view, ui, phone) {
190
194
  canPay: !!selected && missing.length === 0 && !ui.submitting && !ui.cardPaying,
191
195
  detected,
192
196
  total: selected?.price ??
193
- (choosing ? null : view.attempt?.price) ?? {
197
+ (choosing ? tabPrice : view.attempt?.price) ?? {
194
198
  amount: view.amount,
195
199
  currency: view.currency,
196
200
  },
@@ -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, { onPress: onSelect, disabled: muted, activeOpacity: PRESSED_OPACITY, accessibilityRole: "radio", accessibilityLabel: `${name}, ${sub}`, accessibilityState: { checked, disabled: muted }, style: [
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
- /** The amount to pay, in PayPal's currency while it is picked. The order and its lines stay on the web checkout. */
3
- export declare function SheetSummary({ total }: SheetSummaryProps): import("react").JSX.Element;
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
- /** The amount to pay, in PayPal's currency while it is picked. The order and its lines stay on the web checkout. */
10
- export function SheetSummary({ total }) {
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brissoto/pay-react-native",
3
- "version": "1.6.2",
3
+ "version": "1.6.4",
4
4
  "description": "Brissoto Pay for Expo and React Native apps: the payment sheet.",
5
5
  "license": "MIT",
6
6
  "sideEffects": false,