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 | 25x 25x 25x 25x 4x 8x 25x 1x 2x 25x 4x 25x | import { CheckoutSelectors, PaymentInitializeOptions, PaymentMethod, PaymentRequestOptions } from '@bigcommerce/checkout-sdk'; import { noop } from 'lodash'; import { Component, ReactNode } from 'react'; export interface OfflinePaymentMethodProps { method: PaymentMethod; deinitializePayment(options: PaymentRequestOptions): Promise<CheckoutSelectors>; initializePayment(options: PaymentInitializeOptions): Promise<CheckoutSelectors>; onUnhandledError?(error: Error): void; } export default class OfflinePaymentMethod extends Component<OfflinePaymentMethodProps> { async componentDidMount(): Promise<void> { const { initializePayment, method, onUnhandledError = noop, } = this.props; try { await initializePayment({ gatewayId: method.gateway, methodId: method.id, }); } catch (error) { onUnhandledError(error); } } async componentWillUnmount(): Promise<void> { const { deinitializePayment, method, onUnhandledError = noop, } = this.props; try { await deinitializePayment({ gatewayId: method.gateway, methodId: method.id, }); } catch (error) { onUnhandledError(error); } } render(): ReactNode { return null; } } |