Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 | 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 240x 120x 2x 118x 5x 113x 3x 110x 10x 100x 4x 96x 2x 94x 94x 94x 3x 91x 2x 89x 2x 87x 87x 2x 85x 6x 2x 4x 2x 2x 79x 3x 76x 2x 74x 2x 72x 72x 72x 72x 5x 67x 2x 65x 65x 65x 2x 63x 5x 58x 2x 56x 2x 54x 54x 124x 124x 124x 124x 124x 24x | import { CheckoutSelectors, CustomerInitializeOptions, CustomerRequestOptions, PaymentInitializeOptions, PaymentMethod, PaymentRequestOptions } from '@bigcommerce/checkout-sdk'; import React, { memo, FunctionComponent } from 'react'; import { withCheckout, CheckoutContextProps } from '../../checkout'; import getUniquePaymentMethodId from './getUniquePaymentMethodId'; import AdyenV2PaymentMethod from './AdyenV2PaymentMethod'; import AffirmPaymentMethod from './AffirmPaymentMethod'; import AmazonPaymentMethod from './AmazonPaymentMethod'; import AmazonPayV2PaymentMethod from './AmazonPayV2PaymentMethod'; import BarclaycardPaymentMethod from './BarclaycardPaymentMethod'; import BlueSnapV2PaymentMethod from './BlueSnapV2PaymentMethod'; import BoltPaymentMethod from './BoltPaymentMethod'; import BraintreeCreditCardPaymentMethod from './BraintreeCreditCardPaymentMethod'; import ChasePayPaymentMethod from './ChasePayPaymentMethod'; import CheckoutCustomPaymentMethod from './CheckoutcomCustomPaymentMethod'; import CCAvenueMarsPaymentMethod from './CCAvenueMarsPaymentMethod'; import DigitalRiverPaymentMethod from './DigitalRiverPaymentMethod'; import GooglePayPaymentMethod from './GooglePayPaymentMethod'; import HostedCreditCardPaymentMethod from './HostedCreditCardPaymentMethod'; import HostedPaymentMethod from './HostedPaymentMethod'; import KlarnaPaymentMethod from './KlarnaPaymentMethod'; import KlarnaV2PaymentMethod from './KlarnaV2PaymentMethod'; import MasterpassPaymentMethod from './MasterpassPaymentMethod'; import MolliePaymentMethod from './MolliePaymentMethod'; import MonerisPaymentMethod from './MonerisPaymentMethod'; import OfflinePaymentMethod from './OfflinePaymentMethod'; import PaymentMethodId from './PaymentMethodId'; import PaymentMethodProviderType from './PaymentMethodProviderType'; import PaymentMethodType from './PaymentMethodType'; import PaypalCommerceCreditCardPaymentMethod from './PaypalCommerceCreditCardPaymentMethod'; import PaypalCommercePaymentMethod from './PaypalCommercePaymentMethod'; import PaypalExpressPaymentMethod from './PaypalExpressPaymentMethod'; import PaypalPaymentsProPaymentMethod from './PaypalPaymentsProPaymentMethod'; import PPSDKPaymentMethod from './PPSDKPaymentMethod'; import SquarePaymentMethod from './SquarePaymentMethod'; import StripePaymentMethod from './StripePaymentMethod'; import VisaCheckoutPaymentMethod from './VisaCheckoutPaymentMethod'; export interface PaymentMethodProps { method: PaymentMethod; isEmbedded?: boolean; isUsingMultiShipping?: boolean; onUnhandledError?(error: Error): void; submitForm?(): void; } export interface WithCheckoutPaymentMethodProps { isPpsdkEnabled: boolean; isInitializing: boolean; deinitializeCustomer(options: CustomerRequestOptions): Promise<CheckoutSelectors>; deinitializePayment(options: PaymentRequestOptions): Promise<CheckoutSelectors>; initializeCustomer(options: CustomerInitializeOptions): Promise<CheckoutSelectors>; initializePayment(options: PaymentInitializeOptions): Promise<CheckoutSelectors>; } /** * If possible, try to avoid having components that are specific to a specific * payment provider or method. Instead, try to generalise the requirements and * use components that can are reusable for multiple payment methods. i.e.: * CreditCardPaymentMethod, HostedPaymentMethod etc... If it is really necessary * for a particular payment method, you may write a method-specific component for * the purpose of configuring a general-purpose component in order to fulfill * its specific product or technical requirements. */ // tslint:disable:cyclomatic-complexity const PaymentMethodComponent: FunctionComponent<PaymentMethodProps & WithCheckoutPaymentMethodProps> = props => { const { method, isPpsdkEnabled } = props; if (isPpsdkEnabled && method.type === PaymentMethodProviderType.PPSDK) { return <PPSDKPaymentMethod { ...props } />; } if (method.gateway === PaymentMethodId.AdyenV2) { return <AdyenV2PaymentMethod { ...props } />; } if (method.id === PaymentMethodId.SquareV2) { return <SquarePaymentMethod { ...props } />; } if (method.gateway === PaymentMethodId.StripeV3) { return <StripePaymentMethod { ...props } />; } if (method.id === PaymentMethodId.Amazon) { return <AmazonPaymentMethod { ...props } />; } if (method.id === PaymentMethodId.AmazonPay) { return <AmazonPayV2PaymentMethod { ...props } />; } Iif (method.id === PaymentMethodId.Affirm) { return <AffirmPaymentMethod { ...props } />; } Iif (method.gateway === PaymentMethodId.BlueSnapV2) { return <BlueSnapV2PaymentMethod { ...props } />; } if (method.id === PaymentMethodId.DigitalRiver) { return <DigitalRiverPaymentMethod { ...props } />; } if (method.gateway === PaymentMethodId.Klarna) { return <KlarnaV2PaymentMethod { ...props } />; } if (method.id === PaymentMethodId.Klarna) { return <KlarnaPaymentMethod { ...props } />; } Iif (method.id === PaymentMethodId.CCAvenueMars) { return <CCAvenueMarsPaymentMethod { ...props } />; } if (method.id === PaymentMethodId.ChasePay) { return <ChasePayPaymentMethod { ...props } />; } if (method.gateway === PaymentMethodId.Checkoutcom) { if (method.id === 'credit_card') { return <HostedCreditCardPaymentMethod { ...props } />; } if (method.id === PaymentMethodId.Boleto || method.id === PaymentMethodId.Ideal || method.id === PaymentMethodId.Fawry || method.id === PaymentMethodId.Oxxo || method.id === PaymentMethodId.Qpay || method.id === PaymentMethodId.Sepa ) { return <CheckoutCustomPaymentMethod checkoutCustomMethod={ method.id } { ...props } />; } return <HostedPaymentMethod { ...props } />; } if (method.id === PaymentMethodId.BraintreeVisaCheckout) { return <VisaCheckoutPaymentMethod { ...props } />; } if (method.id === PaymentMethodId.AdyenV2GooglePay || method.id === PaymentMethodId.AuthorizeNetGooglePay || method.id === PaymentMethodId.BraintreeGooglePay || method.id === PaymentMethodId.CheckoutcomGooglePay || method.id === PaymentMethodId.CybersourceV2GooglePay || method.id === PaymentMethodId.OrbitalGooglePay || method.id === PaymentMethodId.StripeGooglePay) { return <GooglePayPaymentMethod { ...props } />; } if (method.id === PaymentMethodId.Masterpass) { return <MasterpassPaymentMethod { ...props } />; } Iif (method.id === PaymentMethodId.Braintree) { return <BraintreeCreditCardPaymentMethod { ...props } />; } Iif (method.id === PaymentMethodId.PaypalCommerceCreditCards) { return <PaypalCommerceCreditCardPaymentMethod { ...props } />; } Iif (method.id === PaymentMethodId.PaypalCommerce || method.id === PaymentMethodId.PaypalCommerceCredit || method.gateway === PaymentMethodId.PaypalCommerceAlternativeMethod) { return <PaypalCommercePaymentMethod { ...props } isAPM={ method.gateway === PaymentMethodId.PaypalCommerceAlternativeMethod } uniqueId={ getUniquePaymentMethodId(method.id, method.gateway) } />; } if (method.id === PaymentMethodId.PaypalExpress) { return <PaypalExpressPaymentMethod { ...props } />; } if (method.type !== PaymentMethodProviderType.Hosted && method.id === PaymentMethodId.PaypalPaymentsPro) { return <PaypalPaymentsProPaymentMethod { ...props } />; } Iif (method.gateway === PaymentMethodId.Barclaycard) { return <BarclaycardPaymentMethod { ...props } />; } Iif (method.id === PaymentMethodId.Bolt) { return <BoltPaymentMethod { ...props } />; } if (method.id === PaymentMethodId.Moneris) { return <MonerisPaymentMethod { ...props } />; } if (method.gateway === PaymentMethodId.Afterpay || method.gateway === PaymentMethodId.Clearpay || method.id === PaymentMethodId.Laybuy || method.id === PaymentMethodId.Quadpay || method.id === PaymentMethodId.Sezzle || method.id === PaymentMethodId.Zip || method.method === PaymentMethodType.Paypal || method.method === PaymentMethodType.PaypalCredit || method.type === PaymentMethodProviderType.Hosted) { return <HostedPaymentMethod { ...props } />; } if (method.type === PaymentMethodProviderType.Offline) { return <OfflinePaymentMethod { ...props } />; } if (method.gateway === PaymentMethodId.Mollie) { return <MolliePaymentMethod { ...props } />; } // NOTE: Some payment methods have `method` as `credit-card` but they are // actually not. Therefore, as a workaround, we are doing the following // check last. Eif (method.method === PaymentMethodType.CreditCard || method.type === PaymentMethodProviderType.Api) { return <HostedCreditCardPaymentMethod { ...props } />; } return null; }; function mapToWithCheckoutPaymentMethodProps( { checkoutService, checkoutState }: CheckoutContextProps, { method }: PaymentMethodProps ): WithCheckoutPaymentMethodProps { const { statuses: { isInitializingPayment }, } = checkoutState; const isPpsdkEnabled = Boolean( checkoutService.getState() .data.getConfig() ?.checkoutSettings.features['PAYMENTS-6806.enable_ppsdk_strategy'] ); return { deinitializeCustomer: checkoutService.deinitializeCustomer, deinitializePayment: checkoutService.deinitializePayment, initializeCustomer: checkoutService.initializeCustomer, initializePayment: checkoutService.initializePayment, isInitializing: isInitializingPayment(method.id), isPpsdkEnabled, }; } export default withCheckout(mapToWithCheckoutPaymentMethodProps)(memo(PaymentMethodComponent)); |