@GET @Path("/{paymentId:" + UUID_PATTERN + "}/" + TAGS) @Produces(APPLICATION_JSON) public Response getTags(@PathParam(ID_PARAM_NAME) final String paymentIdString, @QueryParam(QUERY_AUDIT) @DefaultValue("NONE") final AuditMode auditMode, @QueryParam(QUERY_TAGS_INCLUDED_DELETED) @DefaultValue("false") final Boolean includedDeleted, @javax.ws.rs.core.Context final HttpServletRequest request) throws TagDefinitionApiException, PaymentApiException { final UUID paymentId = UUID.fromString(paymentIdString); final TenantContext tenantContext = context.createContext(request); final Payment payment = paymentApi.getPayment(paymentId, false, tenantContext); return super.getTags(payment.getAccountId(), paymentId, auditMode, includedDeleted, tenantContext); }
@GET @Path("/{paymentId:" + UUID_PATTERN + "}") @Produces(APPLICATION_JSON) public Response getPayment(@PathParam(ID_PARAM_NAME) final String paymentIdString, @QueryParam(QUERY_PAYMENT_WITH_REFUNDS_AND_CHARGEBACKS) @DefaultValue("false") final Boolean withRefundsAndChargebacks, @javax.ws.rs.core.Context final HttpServletRequest request) throws PaymentApiException { final TenantContext tenantContext = context.createContext(request); final UUID paymentId = UUID.fromString(paymentIdString); final Payment payment = paymentApi.getPayment(paymentId, false, tenantContext); final PaymentJson paymentJson; if (withRefundsAndChargebacks) { final List<RefundJson> refunds = new ArrayList<RefundJson>(); for (final Refund refund : paymentApi.getPaymentRefunds(paymentId, tenantContext)) { refunds.add(new RefundJson(refund)); } final List<ChargebackJson> chargebacks = new ArrayList<ChargebackJson>(); for (final InvoicePayment chargeback : invoicePaymentApi.getChargebacksByPaymentId(paymentId, tenantContext)) { chargebacks.add(new ChargebackJson(payment.getAccountId(), chargeback)); } paymentJson = new PaymentJson(payment, null, // TODO - the keys are really only used for the timeline refunds, chargebacks); } else { paymentJson = new PaymentJson(payment, null); } return Response.status(Status.OK).entity(paymentJson).build(); }
@PUT @Path("/{paymentId:" + UUID_PATTERN + "}") @Consumes(APPLICATION_JSON) @Produces(APPLICATION_JSON) public Response retryFailedPayment(@PathParam(ID_PARAM_NAME) final String paymentIdString, @HeaderParam(HDR_CREATED_BY) final String createdBy, @HeaderParam(HDR_REASON) final String reason, @HeaderParam(HDR_COMMENT) final String comment, @javax.ws.rs.core.Context final HttpServletRequest request) throws AccountApiException, PaymentApiException { final CallContext callContext = context.createContext(createdBy, reason, comment, request); final UUID paymentId = UUID.fromString(paymentIdString); final Payment payment = paymentApi.getPayment(paymentId, false, callContext); final Account account = accountUserApi.getAccountById(payment.getAccountId(), callContext); final Payment newPayment = paymentApi.retryPayment(account, paymentId, callContext); return Response.status(Status.OK).entity(new PaymentJson(newPayment, null)).build(); }
@Override public RefundJson apply(final Refund refund) { UUID kbAccountId = null; if (!AuditLevel.NONE.equals(auditMode.getLevel()) && paymentIdAccountIdMappings.get(refund.getPaymentId()) == null) { try { kbAccountId = paymentApi.getPayment(refund.getPaymentId(), false, tenantContext).getAccountId(); paymentIdAccountIdMappings.put(refund.getPaymentId(), kbAccountId); } catch (final PaymentApiException e) { log.warn("Unable to retrieve payment for id " + refund.getPaymentId()); } } // Cache audit logs per account if (accountsAuditLogs.get().get(kbAccountId) == null) { accountsAuditLogs.get().put(kbAccountId, auditUserApi.getAccountAuditLogs(kbAccountId, auditMode.getLevel(), tenantContext)); } final List<AuditLog> auditLogs = accountsAuditLogs.get().get(kbAccountId) == null ? null : accountsAuditLogs.get().get(kbAccountId).getAuditLogsForRefund(refund.getId()); return new RefundJson(refund, null, auditLogs); } },
@Override public RefundJson apply(final Refund refund) { UUID kbAccountId = null; if (!AuditLevel.NONE.equals(auditMode.getLevel()) && paymentIdAccountIdMappings.get(refund.getPaymentId()) == null) { try { kbAccountId = paymentApi.getPayment(refund.getPaymentId(), false, tenantContext).getAccountId(); paymentIdAccountIdMappings.put(refund.getPaymentId(), kbAccountId); } catch (final PaymentApiException e) { log.warn("Unable to retrieve payment for id " + refund.getPaymentId()); } } // Cache audit logs per account if (accountsAuditLogs.get().get(kbAccountId) == null) { accountsAuditLogs.get().put(kbAccountId, auditUserApi.getAccountAuditLogs(kbAccountId, auditMode.getLevel(), tenantContext)); } final List<AuditLog> auditLogs = accountsAuditLogs.get().get(kbAccountId) == null ? null : accountsAuditLogs.get().get(kbAccountId).getAuditLogsForRefund(refund.getId()); return new RefundJson(refund, null, auditLogs); } },
final Payment payment = paymentApi.getPayment(paymentUuid, false, callContext); final Account account = accountUserApi.getAccountById(payment.getAccountId(), callContext);