public static InvoicePayment createAndPersistPayment(final InvoiceInternalApi invoicePaymentApi,
final Clock clock,
final UUID invoiceId,
final BigDecimal amount,
final Currency currency,
final InternalCallContext callContext) throws InvoiceApiException {
final InvoicePayment payment = Mockito.mock(InvoicePayment.class);
Mockito.when(payment.getId()).thenReturn(UUID.randomUUID());
Mockito.when(payment.getType()).thenReturn(InvoicePaymentType.ATTEMPT);
Mockito.when(payment.getInvoiceId()).thenReturn(invoiceId);
Mockito.when(payment.getPaymentId()).thenReturn(UUID.randomUUID());
Mockito.when(payment.getPaymentCookieId()).thenReturn(UUID.randomUUID().toString());
final DateTime utcNow = clock.getUTCNow();
Mockito.when(payment.getPaymentDate()).thenReturn(utcNow);
Mockito.when(payment.getAmount()).thenReturn(amount);
Mockito.when(payment.getCurrency()).thenReturn(currency);
Mockito.when(payment.getProcessedCurrency()).thenReturn(currency);
Mockito.when(payment.isSuccess()).thenReturn(true);
invoicePaymentApi.recordPaymentAttemptCompletion(payment.getInvoiceId(), payment.getAmount(), payment.getCurrency(), payment.getProcessedCurrency(), payment.getPaymentId(), payment.getPaymentCookieId(),
payment.getPaymentDate(), payment.isSuccess(), callContext);
return payment;
}
}