Browse Source

fix(core): Payment amount accounts for existing Payments on Order

Michael Bromley 4 years ago
parent
commit
e92d2ce663
1 changed files with 3 additions and 1 deletions
  1. 3 1
      packages/core/src/service/services/order.service.ts

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

@@ -770,10 +770,12 @@ export class OrderService {
         if (order.state !== 'ArrangingPayment') {
             return new OrderPaymentStateError();
         }
+        order.payments = await this.getOrderPayments(ctx, order.id);
+        const amountToPay = order.totalWithTax - totalCoveredByPayments(order);
         const payment = await this.paymentService.createPayment(
             ctx,
             order,
-            order.totalWithTax,
+            amountToPay,
             input.method,
             input.metadata,
         );