private Payment fromPaymentModelDao(final PaymentModelDao input, @Nullable final PaymentInfoPlugin pluginInfo, final InternalTenantContext context) { final List<PaymentAttemptModelDao> attempts = paymentDao.getAttemptsForPayment(input.getId(), context); final List<RefundModelDao> refunds = paymentDao.getRefundsForPayment(input.getId(), context); final Payment payment = new DefaultPayment(input, pluginInfo, attempts, refunds); return payment; }
public DefaultPayment(final PaymentModelDao src, @Nullable final PaymentInfoPlugin paymentPluginInfo, final List<PaymentAttemptModelDao> attempts, final List<RefundModelDao> refunds) { this(src.getId(), src.getCreatedDate(), src.getUpdatedDate(), src.getAccountId(), src.getInvoiceId(), src.getPaymentMethodId(), src.getAmount(), toPaidAmount(src.getPaymentStatus(), src.getAmount(), refunds), src.getCurrency(), src.getEffectiveDate(), src.getPaymentNumber(), src.getPaymentStatus(), paymentPluginInfo, toPaymentAttempts(attempts)); }
private Payment setTerminalStateOnRetryWithAccountLocked(final Account account, final Invoice invoice, final PaymentModelDao payment, final BigDecimal requestedAmount, final String terminalStateReason, final InternalCallContext context) { final PaymentStatus paymentStatus; switch (payment.getPaymentStatus()) { case PAYMENT_FAILURE: paymentStatus = PaymentStatus.PAYMENT_FAILURE_ABORTED; break; case PLUGIN_FAILURE: case UNKNOWN: paymentStatus = PaymentStatus.PLUGIN_FAILURE_ABORTED; break; case AUTO_PAY_OFF: default: throw new IllegalStateException("Unexpected payment status for retry " + payment.getPaymentStatus()); } final PaymentAttemptModelDao attempt = new PaymentAttemptModelDao(account.getId(), invoice.getId(), payment.getId(), account.getPaymentMethodId(), clock.getUTCNow(), requestedAmount, invoice.getCurrency()); paymentDao.updatePaymentWithNewAttempt(payment.getId(), attempt, context); paymentDao.updatePaymentAndAttemptOnCompletion(payment.getId(), paymentStatus, requestedAmount, account.getCurrency(), attempt.getId(), null, terminalStateReason, context); final List<PaymentAttemptModelDao> allAttempts = paymentDao.getAttemptsForPayment(payment.getId(), context); return new DefaultPayment(payment, null, allAttempts, Collections.<RefundModelDao>emptyList()); }
attemptInput.getRequestedAmount(), account.getCurrency(), attemptInput.getId(), null, null, context); allAttempts = paymentDao.getAttemptsForPayment(paymentInput.getId(), context); return new DefaultPayment(paymentInput, null, allAttempts, Collections.<RefundModelDao>emptyList()); return new DefaultPayment(payment, paymentPluginInfo, allAttempts, Collections.<RefundModelDao>emptyList());