Skip to content

Commit

Permalink
feat(core): Make PaymentMethod entity translatable
Browse files Browse the repository at this point in the history
Relates to #1184
  • Loading branch information
michaelbromley committed Feb 23, 2023
1 parent 04b2bb6 commit 2a4b3bc
Show file tree
Hide file tree
Showing 23 changed files with 326 additions and 92 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -731,10 +731,9 @@ export type CreatePaymentMethodInput = {
checker?: InputMaybe<ConfigurableOperationInput>;
code: Scalars['String'];
customFields?: InputMaybe<Scalars['JSON']>;
description?: InputMaybe<Scalars['String']>;
enabled: Scalars['Boolean'];
handler: ConfigurableOperationInput;
name: Scalars['String'];
translations: Array<PaymentMethodTranslationInput>;
};

export type CreateProductInput = {
Expand Down Expand Up @@ -3622,6 +3621,7 @@ export type PaymentMethod = Node & {
handler: ConfigurableOperation;
id: Scalars['ID'];
name: Scalars['String'];
translations: Array<PaymentMethodTranslation>;
updatedAt: Scalars['DateTime'];
};

Expand Down Expand Up @@ -3681,6 +3681,23 @@ export type PaymentMethodSortParameter = {
updatedAt?: InputMaybe<SortOrder>;
};

export type PaymentMethodTranslation = {
createdAt: Scalars['DateTime'];
description: Scalars['String'];
id: Scalars['ID'];
languageCode: LanguageCode;
name: Scalars['String'];
updatedAt: Scalars['DateTime'];
};

export type PaymentMethodTranslationInput = {
customFields?: InputMaybe<Scalars['JSON']>;
description?: InputMaybe<Scalars['String']>;
id?: InputMaybe<Scalars['ID']>;
languageCode: LanguageCode;
name?: InputMaybe<Scalars['String']>;
};

/** Returned if an attempting to refund a Payment against OrderLines from a different Order */
export type PaymentOrderMismatchError = ErrorResult & {
errorCode: ErrorCode;
Expand Down Expand Up @@ -5437,11 +5454,10 @@ export type UpdatePaymentMethodInput = {
checker?: InputMaybe<ConfigurableOperationInput>;
code?: InputMaybe<Scalars['String']>;
customFields?: InputMaybe<Scalars['JSON']>;
description?: InputMaybe<Scalars['String']>;
enabled?: InputMaybe<Scalars['Boolean']>;
handler?: InputMaybe<ConfigurableOperationInput>;
id: Scalars['ID'];
name?: InputMaybe<Scalars['String']>;
translations?: InputMaybe<Array<PaymentMethodTranslationInput>>;
};

export type UpdateProductInput = {
Expand Down
11 changes: 11 additions & 0 deletions packages/common/src/generated-shop-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2246,6 +2246,7 @@ export type PaymentMethod = Node & {
handler: ConfigurableOperation;
id: Scalars['ID'];
name: Scalars['String'];
translations: Array<PaymentMethodTranslation>;
updatedAt: Scalars['DateTime'];
};

Expand All @@ -2260,6 +2261,16 @@ export type PaymentMethodQuote = {
name: Scalars['String'];
};

export type PaymentMethodTranslation = {
__typename?: 'PaymentMethodTranslation';
createdAt: Scalars['DateTime'];
description: Scalars['String'];
id: Scalars['ID'];
languageCode: LanguageCode;
name: Scalars['String'];
updatedAt: Scalars['DateTime'];
};

/**
* @description
* Permissions for administrators and customers. Used to control access to
Expand Down
25 changes: 21 additions & 4 deletions packages/common/src/generated-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -745,10 +745,9 @@ export type CreatePaymentMethodInput = {
checker?: InputMaybe<ConfigurableOperationInput>;
code: Scalars['String'];
customFields?: InputMaybe<Scalars['JSON']>;
description?: InputMaybe<Scalars['String']>;
enabled: Scalars['Boolean'];
handler: ConfigurableOperationInput;
name: Scalars['String'];
translations: Array<PaymentMethodTranslationInput>;
};

export type CreateProductInput = {
Expand Down Expand Up @@ -3821,6 +3820,7 @@ export type PaymentMethod = Node & {
handler: ConfigurableOperation;
id: Scalars['ID'];
name: Scalars['String'];
translations: Array<PaymentMethodTranslation>;
updatedAt: Scalars['DateTime'];
};

Expand Down Expand Up @@ -3883,6 +3883,24 @@ export type PaymentMethodSortParameter = {
updatedAt?: InputMaybe<SortOrder>;
};

export type PaymentMethodTranslation = {
__typename?: 'PaymentMethodTranslation';
createdAt: Scalars['DateTime'];
description: Scalars['String'];
id: Scalars['ID'];
languageCode: LanguageCode;
name: Scalars['String'];
updatedAt: Scalars['DateTime'];
};

export type PaymentMethodTranslationInput = {
customFields?: InputMaybe<Scalars['JSON']>;
description?: InputMaybe<Scalars['String']>;
id?: InputMaybe<Scalars['ID']>;
languageCode: LanguageCode;
name?: InputMaybe<Scalars['String']>;
};

/** Returned if an attempting to refund a Payment against OrderLines from a different Order */
export type PaymentOrderMismatchError = ErrorResult & {
__typename?: 'PaymentOrderMismatchError';
Expand Down Expand Up @@ -5728,11 +5746,10 @@ export type UpdatePaymentMethodInput = {
checker?: InputMaybe<ConfigurableOperationInput>;
code?: InputMaybe<Scalars['String']>;
customFields?: InputMaybe<Scalars['JSON']>;
description?: InputMaybe<Scalars['String']>;
enabled?: InputMaybe<Scalars['Boolean']>;
handler?: InputMaybe<ConfigurableOperationInput>;
id: Scalars['ID'];
name?: InputMaybe<Scalars['String']>;
translations?: InputMaybe<Array<PaymentMethodTranslationInput>>;
};

export type UpdateProductInput = {
Expand Down
3 changes: 1 addition & 2 deletions packages/core/e2e/active-order-strategy.e2e-spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DefaultLogger, mergeConfig, orderPercentageDiscount } from '@vendure/core';
import { mergeConfig, orderPercentageDiscount } from '@vendure/core';
import { createTestEnvironment } from '@vendure/testing';
import gql from 'graphql-tag';
import path from 'path';
Expand All @@ -25,7 +25,6 @@ import { assertThrowsWithMessage } from './utils/assert-throws-with-message';
describe('custom ActiveOrderStrategy', () => {
const { server, adminClient, shopClient } = createTestEnvironment(
mergeConfig(testConfig(), {
logger: new DefaultLogger(),
plugins: [TokenActiveOrderPlugin],
paymentOptions: {
paymentMethodHandlers: [testSuccessfulPaymentMethod],
Expand Down
6 changes: 3 additions & 3 deletions packages/core/e2e/custom-field-relations.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1058,14 +1058,14 @@ describe('Custom field relations', () => {
mutation {
createPaymentMethod(
input: {
name: "test"
code: "test"
enabled: true
handler: {
code: "${testSuccessfulPaymentMethod.code}"
arguments: []
}
customFields: { singleId: "T_1", multiIds: ["T_1", "T_2"] }
customFields: { singleId: "T_1", multiIds: ["T_1", "T_2"] },
translations: [{ languageCode: en, name: "test" }]
}
) {
id
Expand All @@ -1084,7 +1084,7 @@ describe('Custom field relations', () => {
updatePaymentMethod(
input: {
id: "${paymentMethodId}"
customFields: { singleId: "T_2", multiIds: ["T_3", "T_4"] }
customFields: { singleId: "T_2", multiIds: ["T_3", "T_4"] },
}
) {
id
Expand Down
24 changes: 20 additions & 4 deletions packages/core/e2e/graphql/generated-e2e-admin-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -731,10 +731,9 @@ export type CreatePaymentMethodInput = {
checker?: InputMaybe<ConfigurableOperationInput>;
code: Scalars['String'];
customFields?: InputMaybe<Scalars['JSON']>;
description?: InputMaybe<Scalars['String']>;
enabled: Scalars['Boolean'];
handler: ConfigurableOperationInput;
name: Scalars['String'];
translations: Array<PaymentMethodTranslationInput>;
};

export type CreateProductInput = {
Expand Down Expand Up @@ -3622,6 +3621,7 @@ export type PaymentMethod = Node & {
handler: ConfigurableOperation;
id: Scalars['ID'];
name: Scalars['String'];
translations: Array<PaymentMethodTranslation>;
updatedAt: Scalars['DateTime'];
};

Expand Down Expand Up @@ -3681,6 +3681,23 @@ export type PaymentMethodSortParameter = {
updatedAt?: InputMaybe<SortOrder>;
};

export type PaymentMethodTranslation = {
createdAt: Scalars['DateTime'];
description: Scalars['String'];
id: Scalars['ID'];
languageCode: LanguageCode;
name: Scalars['String'];
updatedAt: Scalars['DateTime'];
};

export type PaymentMethodTranslationInput = {
customFields?: InputMaybe<Scalars['JSON']>;
description?: InputMaybe<Scalars['String']>;
id?: InputMaybe<Scalars['ID']>;
languageCode: LanguageCode;
name?: InputMaybe<Scalars['String']>;
};

/** Returned if an attempting to refund a Payment against OrderLines from a different Order */
export type PaymentOrderMismatchError = ErrorResult & {
errorCode: ErrorCode;
Expand Down Expand Up @@ -5437,11 +5454,10 @@ export type UpdatePaymentMethodInput = {
checker?: InputMaybe<ConfigurableOperationInput>;
code?: InputMaybe<Scalars['String']>;
customFields?: InputMaybe<Scalars['JSON']>;
description?: InputMaybe<Scalars['String']>;
enabled?: InputMaybe<Scalars['Boolean']>;
handler?: InputMaybe<ConfigurableOperationInput>;
id: Scalars['ID'];
name?: InputMaybe<Scalars['String']>;
translations?: InputMaybe<Array<PaymentMethodTranslationInput>>;
};

export type UpdateProductInput = {
Expand Down
10 changes: 10 additions & 0 deletions packages/core/e2e/graphql/generated-e2e-shop-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2168,6 +2168,7 @@ export type PaymentMethod = Node & {
handler: ConfigurableOperation;
id: Scalars['ID'];
name: Scalars['String'];
translations: Array<PaymentMethodTranslation>;
updatedAt: Scalars['DateTime'];
};

Expand All @@ -2181,6 +2182,15 @@ export type PaymentMethodQuote = {
name: Scalars['String'];
};

export type PaymentMethodTranslation = {
createdAt: Scalars['DateTime'];
description: Scalars['String'];
id: Scalars['ID'];
languageCode: LanguageCode;
name: Scalars['String'];
updatedAt: Scalars['DateTime'];
};

/**
* @description
* Permissions for administrators and customers. Used to control access to
Expand Down
52 changes: 41 additions & 11 deletions packages/core/e2e/payment-method.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,18 @@ describe('PaymentMethod resolver', () => {
>(CREATE_PAYMENT_METHOD, {
input: {
code: 'no-checks',
name: 'No Checker',
description: 'This is a test payment method',
enabled: true,
handler: {
code: dummyPaymentHandler.code,
arguments: [{ name: 'automaticSettle', value: 'true' }],
},
translations: [
{
languageCode: LanguageCode.en,
name: 'No Checker',
description: 'This is a test payment method',
},
],
},
});

Expand Down Expand Up @@ -115,7 +120,6 @@ describe('PaymentMethod resolver', () => {
>(UPDATE_PAYMENT_METHOD, {
input: {
id: 'T_1',
description: 'modified',
checker: {
code: minPriceChecker.code,
arguments: [{ name: 'minPrice', value: '0' }],
Expand All @@ -124,6 +128,12 @@ describe('PaymentMethod resolver', () => {
code: dummyPaymentHandler.code,
arguments: [{ name: 'automaticSettle', value: 'false' }],
},
translations: [
{
languageCode: LanguageCode.en,
description: 'modified',
},
],
},
});

Expand Down Expand Up @@ -200,8 +210,6 @@ describe('PaymentMethod resolver', () => {
>(CREATE_PAYMENT_METHOD, {
input: {
code: 'price-check',
name: 'With Min Price Checker',
description: 'Order total must be more than 2k',
enabled: true,
checker: {
code: minPriceChecker.code,
Expand All @@ -211,6 +219,13 @@ describe('PaymentMethod resolver', () => {
code: dummyPaymentHandler.code,
arguments: [{ name: 'automaticSettle', value: 'true' }],
},
translations: [
{
languageCode: LanguageCode.en,
name: 'With Min Price Checker',
description: 'Order total must be more than 2k',
},
],
},
});
await adminClient.query<
Expand All @@ -219,13 +234,18 @@ describe('PaymentMethod resolver', () => {
>(CREATE_PAYMENT_METHOD, {
input: {
code: 'disabled-method',
name: 'Disabled ones',
description: 'This method is disabled',
enabled: false,
handler: {
code: dummyPaymentHandler.code,
arguments: [{ name: 'automaticSettle', value: 'true' }],
},
translations: [
{
languageCode: LanguageCode.en,
name: 'Disabled ones',
description: 'This method is disabled',
},
],
},
});

Expand Down Expand Up @@ -325,13 +345,18 @@ describe('PaymentMethod resolver', () => {
>(CREATE_PAYMENT_METHOD, {
input: {
code: 'channel-2-method',
name: 'Channel 2 method',
description: 'This is a test payment method',
enabled: true,
handler: {
code: dummyPaymentHandler.code,
arguments: [{ name: 'automaticSettle', value: 'true' }],
},
translations: [
{
languageCode: LanguageCode.en,
name: 'Channel 2 method',
description: 'This is a test payment method',
},
],
},
});

Expand Down Expand Up @@ -407,13 +432,18 @@ describe('PaymentMethod resolver', () => {
>(CREATE_PAYMENT_METHOD, {
input: {
code: 'channel-2-method2',
name: 'Channel 2 method 2',
description: 'This is a test payment method',
enabled: true,
handler: {
code: dummyPaymentHandler.code,
arguments: [{ name: 'automaticSettle', value: 'true' }],
},
translations: [
{
languageCode: LanguageCode.en,
name: 'Channel 2 method 2',
description: 'This is a test payment method',
},
],
},
});

Expand Down
Loading

0 comments on commit 2a4b3bc

Please sign in to comment.