Details
diff --git a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestPaymentRefund.java b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestPaymentRefund.java
index b501af7..86912e4 100644
--- a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestPaymentRefund.java
+++ b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestPaymentRefund.java
@@ -116,8 +116,7 @@ public class TestPaymentRefund extends TestIntegrationBase {
}
}
- @Test(groups = "slow", description = "https://github.com/killbill/killbill/issues/255",
- expectedExceptions = PaymentApiException.class, expectedExceptionsMessageRegExp = "Payment method .* does not exist")
+ @Test(groups = "slow", description = "https://github.com/killbill/killbill/issues/255")
public void testRefundWithDeletedPaymentMethod() throws Exception {
// delete payment method
@@ -126,8 +125,10 @@ public class TestPaymentRefund extends TestIntegrationBase {
assertListenerStatus();
// try to create a refund for a payment with its payment method deleted
+ busHandler.pushExpectedEvent(NextEvent.PAYMENT);
paymentApi.createRefund(account, payment.getId(), payment.getPurchasedAmount(), payment.getCurrency(),
UUID.randomUUID().toString(), PLUGIN_PROPERTIES, callContext);
+ assertListenerStatus();
}
private void setupRefundTest() throws Exception {
diff --git a/payment/src/main/java/org/killbill/billing/payment/core/sm/PaymentAutomatonRunner.java b/payment/src/main/java/org/killbill/billing/payment/core/sm/PaymentAutomatonRunner.java
index c1304a7..19d4d38 100644
--- a/payment/src/main/java/org/killbill/billing/payment/core/sm/PaymentAutomatonRunner.java
+++ b/payment/src/main/java/org/killbill/billing/payment/core/sm/PaymentAutomatonRunner.java
@@ -192,6 +192,7 @@ public class PaymentAutomatonRunner {
operationCallback = new RefundOperation(daoHelper, locker, paymentPluginDispatcher, paymentConfig, paymentStateContext);
leavingStateCallback = new RefundInitiated(daoHelper, paymentStateContext);
enteringStateCallback = new RefundCompleted(daoHelper, paymentStateContext);
+ includeDeletedPaymentMethod = Boolean.TRUE;
break;
case CREDIT:
operationCallback = new CreditOperation(daoHelper, locker, paymentPluginDispatcher, paymentConfig, paymentStateContext);
diff --git a/payment/src/test/java/org/killbill/billing/payment/api/TestPaymentApi.java b/payment/src/test/java/org/killbill/billing/payment/api/TestPaymentApi.java
index af49a16..d31b5ca 100644
--- a/payment/src/test/java/org/killbill/billing/payment/api/TestPaymentApi.java
+++ b/payment/src/test/java/org/killbill/billing/payment/api/TestPaymentApi.java
@@ -26,8 +26,10 @@ import java.util.List;
import java.util.UUID;
import javax.annotation.Nullable;
+import javax.annotation.concurrent.Immutable;
import org.joda.time.LocalDate;
+import org.joda.time.LocalDate.Property;
import org.killbill.billing.ErrorCode;
import org.killbill.billing.account.api.Account;
import org.killbill.billing.catalog.api.Currency;
@@ -183,6 +185,19 @@ public class TestPaymentApi extends PaymentTestSuiteWithEmbeddedDB {
checkPaymentMethodPagination(paymentMethodId, baseNbRecords + 1, false);
}
+ @Test(groups = "slow", description="Verify we can make a refund on payment whose original payment method was deleted. See 694")
+ public void testRefundAfterDeletedPaymentMethod() throws PaymentApiException {
+
+ final BigDecimal requestedAmount = BigDecimal.TEN;
+ final Payment payment = paymentApi.createPurchase(account, account.getPaymentMethodId(), null, requestedAmount, Currency.EUR, UUID.randomUUID().toString(), UUID.randomUUID().toString(),
+ ImmutableList.<PluginProperty>of(), callContext);
+
+ paymentApi.deletePaymentMethod(account, account.getPaymentMethodId(), false, true, ImmutableList.<PluginProperty>of(), callContext);
+
+ final Payment newPayment = paymentApi.createRefund(account, payment.getId(),requestedAmount, Currency.EUR, UUID.randomUUID().toString(), ImmutableList.<PluginProperty>of(), callContext);
+ Assert.assertEquals(newPayment.getTransactions().size(), 2);
+ }
+
@Test(groups = "slow")
public void testCreateSuccessPurchase() throws PaymentApiException {