use of org.killbill.billing.payment.provider.DefaultNoOpPaymentInfoPlugin in project killbill by killbill.
the class PaymentOperation method convertToUnknownTransactionStatusAndErroredPaymentState.
//
// In case of exceptions, timeouts, we don't really know what happened:
// - Return an OperationResult.EXCEPTION to transition Payment State to Errored (see PaymentTransactionInfoPluginConverter#toOperationResult)
// - Construct a PaymentTransactionInfoPlugin whose PaymentPluginStatus = UNDEFINED to end up with a paymentTransactionStatus = UNKNOWN and have a chance to
// be fixed by Janitor.
//
private OperationException convertToUnknownTransactionStatusAndErroredPaymentState(final Exception e) {
final PaymentTransactionInfoPlugin paymentInfoPlugin = new DefaultNoOpPaymentInfoPlugin(paymentStateContext.getPaymentId(), paymentStateContext.getTransactionId(), paymentStateContext.getTransactionType(), paymentStateContext.getAmount(), paymentStateContext.getCurrency(), paymentStateContext.getCallContext().getCreatedDate(), paymentStateContext.getCallContext().getCreatedDate(), PaymentPluginStatus.UNDEFINED, null, null);
paymentStateContext.setPaymentTransactionInfoPlugin(paymentInfoPlugin);
if (e.getCause() instanceof OperationException) {
return (OperationException) e.getCause();
}
if (e instanceof OperationException) {
return (OperationException) e;
}
return new OperationException(e, OperationResult.EXCEPTION);
}
use of org.killbill.billing.payment.provider.DefaultNoOpPaymentInfoPlugin in project killbill by killbill.
the class TestIncompletePaymentTransactionTaskWithDB method testUpdateWithinLock.
@Test(groups = "slow", description = "https://github.com/killbill/killbill/issues/809")
public void testUpdateWithinLock() throws PaymentApiException {
final Payment payment = paymentApi.createAuthorization(account, account.getPaymentMethodId(), null, BigDecimal.TEN, Currency.EUR, null, UUID.randomUUID().toString(), UUID.randomUUID().toString(), ImmutableList.<PluginProperty>of(new PluginProperty(MockPaymentProviderPlugin.PLUGIN_PROPERTY_PAYMENT_PLUGIN_STATUS_OVERRIDE, PaymentPluginStatus.UNDEFINED.toString(), false)), callContext);
final PaymentModelDao paymentModel = paymentDao.getPayment(payment.getId(), internalCallContext);
final UUID transactionId = payment.getTransactions().get(0).getId();
final PaymentTransactionModelDao transactionModel = paymentDao.getPaymentTransaction(transactionId, internalCallContext);
Assert.assertEquals(paymentModel.getStateName(), "AUTH_ERRORED");
Assert.assertEquals(transactionModel.getTransactionStatus().toString(), "UNKNOWN");
paymentDao.updatePaymentAndTransactionOnCompletion(account.getId(), null, payment.getId(), TransactionType.AUTHORIZE, "AUTH_SUCCESS", "AUTH_SUCCESS", transactionId, TransactionStatus.SUCCESS, BigDecimal.TEN, Currency.EUR, "200", "Ok", true, internalCallContext);
paymentApi.createCapture(account, payment.getId(), BigDecimal.TEN, Currency.EUR, null, UUID.randomUUID().toString(), ImmutableList.<PluginProperty>of(new PluginProperty(MockPaymentProviderPlugin.PLUGIN_PROPERTY_PAYMENT_PLUGIN_STATUS_OVERRIDE, PaymentPluginStatus.PROCESSED.toString(), false)), callContext);
final PaymentModelDao paymentAfterCapture = paymentDao.getPayment(payment.getId(), internalCallContext);
Assert.assertEquals(paymentAfterCapture.getStateName(), "CAPTURE_SUCCESS");
PaymentTransactionInfoPlugin paymentTransactionInfoPlugin = new DefaultNoOpPaymentInfoPlugin(payment.getId(), transactionId, TransactionType.AUTHORIZE, BigDecimal.TEN, Currency.EUR, transactionModel.getEffectiveDate(), transactionModel.getCreatedDate(), PaymentPluginStatus.PROCESSED, "200", "OK");
incompletePaymentTransactionTask.updatePaymentAndTransactionIfNeeded(paymentModel.getAccountId(), transactionModel.getId(), payment.getTransactions().get(0).getTransactionStatus(), paymentTransactionInfoPlugin, true, internalCallContext);
final PaymentModelDao paymentAfterJanitor = paymentDao.getPayment(payment.getId(), internalCallContext);
Assert.assertEquals(paymentAfterJanitor.getStateName(), "CAPTURE_SUCCESS");
}
Aggregations