1 import { c } from 'ttag';
3 import Alert from '@proton/components/components/alert/Alert';
4 import Price from '@proton/components/components/price/Price';
5 import type { PaypalProcessorHook } from '@proton/components/payments/react-extensions/usePaypal';
6 import type { PaymentMethodFlows, PlainPaymentMethodType } from '@proton/payments';
7 import { type Currency, PAYMENT_METHOD_TYPES } from '@proton/payments';
8 import { MAX_PAYPAL_AMOUNT, MIN_PAYPAL_AMOUNT_CHARGEBEE, MIN_PAYPAL_AMOUNT_INHOUSE } from '@proton/payments';
10 import PayPalButton from './PayPalButton';
11 import PayPalInfoMessage from './PayPalInfoMessage';
14 paypal: PaypalProcessorHook;
15 paypalCredit: PaypalProcessorHook;
16 type?: PaymentMethodFlows;
20 prefetchToken?: boolean;
22 triggersDisabled?: boolean;
23 showPaypalCredit: boolean;
24 method: PlainPaymentMethodType;
39 const isChargebeePaypal = method === PAYMENT_METHOD_TYPES.CHARGEBEE_PAYPAL;
40 const minAmount = isChargebeePaypal ? MIN_PAYPAL_AMOUNT_CHARGEBEE : MIN_PAYPAL_AMOUNT_INHOUSE;
42 if (amount < minAmount) {
43 const minimumAmount = <Price currency={currency}>{minAmount}</Price>;
46 <Alert className="mb-4" type="error">
47 {c('Error').jt`Amount below minimum (${minimumAmount}).`}
52 if (amount > MAX_PAYPAL_AMOUNT) {
53 return <Alert className="mb-4" type="error">{c('Error').t`Amount above the maximum.`}</Alert>;
59 data-testid="paypal-credit-button"
67 disabled={disabled || paypalCredit.isInitialState || triggersDisabled}
68 prefetchToken={prefetchToken}
71 loading={paypalCredit.processingToken}
73 {c('Link').t`click here`}
78 <div className="p-4 border rounded bg-weak mb-4" data-testid="paypal-view">
82 <div className="mt-4 mb-4">
84 .t`You must have a credit card or bank account linked with your PayPal account. If your PayPal account doesn't have that, please click on the button below.`}
86 <div>{clickHere}</div>
93 export default PayPalView;