Skip to content

Commit

Permalink
feat(core): Allow manual payments to be added by Administrator
Browse files Browse the repository at this point in the history
Relates to #753.
  • Loading branch information
michaelbromley committed Nov 30, 2021
1 parent 25c9c8a commit 107ca9a
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions packages/core/e2e/shop-order.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
5 changes: 4 additions & 1 deletion packages/core/src/api/schema/admin-api/order.api.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/i18n/messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/service/services/order.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 107ca9a

Please sign in to comment.