@brissoto/pay-react-native 1.4.5 → 1.5.1
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/README.md +10 -9
- package/dist/checkout-core/messages/en.d.ts +1 -4
- package/dist/checkout-core/messages/en.js +1 -4
- package/dist/checkout-core/messages/fr.js +1 -4
- package/dist/checkout-core/models/checkout.enum.d.ts +1 -4
- package/dist/checkout-core/models/checkout.enum.js +0 -3
- package/dist/checkout-core/models/checkout.interface.d.ts +2 -0
- package/dist/checkout-core/models/checkout.view.utils.js +1 -3
- package/dist/components/SheetContent.js +0 -1
- package/dist/components/SheetForm.js +4 -2
- package/dist/components/SheetTerminal.js +0 -1
- package/dist/models/sheet.interface.d.ts +5 -2
- package/dist/models/sheet.utils.js +3 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -139,15 +139,16 @@ Open the sheet with it: `presentPayment({ paymentId })`. Ship on the `payment.pa
|
|
|
139
139
|
|
|
140
140
|
## Results
|
|
141
141
|
|
|
142
|
-
| `result.status` | When
|
|
143
|
-
| --------------- |
|
|
144
|
-
| `paid` | The payment is paid.
|
|
145
|
-
| `pending` | The payer closed the sheet while a prompt waited on their phone: it may still go through.
|
|
146
|
-
| `closed` | The payer closed the sheet with the payment still open.
|
|
147
|
-
| `cancelled` | The payment was cancelled.
|
|
148
|
-
| `expired` | The payment expired.
|
|
149
|
-
| `locked` | Too many failed tries: the payment can no longer be paid.
|
|
150
|
-
| `refunded` | A store refunded the payment.
|
|
142
|
+
| `result.status` | When |
|
|
143
|
+
| --------------- | --------------------------------------------------------------------------------------------- |
|
|
144
|
+
| `paid` | The payment is paid. |
|
|
145
|
+
| `pending` | The payer closed the sheet while a prompt waited on their phone: it may still go through. |
|
|
146
|
+
| `closed` | The payer closed the sheet with the payment still open. |
|
|
147
|
+
| `cancelled` | The payment was cancelled. |
|
|
148
|
+
| `expired` | The payment expired. |
|
|
149
|
+
| `locked` | Too many failed tries: the payment can no longer be paid. |
|
|
150
|
+
| `refunded` | A store refunded the payment. |
|
|
151
|
+
| `unavailable` | No method could take the payment (`payment.unavailable`): its tabs said so. Nothing was paid. |
|
|
151
152
|
|
|
152
153
|
When the sheet could not show the payment, `status` is `closed` and `result.error` says why: `not_found` (no payment has this id) or `network` (it could not load).
|
|
153
154
|
|
|
@@ -67,6 +67,7 @@ declare const _default: {
|
|
|
67
67
|
back: string;
|
|
68
68
|
change: string;
|
|
69
69
|
method_missing: string;
|
|
70
|
+
tab_empty: string;
|
|
70
71
|
secured_by: string;
|
|
71
72
|
help: string;
|
|
72
73
|
terms: string;
|
|
@@ -213,10 +214,6 @@ declare const _default: {
|
|
|
213
214
|
title: string;
|
|
214
215
|
body: string;
|
|
215
216
|
};
|
|
216
|
-
no_method: {
|
|
217
|
-
title: string;
|
|
218
|
-
body: string;
|
|
219
|
-
};
|
|
220
217
|
contact_support: string;
|
|
221
218
|
get_help: string;
|
|
222
219
|
returning: string;
|
|
@@ -67,6 +67,7 @@ export default {
|
|
|
67
67
|
back: 'Back to payment methods',
|
|
68
68
|
change: 'Change',
|
|
69
69
|
method_missing: 'Choose a payment method',
|
|
70
|
+
tab_empty: 'No payment method available here for now.',
|
|
70
71
|
secured_by: 'Payment secured by',
|
|
71
72
|
help: 'Need help?',
|
|
72
73
|
terms: 'Terms',
|
|
@@ -213,10 +214,6 @@ export default {
|
|
|
213
214
|
title: "This link isn't valid",
|
|
214
215
|
body: "We couldn't find this payment. The link may be incomplete. Open it again from the app you were paying in.",
|
|
215
216
|
},
|
|
216
|
-
no_method: {
|
|
217
|
-
title: 'No way to pay right now',
|
|
218
|
-
body: '{app} offers no payment method at the moment. Try again later.',
|
|
219
|
-
},
|
|
220
217
|
contact_support: 'Contact support',
|
|
221
218
|
get_help: 'Get help',
|
|
222
219
|
returning: 'Returning to {app}…',
|
|
@@ -68,6 +68,7 @@ const messages = {
|
|
|
68
68
|
back: 'Retour aux moyens de paiement',
|
|
69
69
|
change: 'Modifier',
|
|
70
70
|
method_missing: 'Choisissez un moyen de paiement',
|
|
71
|
+
tab_empty: 'Aucun moyen de paiement disponible ici pour le moment.',
|
|
71
72
|
secured_by: 'Paiement sécurisé par',
|
|
72
73
|
help: "Besoin d'aide ?",
|
|
73
74
|
terms: 'Conditions',
|
|
@@ -213,10 +214,6 @@ const messages = {
|
|
|
213
214
|
title: "Ce lien n'est pas valide",
|
|
214
215
|
body: "Nous ne trouvons pas ce paiement. Le lien est peut-être incomplet. Rouvrez-le depuis l'application où vous payiez.",
|
|
215
216
|
},
|
|
216
|
-
no_method: {
|
|
217
|
-
title: 'Aucun moyen de paiement pour le moment',
|
|
218
|
-
body: '{app} ne propose aucun moyen de paiement en ce moment. Réessayez plus tard.',
|
|
219
|
-
},
|
|
220
217
|
contact_support: 'Contacter le support',
|
|
221
218
|
get_help: "Obtenir de l'aide",
|
|
222
219
|
returning: 'Retour à {app}…',
|
|
@@ -10,8 +10,6 @@ export declare enum CheckoutScreenEnum {
|
|
|
10
10
|
CANCELLED = "cancelled",
|
|
11
11
|
LOCKED = "locked",
|
|
12
12
|
INVALID = "invalid",
|
|
13
|
-
/** Every method went off since the link was made: nothing to pay with. */
|
|
14
|
-
NO_METHOD = "no_method",
|
|
15
13
|
REDIRECT = "redirect"
|
|
16
14
|
}
|
|
17
15
|
/** The form's two steps: pick a method, then what it needs (the number and its code, or the card). */
|
|
@@ -189,8 +187,7 @@ export declare enum TerminalKindEnum {
|
|
|
189
187
|
EXPIRED = "expired",
|
|
190
188
|
CANCELLED = "cancelled",
|
|
191
189
|
LOCKED = "locked",
|
|
192
|
-
INVALID = "invalid"
|
|
193
|
-
NO_METHOD = "no_method"
|
|
190
|
+
INVALID = "invalid"
|
|
194
191
|
}
|
|
195
192
|
export declare enum CheckoutButtonVariantEnum {
|
|
196
193
|
PRIMARY = "primary",
|
|
@@ -11,8 +11,6 @@ export var CheckoutScreenEnum;
|
|
|
11
11
|
CheckoutScreenEnum["CANCELLED"] = "cancelled";
|
|
12
12
|
CheckoutScreenEnum["LOCKED"] = "locked";
|
|
13
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
14
|
CheckoutScreenEnum["REDIRECT"] = "redirect";
|
|
17
15
|
})(CheckoutScreenEnum || (CheckoutScreenEnum = {}));
|
|
18
16
|
/** The form's two steps: pick a method, then what it needs (the number and its code, or the card). */
|
|
@@ -212,7 +210,6 @@ export var TerminalKindEnum;
|
|
|
212
210
|
TerminalKindEnum["CANCELLED"] = "cancelled";
|
|
213
211
|
TerminalKindEnum["LOCKED"] = "locked";
|
|
214
212
|
TerminalKindEnum["INVALID"] = "invalid";
|
|
215
|
-
TerminalKindEnum["NO_METHOD"] = "no_method";
|
|
216
213
|
})(TerminalKindEnum || (TerminalKindEnum = {}));
|
|
217
214
|
export var CheckoutButtonVariantEnum;
|
|
218
215
|
(function (CheckoutButtonVariantEnum) {
|
|
@@ -139,6 +139,8 @@ export interface CheckoutView {
|
|
|
139
139
|
preferredTab: CheckoutTabEnum | null;
|
|
140
140
|
app: CheckoutApp;
|
|
141
141
|
methods: Array<CheckoutMethod>;
|
|
142
|
+
/** No method could take it when it was created: nothing can ever be paid on it. */
|
|
143
|
+
unavailable: boolean;
|
|
142
144
|
/**
|
|
143
145
|
* False for a store product's payment until the payment sheet first
|
|
144
146
|
* opens it: its currency and amount are not set yet.
|
|
@@ -97,9 +97,6 @@ export function screenOf(view, ui) {
|
|
|
97
97
|
: null;
|
|
98
98
|
if (shown === AttemptStatusEnum.PENDING)
|
|
99
99
|
return CheckoutScreenEnum.WAITING;
|
|
100
|
-
// The app offers nothing any more: no form to fill, no other method to try.
|
|
101
|
-
if (view.methods.length === 0)
|
|
102
|
-
return CheckoutScreenEnum.NO_METHOD;
|
|
103
100
|
// A store's sheet closed with nothing bought: back on the form, no failure.
|
|
104
101
|
if (shown === AttemptStatusEnum.FAILED &&
|
|
105
102
|
attempt.failureReason !== FailureReasonEnum.CANCELLED) {
|
|
@@ -282,6 +279,7 @@ export function previewView(app, methods) {
|
|
|
282
279
|
theme: null,
|
|
283
280
|
preferredMethod: null,
|
|
284
281
|
preferredTab: null,
|
|
282
|
+
unavailable: false,
|
|
285
283
|
priced: true,
|
|
286
284
|
stores: [],
|
|
287
285
|
attemptsLeft: 0,
|
|
@@ -29,7 +29,6 @@ const TERMINAL_KIND = {
|
|
|
29
29
|
[CheckoutScreenEnum.EXPIRED]: TerminalKindEnum.EXPIRED,
|
|
30
30
|
[CheckoutScreenEnum.CANCELLED]: TerminalKindEnum.CANCELLED,
|
|
31
31
|
[CheckoutScreenEnum.LOCKED]: TerminalKindEnum.LOCKED,
|
|
32
|
-
[CheckoutScreenEnum.NO_METHOD]: TerminalKindEnum.NO_METHOD,
|
|
33
32
|
};
|
|
34
33
|
/** The sheet's screens, driven by the shared checkout controller. */
|
|
35
34
|
export function SheetContent({ payment, fontsReady, deviceLocale, ipCountry, onClose, dragHandlers, backRef, }) {
|
|
@@ -28,7 +28,7 @@ function GridRows({ cards, missing, alone }) {
|
|
|
28
28
|
return rows.map((row) => (_jsxs(View, { style: styles.gridRow, children: [row.map(({ id, ...card }) => (_jsx(SheetMethodCard, { ...card, missing: missing, alone: alone }, id))), row.length === 1 && !alone && _jsx(View, { style: styles.gridSpacer })] }, row[0].id)));
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
31
|
-
* The tab's methods, a lone one full width; then, on the Card tab of a
|
|
31
|
+
* The tab's methods, a lone one full width, or a line saying it has none; then, on the Card tab of a
|
|
32
32
|
* guessed country, the other countries' bank redirects behind "Paying from
|
|
33
33
|
* another country?". Red with a hint, and shaken, after Continue with none picked.
|
|
34
34
|
*/
|
|
@@ -36,7 +36,7 @@ function MethodGrid({ cards, others, missing }) {
|
|
|
36
36
|
const t = useTranslations('checkout');
|
|
37
37
|
const { colors } = useSheetTheme();
|
|
38
38
|
const shake = useShake(missing);
|
|
39
|
-
return (_jsxs(Animated.View, { testID: "method-grid", accessibilityRole: "radiogroup", style: [styles.grid, { transform: [{ translateX: shake }] }], children: [_jsx(GridRows, { cards: cards, missing: missing > 0, alone: cards.length === 1 }), others &&
|
|
39
|
+
return (_jsxs(Animated.View, { testID: "method-grid", accessibilityRole: "radiogroup", style: [styles.grid, { transform: [{ translateX: shake }] }], children: [cards.length === 0 && !others ? (_jsx(View, { style: styles.empty, children: _jsx(SheetText, { size: 13, color: colors.muted, style: styles.emptyText, children: t('tab_empty') }) })) : (_jsx(GridRows, { cards: cards, missing: missing > 0, alone: cards.length === 1 })), others &&
|
|
40
40
|
(others.open ? (_jsxs(View, { style: styles.others, children: [_jsx(SheetText, { weight: FigtreeEnum.SEMI_BOLD, size: 13, color: colors.muted, children: t('bank.other_countries') }), _jsx(GridRows, { cards: others.cards, missing: missing > 0, alone: false })] })) : (_jsx(View, { style: styles.othersLink, children: _jsx(SheetButton, { variant: CheckoutButtonVariantEnum.LINK, label: t('bank.other_countries'), onPress: others.onOpen }) }))), missing > 0 && (_jsx(SheetText, { accessibilityRole: "alert", weight: FigtreeEnum.MEDIUM, size: 13, color: colors.danger, children: t('method_missing') }))] }));
|
|
41
41
|
}
|
|
42
42
|
/**
|
|
@@ -129,6 +129,8 @@ const styles = StyleSheet.create({
|
|
|
129
129
|
elevation: 1,
|
|
130
130
|
},
|
|
131
131
|
grid: { gap: 8, marginTop: 12 },
|
|
132
|
+
empty: { paddingVertical: 16 },
|
|
133
|
+
emptyText: { textAlign: 'center' },
|
|
132
134
|
gridRow: { flexDirection: 'row', gap: 8 },
|
|
133
135
|
// A card's flex share leaves out its padding and border (13 a side): the
|
|
134
136
|
// spacer takes the same, so a lone last card is as wide as the others.
|
|
@@ -9,7 +9,6 @@ const COPY_KEY = {
|
|
|
9
9
|
[TerminalKindEnum.EXPIRED]: 'expired',
|
|
10
10
|
[TerminalKindEnum.CANCELLED]: 'cancelled',
|
|
11
11
|
[TerminalKindEnum.LOCKED]: 'locked_screen',
|
|
12
|
-
[TerminalKindEnum.NO_METHOD]: 'no_method',
|
|
13
12
|
};
|
|
14
13
|
/** A payment that cannot be paid any more, said plainly, and the way back to the app. */
|
|
15
14
|
export function SheetTerminal({ core, kind, onClose }) {
|
|
@@ -7,9 +7,12 @@ import type { CardFieldsMessage, CheckoutColors, CheckoutCore, CheckoutToast, Ch
|
|
|
7
7
|
import type { FigtreeEnum, SheetIconEnum, StoreProductTypeEnum, WebBrowserResultEnum } from './sheet.enum.js';
|
|
8
8
|
/**
|
|
9
9
|
* How the sheet ended. `closed`: the payer closed it with the payment still
|
|
10
|
-
* open.
|
|
10
|
+
* open. `unavailable`: no method could take the payment, so its tabs said
|
|
11
|
+
* so and nothing was paid (`payment.unavailable` on the server). A hint only: ship on `payment.paid` from the webhook or `getPayment`.
|
|
11
12
|
*/
|
|
12
|
-
export type PaymentSheetStatus = 'paid' | 'pending' | 'cancelled' | 'expired' | 'locked' | 'refunded' | 'closed'
|
|
13
|
+
export type PaymentSheetStatus = 'paid' | 'pending' | 'cancelled' | 'expired' | 'locked' | 'refunded' | 'closed'
|
|
14
|
+
/** No payment method could take the payment: the sheet said so, nothing was paid. */
|
|
15
|
+
| 'unavailable';
|
|
13
16
|
/** Why the sheet could not show the payment: no payment has this id, or it could not load. */
|
|
14
17
|
export type PaymentSheetError = 'not_found' | 'network';
|
|
15
18
|
export interface PaymentSheetResult {
|
|
@@ -27,6 +27,9 @@ export function sheetResult(view, failed) {
|
|
|
27
27
|
if (view.status !== CheckoutPaymentStatusEnum.PENDING) {
|
|
28
28
|
return { status: view.status };
|
|
29
29
|
}
|
|
30
|
+
// No method could ever take it: the app may offer something else.
|
|
31
|
+
if (view.unavailable)
|
|
32
|
+
return { status: 'unavailable' };
|
|
30
33
|
// A prompt still on the phone: approved later, the payment goes through.
|
|
31
34
|
return {
|
|
32
35
|
status: view.attempt?.status === AttemptStatusEnum.PENDING ? 'pending' : 'closed',
|