@Override public UUID apply(@Nullable final Payment input) { if (input == null) { return null; } else { return input.getId(); } } });
@GET @Path("/{invoiceId:" + UUID_PATTERN + "}/" + PAYMENTS) @Produces(APPLICATION_JSON) public Response getPayments(@PathParam("invoiceId") final String invoiceId, @QueryParam(QUERY_AUDIT) @DefaultValue("NONE") final AuditMode auditMode, @javax.ws.rs.core.Context final HttpServletRequest request) throws PaymentApiException { final TenantContext tenantContext = context.createContext(request); final List<Payment> payments = paymentApi.getInvoicePayments(UUID.fromString(invoiceId), tenantContext); final List<PaymentJson> result = new ArrayList<PaymentJson>(payments.size()); if (payments.size() == 0) { return Response.status(Status.OK).entity(result).build(); } final AccountAuditLogsForObjectType auditLogsForPayments = auditUserApi.getAccountAuditLogs(payments.get(0).getAccountId(), ObjectType.PAYMENT, auditMode.getLevel(), tenantContext); for (final Payment cur : payments) { result.add(new PaymentJson(cur, auditLogsForPayments.getAuditLogs(cur.getId()))); } return Response.status(Status.OK).entity(result).build(); }
@Override public PaymentJson apply(final Payment payment) { // Cache audit logs per account if (accountsAuditLogs.get().get(payment.getAccountId()) == null) { accountsAuditLogs.get().put(payment.getAccountId(), auditUserApi.getAccountAuditLogs(payment.getAccountId(), auditMode.getLevel(), tenantContext)); } return new PaymentJson(payment, accountsAuditLogs.get().get(payment.getAccountId()).getAuditLogsForPayment(payment.getId())); } },
@Override public PaymentJson apply(final Payment payment) { // Cache audit logs per account if (accountsAuditLogs.get().get(payment.getAccountId()) == null) { accountsAuditLogs.get().put(payment.getAccountId(), auditUserApi.getAccountAuditLogs(payment.getAccountId(), auditMode.getLevel(), tenantContext)); } return new PaymentJson(payment, accountsAuditLogs.get().get(payment.getAccountId()).getAuditLogsForPayment(payment.getId())); } },
final Map<UUID, Payment> payments = new HashMap<UUID, Payment>(); for (final Payment payment : accountPayments) { payments.put(payment.getId(), payment); final Payment paymentInfo = payments.get(paymentId); bipDao.invoicePaymentPosted(paymentInfo.getAccountId(), paymentInfo.getId(), paymentInfo.getPaymentStatus().toString(), internalCallContext);
public PaymentJson(final Payment payment, final String bundleExternalKey, final List<RefundJson> refunds, final List<ChargebackJson> chargebacks, @Nullable final List<AuditLog> auditLogs) { this(payment.getAmount(), payment.getPaidAmount(), payment.getAccountId().toString(), payment.getInvoiceId().toString(), payment.getId().toString(), payment.getPaymentNumber().toString(), payment.getPaymentMethodId().toString(), payment.getEffectiveDate(), payment.getEffectiveDate(), payment.getAttempts().size(), payment.getCurrency().toString(), payment.getPaymentStatus().toString(), payment.getAttempts().get(payment.getAttempts().size() - 1).getGatewayErrorCode(), payment.getAttempts().get(payment.getAttempts().size() - 1).getGatewayErrorMsg(), bundleExternalKey, refunds, chargebacks, toAuditLogJson(auditLogs)); }
@Override public Void inTransaction(final BusinessInvoicePaymentSqlDao transactional, final TransactionStatus status) throws Exception { // Delete the existing payment if it exists - this is to make the call idempotent transactional.deleteInvoicePayment(payment.getId().toString(), context); // Create the bip record transactional.createInvoicePayment(businessInvoicePayment, context); if (invoice != null) { // Update bin to get the latest invoice balance final BusinessInvoiceSqlDao invoiceSqlDao = transactional.become(BusinessInvoiceSqlDao.class); invoiceDao.rebuildInvoiceInTransaction(account.getExternalKey(), invoice, invoiceSqlDao, context); } // Update bac to get the latest account balance, total invoice balance, etc. final BusinessAccountSqlDao accountSqlDao = transactional.become(BusinessAccountSqlDao.class); accountDao.updateAccountInTransaction(bac, accountSqlDao, context); log.info("Added payment {}", businessInvoicePayment); return null; } });
for (final Payment payment : payments) { final List<RefundJson> refunds = new ArrayList<RefundJson>(); for (final Refund refund : refundsByPayment.get(payment.getId())) { final List<AuditLog> auditLogs = accountAuditLogs.getAuditLogsForRefund(refund.getId()); for (final InvoicePayment chargeback : chargebacksByPayment.get(payment.getId())) { final List<AuditLog> auditLogs = accountAuditLogs.getAuditLogsForChargeback(chargeback.getId()); chargebacks.add(new ChargebackJson(payment.getAccountId(), chargeback, auditLogs)); final List<AuditLog> auditLogs = accountAuditLogs.getAuditLogsForPayment(payment.getId()); this.payments.add(new PaymentJson(payment, getBundleExternalKey(payment.getInvoiceId(), invoices, bundles),
fail("Expected to fail because requested amount > invoice amount"); assertNotNull(paymentInfo.getId()); assertTrue(paymentInfo.getAmount().compareTo(expectedAmount.setScale(2, RoundingMode.HALF_EVEN)) == 0); assertNotNull(paymentInfo.getPaymentNumber());
payment.getInvoiceId(), message, payment.getId(), paymentMethodString, "Electronic",