Skip to content

Commit

Permalink
chore(paypal-connector): rename instances of mock to paypal
Browse files Browse the repository at this point in the history
  • Loading branch information
johnsonogwuru committed Feb 16, 2024
1 parent 0b71195 commit a6f1b87
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 26 deletions.
4 changes: 2 additions & 2 deletions enabler/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { MockPaymentEnabler } from './payment-enabler/payment-enabler-mock';
import { PaypalPaymentEnabler } from './payment-enabler/payment-enabler-paypal';

export { MockPaymentEnabler as Enabler };
export { PaypalPaymentEnabler as Enabler };
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ declare global {
}
}

export class MockPaymentEnabler implements PaymentEnabler {
export class PaypalPaymentEnabler implements PaymentEnabler {
setupData: Promise<{ baseOptions: BaseOptions }>;

private constructor(options: EnablerOptions) {
this.setupData = MockPaymentEnabler._Setup(options);
this.setupData = PaypalPaymentEnabler._Setup(options);
}

private static _Setup = async (options: EnablerOptions): Promise<{ baseOptions: BaseOptions }> => {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
import { OperationProcessor } from '../services/processors/operation.processor';
const packageJSON = require('../../package.json');

export class MockOperationProcessor implements OperationProcessor {
export class PaypalOperationProcessor implements OperationProcessor {
async config(): Promise<ConfigResponse> {
return {
clientKey: config.mockClientKey,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import {
PaymentRequestSchemaDTO,
PaymentResponseSchema,
PaymentResponseSchemaDTO,
} from '../dtos/mock-payment.dto';
import { MockPaymentService } from '../services/mock-payment.service';
} from '../dtos/paypal-payment.dto';
import { PaypalPaymentService } from '../services/paypal-payment.service';

type PaymentRoutesOptions = {
paymentService: MockPaymentService;
paymentService: PaypalPaymentService;
sessionAuthHook: SessionAuthenticationHook;
};

Expand Down
4 changes: 2 additions & 2 deletions processor/src/server/plugins/operation.plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { FastifyInstance } from 'fastify';
import { paymentSDK } from '../../payment-sdk';
import { operationsRoute } from '../../routes/operation.route';
import { DefaultOperationService } from '../../services/operation.service';
import { MockOperationProcessor } from '../../services/processors/mock-operation.processor';
import { PaypalOperationProcessor } from '../../services/processors/paypal-operation.processor';

export default async function (server: FastifyInstance) {
const paymentProcessor = new MockOperationProcessor();
const paymentProcessor = new PaypalOperationProcessor();

const operationService = new DefaultOperationService({
ctCartService: paymentSDK.ctCartService,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { FastifyInstance } from 'fastify';
import { paymentSDK } from '../../payment-sdk';
import { paymentRoutes } from '../../routes/mock-payment.route';
import { MockPaymentService } from '../../services/mock-payment.service';
import { paymentRoutes } from '../../routes/paypal-payment.route';
import { PaypalPaymentService } from '../../services/paypal-payment.service';

export default async function (server: FastifyInstance) {
const mockPaymentService = new MockPaymentService({
const paypalPaymentService = new PaypalPaymentService({
ctCartService: paymentSDK.ctCartService,
ctPaymentService: paymentSDK.ctPaymentService,
});

await server.register(paymentRoutes, {
paymentService: mockPaymentService,
paymentService: paypalPaymentService,
sessionAuthHook: paymentSDK.sessionAuthHookFn,
});
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import { CommercetoolsCartService, CommercetoolsPaymentService } from '@commercetools/connect-payments-sdk';
import { PaymentOutcome, PaymentResponseSchemaDTO } from '../dtos/mock-payment.dto';
import { PaymentOutcome, PaymentResponseSchemaDTO } from '../dtos/paypal-payment.dto';

import { randomUUID } from 'crypto';
import { getCartIdFromContext } from '../libs/fastify/context/context';
import { CreatePayment } from './types/mock-payment.type';
import { CreatePayment } from './types/paypal-payment.type';

export type MockPaymentServiceOptions = {
export type PaypalPaymentServiceOptions = {
ctCartService: CommercetoolsCartService;
ctPaymentService: CommercetoolsPaymentService;
};

export class MockPaymentService {
export class PaypalPaymentService {
private ctCartService: CommercetoolsCartService;
private ctPaymentService: CommercetoolsPaymentService;
private allowedCreditCards = ['4111111111111111', '5555555555554444', '341925950237632'];

constructor(opts: MockPaymentServiceOptions) {
constructor(opts: PaypalPaymentServiceOptions) {
this.ctCartService = opts.ctCartService;
this.ctPaymentService = opts.ctPaymentService;
}
Expand All @@ -34,7 +34,7 @@ export class MockPaymentService {
cart: ctCart,
}),
paymentMethodInfo: {
paymentInterface: 'mock',
paymentInterface: 'paypal',
},
...(ctCart.customerId && {
customer: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
import { OperationProcessor } from './operation.processor';
const packageJSON = require('../../../package.json');

export class MockOperationProcessor implements OperationProcessor {
export class PaypalOperationProcessor implements OperationProcessor {
async config(): Promise<ConfigResponse> {
return {
clientKey: config.mockClientKey,
Expand All @@ -34,15 +34,15 @@ export class MockOperationProcessor implements OperationProcessor {
try {
const paymentMethods = 'card';
return {
name: 'Mock Payment API',
name: 'Paypal Payment API',
status: 'UP',
data: {
paymentMethods,
},
};
} catch (e) {
return {
name: 'Mock Payment API',
name: 'Paypal Payment API',
status: 'DOWN',
data: {
// TODO do not expose the error
Expand Down
2 changes: 1 addition & 1 deletion processor/src/services/types/operation.type.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CommercetoolsCartService, CommercetoolsPaymentService } from '@commercetools/connect-payments-sdk';
import { PaymentOutcome, PaymentRequestSchemaDTO } from '../../dtos/mock-payment.dto';
import { PaymentOutcome, PaymentRequestSchemaDTO } from '../../dtos/paypal-payment.dto';
import { ConfigResponseSchemaDTO } from '../../dtos/operations/config.dto';
import { SupportedPaymentComponentsSchemaDTO } from '../../dtos/operations/payment-componets.dto';
import {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PaymentOutcome, PaymentRequestSchemaDTO } from '../../dtos/mock-payment.dto';
import { PaymentOutcome, PaymentRequestSchemaDTO } from '../../dtos/paypal-payment.dto';

export type CreatePayment = {
data: PaymentRequestSchemaDTO;
Expand All @@ -8,7 +8,7 @@ export type CreatePaymentRequest = {
data: PaymentRequestSchemaDTO;
};

export type MockPaymentProviderResponse = {
export type PaypalPaymentProviderResponse = {
resultCode: PaymentOutcome;
pspReference: string;
paymentMethodType: string;
Expand Down

0 comments on commit a6f1b87

Please sign in to comment.