import type { PaymentMethodContextProviderProps } from '@graphcommerce/magento-cart-payment-method' import type { PluginConfig, PluginProps } from '@graphcommerce/next-config' import { useSendEvent } from '../hooks/useSendEvent' import { cartToPurchase } from '../mapping/cartToPurchase/cartToPurchase' export const config: PluginConfig = { module: '@graphcommerce/magento-cart-payment-method', type: 'component', } export function PaymentMethodContextProvider( props: PluginProps, ) { const { Prev, onSuccess, ...rest } = props const sendEvent = useSendEvent() return ( { sendEvent('purchase', cartToPurchase(orderNumber, cart)) return onSuccess?.(orderNumber, cart) }} /> ) }