jaxrs: fix refund path
@@ -190,7 +190,7 @@ public class InvoicePaymentResource extends JaxRsResourceBase {
final UUID paymentIdToRedirectTo;
if (externalPayment) {
- final InvoicePayment result = invoicePaymentApi.createCreditForInvoicePayment(isAdjusted,
+ invoicePaymentApi.createCreditForInvoicePayment(isAdjusted,
adjustments,
account,
paymentId,
@@ -207,7 +207,7 @@ public class InvoicePaymentResource extends JaxRsResourceBase {
// /!\ Note! The invoicePayment#paymentId points to the original payment (PURCHASE) here, NOT the new one (CREDIT)
paymentIdToRedirectTo = paymentApi.getPaymentByTransactionExternalKey(transactionExternalKey, false, false, ImmutableList.<PluginProperty>of(), callContext).getId();
} else {
- final InvoicePayment result = invoicePaymentApi.createRefundForInvoicePayment(isAdjusted,
+ invoicePaymentApi.createRefundForInvoicePayment(isAdjusted,
adjustments,
account,
payment.getId(),
@@ -218,7 +218,8 @@ public class InvoicePaymentResource extends JaxRsResourceBase {
pluginProperties,
createInvoicePaymentControlPluginApiPaymentOptions(false),
callContext);
- paymentIdToRedirectTo = result.getPaymentId();
+ // Note that the InvoicePayment may not be created (i.e. return null), even though the refund went through (wrong item adjustments for instance)
+ paymentIdToRedirectTo = payment.getId();
}
return uriBuilder.buildResponse(uriInfo, InvoicePaymentResource.class, "getInvoicePayment", paymentIdToRedirectTo, request);
