Skip to content

Commit

Permalink
feat(payment): PI-2943 Change HostedFormOptions interface name in core
Browse files Browse the repository at this point in the history
  • Loading branch information
bc-sebastianszafraniec committed Dec 5, 2024
1 parent 7a6eb7f commit cb1464c
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions packages/core/src/hosted-form/hosted-form-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { createSpamProtection, PaymentHumanVerificationHandler } from '../spam-p
import HostedField from './hosted-field';
import HostedFieldType from './hosted-field-type';
import HostedForm from './hosted-form';
import HostedFormOptions, {
import LegacyHostedFormOptions, {
HostedCardFieldOptionsMap,
HostedStoredCardFieldOptionsMap,
} from './hosted-form-options';
Expand All @@ -20,7 +20,7 @@ import HostedFormOrderDataTransformer from './hosted-form-order-data-transformer
export default class HostedFormFactory {
constructor(private _store: ReadableCheckoutStore) {}

create(host: string, options: HostedFormOptions): HostedForm {
create(host: string, options: LegacyHostedFormOptions): HostedForm {
const fieldTypes = Object.keys(options.fields) as HostedFieldType[];
const fields = fieldTypes.reduce<HostedField[]>((result, type) => {
const fields = options.fields as HostedStoredCardFieldOptionsMap &
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/hosted-form/hosted-form-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
HostedInputValidateEvent,
} from './iframe-content';

export default interface HostedFormOptions {
export default interface LegacyHostedFormOptions {
fields: HostedFieldOptionsMap;
styles?: HostedFieldStylesMap;
onBlur?(data: HostedFieldBlurEventData): void;
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/hosted-form/hosted-form.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { createSpamProtection, PaymentHumanVerificationHandler } from '../spam-p
import HostedField from './hosted-field';
import HostedFieldType from './hosted-field-type';
import HostedForm from './hosted-form';
import HostedFormOptions from './hosted-form-options';
import LegacyHostedFormOptions from './hosted-form-options';
import HostedFormOrderDataTransformer from './hosted-form-order-data-transformer';
import { getHostedFormOrderData } from './hosted-form-order-data.mock';
import { HostedInputEventMap, HostedInputEventType } from './iframe-content';
Expand All @@ -20,7 +20,7 @@ import {

describe('HostedForm', () => {
let callbacks: Pick<
HostedFormOptions,
LegacyHostedFormOptions,
'onBlur' | 'onCardTypeChange' | 'onEnter' | 'onFocus' | 'onValidate'
>;
let eventListener: IframeEventListener<HostedInputEventMap>;
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/hosted-form/hosted-form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { PaymentHumanVerificationHandler } from '../spam-protection';

import { InvalidHostedFormConfigError } from './errors';
import HostedField from './hosted-field';
import HostedFormOptions from './hosted-form-options';
import LegacyHostedFormOptions from './hosted-form-options';
import HostedFormOrderDataTransformer from './hosted-form-order-data-transformer';
import {
HostedInputEnterEvent,
Expand All @@ -24,7 +24,7 @@ import {
} from './stored-card-hosted-form-type';

type HostedFormEventCallbacks = Pick<
HostedFormOptions,
LegacyHostedFormOptions,
'onBlur' | 'onCardTypeChange' | 'onFocus' | 'onEnter' | 'onValidate'
>;

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/hosted-form/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export { default as HostedFieldType } from './hosted-field-type';
export { default as HostedForm } from './hosted-form';
export { default as HostedFormFactory } from './hosted-form-factory';
export { default as HostedFormOptions } from './hosted-form-options';
export { default as LegacyHostedFormOptions } from './hosted-form-options';
export { default as HostedFormOrderDataTransformer } from './hosted-form-order-data-transformer';
export { default as HostedFormOrderData } from './hosted-form-order-data';
export { default as createStoredCardHostedFormService } from './create-hosted-form-stored-card-service';
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import {
StoredCardHostedFormInstrumentFieldsMock,
} from './stored-card-hosted-form.mock';

import { HostedForm, HostedFormFactory, HostedFormOptions } from '.';
import { HostedForm, HostedFormFactory, LegacyHostedFormOptions } from '.';

describe('StoredCardHostedFormService', () => {
let formFactory: HostedFormFactory;

let store: CheckoutStore;
let service: StoredCardHostedFormService;
let initializeOptions: HostedFormOptions;
let initializeOptions: LegacyHostedFormOptions;

beforeEach(() => {
store = createCheckoutStore(getCheckoutStoreState());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { NotInitializedError, NotInitializedErrorType } from '../common/error/er

import HostedForm from './hosted-form';
import HostedFormFactory from './hosted-form-factory';
import HostedFormOptions from './hosted-form-options';
import LegacyHostedFormOptions from './hosted-form-options';
import {
StoredCardHostedFormData,
StoredCardHostedFormInstrumentFields,
Expand All @@ -25,7 +25,7 @@ export default class StoredCardHostedFormService {
await form.validate().then(() => form.submitStoredCard({ fields, data }));
}

initialize(options: HostedFormOptions): Promise<void> {
initialize(options: LegacyHostedFormOptions): Promise<void> {
const form = this._hostedFormFactory.create(this._host, options);

return form.attach().then(() => {
Expand Down

0 comments on commit cb1464c

Please sign in to comment.