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 4cbd71e commit 6cdeb16
Show file tree
Hide file tree
Showing 29 changed files with 564 additions and 542 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
17 changes: 0 additions & 17 deletions packages/core/src/payment/create-payment-strategy-registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import {
SpamProtectionActionCreator,
SpamProtectionRequestSender,
} from '../spam-protection';
import { StoreCreditActionCreator, StoreCreditRequestSender } from '../store-credit';

import createPaymentStrategyRegistryV2 from './create-payment-strategy-registry-v2';
import PaymentActionCreator from './payment-action-creator';
Expand Down Expand Up @@ -56,7 +55,6 @@ import {
import { CBAMPGSPaymentStrategy, CBAMPGSScriptLoader } from './strategies/cba-mpgs';
import { ConvergePaymentStrategy } from './strategies/converge';
import { MasterpassPaymentStrategy, MasterpassScriptLoader } from './strategies/masterpass';
import { MonerisPaymentStrategy } from './strategies/moneris';
import { OpyPaymentStrategy, OpyScriptLoader } from './strategies/opy';
import { PaypalExpressPaymentStrategy, PaypalScriptLoader } from './strategies/paypal';
import {
Expand Down Expand Up @@ -93,9 +91,6 @@ export default function createPaymentStrategyRegistry(
new OrderRequestSender(requestSender),
checkoutValidator,
);
const storeCreditActionCreator = new StoreCreditActionCreator(
new StoreCreditRequestSender(requestSender),
);
const paymentHumanVerificationHandler = new PaymentHumanVerificationHandler(
createSpamProtection(createScriptLoader()),
);
Expand Down Expand Up @@ -241,18 +236,6 @@ export default function createPaymentStrategyRegistry(
),
);

registry.register(
PaymentStrategyType.MONERIS,
() =>
new MonerisPaymentStrategy(
hostedFormFactory,
store,
orderActionCreator,
paymentActionCreator,
storeCreditActionCreator,
),
);

registry.register(
PaymentStrategyType.OPY,
() =>
Expand Down
7 changes: 0 additions & 7 deletions packages/core/src/payment/payment-request-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
} from './strategies/braintree';
import { DigitalRiverPaymentInitializeOptions } from './strategies/digitalriver';
import { MasterpassPaymentInitializeOptions } from './strategies/masterpass';
import { MonerisPaymentInitializeOptions } from './strategies/moneris';
import { OpyPaymentInitializeOptions } from './strategies/opy';
import { PaypalExpressPaymentInitializeOptions } from './strategies/paypal';

Expand Down Expand Up @@ -77,12 +76,6 @@ export interface BasePaymentInitializeOptions extends PaymentRequestOptions {
*/
masterpass?: MasterpassPaymentInitializeOptions;

/**
* The options that are required to initialize the Moneris payment method.
* They can be omitted unless you need to support Moneris.
*/
moneris?: MonerisPaymentInitializeOptions;

/**
* The options that are required to initialize the Opy payment
* method. They can be omitted unless you need to support Opy.
Expand Down
3 changes: 0 additions & 3 deletions packages/core/src/payment/strategies/moneris/index.ts

This file was deleted.

Loading

0 comments on commit 6cdeb16

Please sign in to comment.