From 107ca9a0a8ada54b0c250f0840c0cd5fa4fff944 Mon Sep 17 00:00:00 2001 From: Michael Bromley Date: Tue, 30 Nov 2021 14:45:50 +0100 Subject: [PATCH] feat(core): Allow manual payments to be added by Administrator Relates to #753. --- packages/core/e2e/shop-order.e2e-spec.ts | 1 + packages/core/src/api/schema/admin-api/order.api.graphql | 5 ++++- packages/core/src/i18n/messages/en.json | 2 +- packages/core/src/service/services/order.service.ts | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/core/e2e/shop-order.e2e-spec.ts b/packages/core/e2e/shop-order.e2e-spec.ts index 94534b0859..3b0a1464e8 100644 --- a/packages/core/e2e/shop-order.e2e-spec.ts +++ b/packages/core/e2e/shop-order.e2e-spec.ts @@ -1251,6 +1251,7 @@ describe('Shop orders', () => { GET_ACTIVE_ORDER_WITH_PAYMENTS, ); const payment = order!.payments![0]; + expect(order!.state).toBe('ArrangingPayment'); expect(order!.payments!.length).toBe(1); expect(payment.method).toBe(testFailingPaymentMethod.code); expect(payment.state).toBe('Declined'); diff --git a/packages/core/src/api/schema/admin-api/order.api.graphql b/packages/core/src/api/schema/admin-api/order.api.graphql index 217c4d471b..96454fda80 100644 --- a/packages/core/src/api/schema/admin-api/order.api.graphql +++ b/packages/core/src/api/schema/admin-api/order.api.graphql @@ -22,7 +22,10 @@ type Mutation { """ modifyOrder(input: ModifyOrderInput!): ModifyOrderResult! """ - Used to manually create a new Payment against an Order. This is used when a completed Order + Used to manually create a new Payment against an Order. + This can be used by an Administrator when an Order is in the ArrangingPayment state. + + It is also used when a completed Order has been modified (using `modifyOrder`) and the price has increased. The extra payment can then be manually arranged by the administrator, and the details used to create a new Payment. diff --git a/packages/core/src/i18n/messages/en.json b/packages/core/src/i18n/messages/en.json index e7274e8253..4a05ee4c7d 100644 --- a/packages/core/src/i18n/messages/en.json +++ b/packages/core/src/i18n/messages/en.json @@ -63,7 +63,7 @@ "INVALID_CREDENTIALS_ERROR": "The provided credentials are invalid", "ITEMS_ALREADY_FULFILLED_ERROR": "One or more OrderItems are already part of a Fulfillment", "LANGUAGE_NOT_AVAILABLE_ERROR": "Language \"{languageCode}\" is not available. First enable it via GlobalSettings and try again", - "MANUAL_PAYMENT_STATE_ERROR": "A manual payment may only be added when in the \"ArrangingAdditionalPayment\" state", + "MANUAL_PAYMENT_STATE_ERROR": "A manual payment may only be added when in the \"ArrangingPayment\" or \"ArrangingAdditionalPayment\" states", "MIME_TYPE_ERROR": "The MIME type '{ mimeType }' is not permitted.", "MISSING_CONDITIONS_ERROR": "A Promotion must have either at least one condition or a coupon code set", "MISSING_PASSWORD_ERROR": "A password must be provided.", diff --git a/packages/core/src/service/services/order.service.ts b/packages/core/src/service/services/order.service.ts index 722cee80aa..cbfe619a6d 100644 --- a/packages/core/src/service/services/order.service.ts +++ b/packages/core/src/service/services/order.service.ts @@ -1003,7 +1003,7 @@ export class OrderService { input: ManualPaymentInput, ): Promise> { const order = await this.getOrderOrThrow(ctx, input.orderId); - if (order.state !== 'ArrangingAdditionalPayment') { + if (order.state !== 'ArrangingAdditionalPayment' && order.state !== 'ArrangingPayment') { return new ManualPaymentStateError(); } const existingPayments = await this.getOrderPayments(ctx, order.id);