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 | 24x 24x 24x 24x 24x 24x 24x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 24x | import React, { useCallback, useContext, FunctionComponent } from 'react'; import { Omit } from 'utility-types'; import { connectFormik, ConnectFormikProps } from '../../common/form'; import { FormContext } from '../../ui/form'; import { PaymentFormValues } from '../PaymentForm'; import HostedDropInPaymentMethod from './HostedDropInPaymentMethod'; import { HostedWidgetPaymentMethodProps } from './HostedWidgetPaymentMethod'; export type DigitalRiverPaymentMethodProps = Omit<HostedWidgetPaymentMethodProps, 'containerId'> & ConnectFormikProps<PaymentFormValues>; export enum DigitalRiverClasses { base = 'form-input optimizedCheckout-form-input', } const DigitalRiverPaymentMethod: FunctionComponent<DigitalRiverPaymentMethodProps> = ({ initializePayment, onUnhandledError, formik: { submitForm }, ...rest }) => { const { setSubmitted } = useContext(FormContext); const containerId = `${rest.method.id}-component-field`; const disabledPaymentMethods = rest.method.initializationData?.disabledPaymentMethods ?? []; const isVaultingEnabled = rest.method.config.isVaultingEnabled; const initializeDigitalRiverPayment = useCallback(options => initializePayment({ ...options, digitalriver: { containerId, configuration: { flow: 'checkout', showSavePaymentAgreement: isVaultingEnabled, showComplianceSection: true, button: { type: 'submitOrder', }, usage: 'unscheduled', showTermsOfSaleDisclosure: true, paymentMethodConfiguration: { disabledPaymentMethods, classes: DigitalRiverClasses, }, }, onSubmitForm: () => { setSubmitted(true); submitForm(); }, onError: (error: Error) => { onUnhandledError?.(error); }, }, }), [initializePayment, containerId, isVaultingEnabled, disabledPaymentMethods, setSubmitted, submitForm, onUnhandledError]); return <HostedDropInPaymentMethod { ...rest } containerId={ containerId } hideVerificationFields initializePayment={ initializeDigitalRiverPayment } />; }; export default connectFormik(DigitalRiverPaymentMethod); |