Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -263,15 +263,6 @@ describe('when using Stripe OCS payment', () => {
expect(hidePaymentSubmitButtonMock).toHaveBeenCalledWith(method, false);
});

it('should not initialize method if payment not required', () => {
jest.spyOn(checkoutState.data, 'isPaymentDataRequired').mockReturnValue(false);

render(<PaymentMethodTest {...defaultProps} method={method} />);

expect(screen.queryByTestId('stripe-accordion-skeleton')).not.toBeInTheDocument();
expect(checkoutService.initializePayment).not.toHaveBeenCalled();
});

describe('# Stripe OCS accordion layout', () => {
it('should initialize with auto layout when isCustomChecklistItem is false', () => {
method = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ const StripeOCSPaymentMethod: FunctionComponent<PaymentMethodProps> = ({
setValidationSchema,
} = paymentForm;
const instruments = checkoutState.data.getInstruments(method) || [];

const {
data: { getCheckout, isPaymentDataRequired },
statuses: { isLoadingInstruments },
Expand Down Expand Up @@ -149,20 +150,6 @@ const StripeOCSPaymentMethod: FunctionComponent<PaymentMethodProps> = ({
],
);

const initializeStripeCustomer = useCallback(
(options: CustomerInitializeOptions) => {
return checkoutService.initializeCustomer({
...options,
integrations: [createStripeLinkV2CustomerStrategy],
});
},
[checkoutService],
);

if (!isPaymentDataRequired()) {
return null;
}

const renderCustomOCSSectionStyles = () => (
<style>
{`
Expand All @@ -175,6 +162,15 @@ const StripeOCSPaymentMethod: FunctionComponent<PaymentMethodProps> = ({
`}
</style>
);
const initializeStripeCustomer = useCallback(
(options: CustomerInitializeOptions) => {
return checkoutService.initializeCustomer({
...options,
integrations: [createStripeLinkV2CustomerStrategy],
});
},
[checkoutService],
);

const renderCheckoutElementsForStripeOCSStyling = () => (
<div style={{ display: 'none' }}>
Expand Down