Added event type for refunds (#35)

Co-authored-by: Inal Arsanukaev <aiz@empayre.com>
This commit is contained in:
Inal Arsanukaev 2023-01-27 13:29:33 +03:00 committed by GitHub
parent f4eb04f247
commit 0b55ab3998
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -69,7 +69,8 @@ public class InvoicingEventService
case INVOICE_PAYMENT_REFUND_STARTED -> new RefundCreated()
.invoice(getSwagInvoice(invoiceInfo))
.payment(getSwagPayment(m, invoiceInfo))
.refund(getSwagRefund(m, invoiceInfo));
.refund(getSwagRefund(m, invoiceInfo))
.eventType(Event.EventTypeEnum.REFUNDCREATED);
case INVOICE_PAYMENT_REFUND_STATUS_CHANGED -> resolveRefundStatusChanged(m, invoiceInfo);
default -> throw new UnsupportedOperationException("Unknown event type " + m.getEventType());
};
@ -185,9 +186,21 @@ public class InvoicingEventService
ExpandedPayment swagPayment = getSwagPayment(message, invoiceInfo);
Refund swagRefund = getSwagRefund(message, invoiceInfo);
return switch (message.getRefundStatus()) {
case PENDING -> new RefundCreated().invoice(swagInvoice).payment(swagPayment).refund(swagRefund);
case SUCCEEDED -> new RefundSucceeded().invoice(swagInvoice).payment(swagPayment).refund(swagRefund);
case FAILED -> new RefundFailed().invoice(swagInvoice).payment(swagPayment).refund(swagRefund);
case PENDING -> new RefundCreated()
.invoice(swagInvoice)
.payment(swagPayment)
.refund(swagRefund)
.eventType(Event.EventTypeEnum.REFUNDPENDING);
case SUCCEEDED -> new RefundSucceeded()
.invoice(swagInvoice)
.payment(swagPayment)
.refund(swagRefund)
.eventType(Event.EventTypeEnum.REFUNDSUCCEEDED);
case FAILED -> new RefundFailed()
.invoice(swagInvoice)
.payment(swagPayment)
.refund(swagRefund)
.eventType(Event.EventTypeEnum.REFUNDFAILED);
default -> throw new UnsupportedOperationException("Unknown refund status " + message.getRefundStatus());
};
}