Browse Source

feat(core): Allow manual payments to be added by Administrator

Relates to #753.
Michael Bromley 4 years ago
parent
commit
107ca9a0a8

+ 1 - 0
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');

+ 4 - 1
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.

+ 1 - 1
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.",

+ 1 - 1
packages/core/src/service/services/order.service.ts

@@ -1003,7 +1003,7 @@ export class OrderService {
         input: ManualPaymentInput,
     ): Promise<ErrorResultUnion<AddManualPaymentToOrderResult, Order>> {
         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);