killbill-aplcache
Changes
beatrix/src/test/java/org/killbill/billing/beatrix/integration/osgi/TestBasicOSGIWithTestBundle.java 27(+16 -11)
beatrix/src/test/java/org/killbill/billing/beatrix/integration/osgi/TestJrubyPaymentPlugin.java 50(+27 -23)
beatrix/src/test/java/org/killbill/billing/beatrix/integration/osgi/TestPaymentOSGIWithTestPaymentBundle.java 32(+18 -14)
osgi-bundles/bundles/jruby/src/main/java/org/killbill/billing/osgi/bundles/jruby/JRubyPaymentPlugin.java 80(+41 -39)
osgi-bundles/tests/beatrix/src/test/java/org/killbill/billing/osgi/bundles/test/TestPaymentPluginApi.java 48(+28 -20)
osgi-bundles/tests/payment/src/test/java/org/killbill/billing/osgi/bundles/test/TestPaymentPluginApi.java 54(+34 -20)
payment/src/main/java/org/killbill/billing/payment/provider/DefaultNoOpPaymentInfoPlugin.java 9(+9 -0)
payment/src/main/java/org/killbill/billing/payment/provider/DefaultNoOpPaymentMethodPlugin.java 16(+9 -7)
payment/src/main/java/org/killbill/billing/payment/provider/DefaultNoOpPaymentProviderPlugin.java 48(+25 -23)
payment/src/main/java/org/killbill/billing/payment/provider/DefaultNoOpRefundInfoPlugin.java 14(+12 -2)
payment/src/main/java/org/killbill/billing/payment/provider/ExternalPaymentProviderPlugin.java 48(+25 -23)
payment/src/test/java/org/killbill/billing/payment/core/TestPaymentMethodProcessorRefreshWithDB.java 39(+19 -20)
payment/src/test/java/org/killbill/billing/payment/provider/MockPaymentProviderPlugin.java 45(+24 -21)
payment/src/test/java/org/killbill/billing/payment/provider/TestDefaultNoOpPaymentMethodPlugin.java 21(+11 -10)
payment/src/test/java/org/killbill/billing/payment/provider/TestExternalPaymentProviderPlugin.java 25(+13 -12)
pom.xml 2(+1 -1)
Details
diff --git a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/osgi/TestBasicOSGIWithTestBundle.java b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/osgi/TestBasicOSGIWithTestBundle.java
index 4ff1bce..c125071 100644
--- a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/osgi/TestBasicOSGIWithTestBundle.java
+++ b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/osgi/TestBasicOSGIWithTestBundle.java
@@ -1,7 +1,9 @@
/*
* Copyright 2010-2013 Ning, Inc.
+ * Copyright 2014 Groupon, Inc
+ * Copyright 2014 The Billing Project, LLC
*
- * Ning licenses this file to you under the Apache License, version 2.0
+ * The Billing Project licenses this file to you under the Apache License, version 2.0
* (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
*
@@ -30,6 +32,7 @@ import org.killbill.billing.account.api.Account;
import org.killbill.billing.beatrix.osgi.SetupBundleWithAssertion;
import org.killbill.billing.catalog.api.Currency;
import org.killbill.billing.osgi.api.OSGIServiceRegistration;
+import org.killbill.billing.payment.api.PluginProperty;
import org.killbill.billing.payment.plugin.api.PaymentInfoPlugin;
import org.killbill.billing.payment.plugin.api.PaymentPluginApi;
import org.skife.jdbi.v2.Handle;
@@ -43,6 +46,8 @@ import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
+import com.google.common.collect.ImmutableList;
+
import static com.jayway.awaitility.Awaitility.await;
/**
@@ -69,7 +74,7 @@ public class TestBasicOSGIWithTestBundle extends TestOSGIBase {
// This is extracted from surefire system configuration-- needs to be added explicitly in IntelliJ for correct running
final String killbillVersion = System.getProperty("killbill.version");
- SetupBundleWithAssertion setupTest = new SetupBundleWithAssertion(BUNDLE_TEST_RESOURCE, osgiConfig, killbillVersion);
+ final SetupBundleWithAssertion setupTest = new SetupBundleWithAssertion(BUNDLE_TEST_RESOURCE, osgiConfig, killbillVersion);
setupTest.setupJavaBundle();
}
@@ -91,12 +96,12 @@ public class TestBasicOSGIWithTestBundle extends TestOSGIBase {
// Make a payment and expect test bundle to correcly write in its table the input values
final UUID paymentId = UUID.randomUUID();
final BigDecimal paymentAmount = new BigDecimal("14.32");
- final PaymentInfoPlugin r = paymentPluginApi.processPayment(account.getId(), paymentId, account.getPaymentMethodId(), paymentAmount, Currency.USD, callContext);
+ final PaymentInfoPlugin r = paymentPluginApi.processPayment(account.getId(), paymentId, account.getPaymentMethodId(), paymentAmount, Currency.USD, ImmutableList.<PluginProperty>of(), callContext);
assertTor.assertPluginCreatedPayment(paymentId, account.getPaymentMethodId(), paymentAmount);
}
private PaymentPluginApi getTestPluginPaymentApi() {
- PaymentPluginApi result = paymentPluginApiOSGIServiceRegistration.getServiceForName("test");
+ final PaymentPluginApi result = paymentPluginApiOSGIServiceRegistration.getServiceForName("test");
Assert.assertNotNull(result);
return result;
}
@@ -144,34 +149,34 @@ public class TestBasicOSGIWithTestBundle extends TestOSGIBase {
return callback.isSuccess();
}
});
- } catch (Exception e) {
+ } catch (final Exception e) {
Assert.fail(error, e);
}
}
private boolean isValidPayment(final UUID expectedPaymentId, final UUID expectedPaymentMethodId, final BigDecimal expectedAmount) {
- TestModel test = getTestModelFirstRecord();
+ final TestModel test = getTestModelFirstRecord();
return expectedPaymentId.equals(test.getPaymentId()) &&
expectedPaymentMethodId.equals(test.getPaymentMethodId()) &&
expectedAmount.compareTo(test.getAmount()) == 0;
}
private boolean isPluginInitialized() {
- TestModel test = getTestModelFirstRecord();
+ final TestModel test = getTestModelFirstRecord();
return test.isStarted();
}
private boolean isValidAccountExternalKey(final String expectedExternalKey) {
- TestModel test = getTestModelFirstRecord();
+ final TestModel test = getTestModelFirstRecord();
return expectedExternalKey.equals(test.getAccountExternalKey());
}
private TestModel getTestModelFirstRecord() {
- TestModel test = dbi.inTransaction(new TransactionCallback<TestModel>() {
+ final TestModel test = dbi.inTransaction(new TransactionCallback<TestModel>() {
@Override
public TestModel inTransaction(final Handle conn, final TransactionStatus status) throws Exception {
- Query<Map<String, Object>> q = conn.createQuery("SELECT is_started, external_key, payment_id, payment_method_id, payment_amount FROM test_bundle WHERE record_id = 1;");
- TestModel test = q.map(new TestMapper()).first();
+ final Query<Map<String, Object>> q = conn.createQuery("SELECT is_started, external_key, payment_id, payment_method_id, payment_amount FROM test_bundle WHERE record_id = 1;");
+ final TestModel test = q.map(new TestMapper()).first();
return test;
}
});
diff --git a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/osgi/TestJrubyPaymentPlugin.java b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/osgi/TestJrubyPaymentPlugin.java
index b539ee0..ec55d29 100644
--- a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/osgi/TestJrubyPaymentPlugin.java
+++ b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/osgi/TestJrubyPaymentPlugin.java
@@ -1,7 +1,9 @@
/*
* Copyright 2010-2013 Ning, Inc.
+ * Copyright 2014 Groupon, Inc
+ * Copyright 2014 The Billing Project, LLC
*
- * Ning licenses this file to you under the Apache License, version 2.0
+ * The Billing Project licenses this file to you under the Apache License, version 2.0
* (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
*
@@ -24,21 +26,23 @@ import javax.inject.Inject;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
-import org.testng.Assert;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
import org.killbill.billing.account.api.Account;
import org.killbill.billing.beatrix.osgi.SetupBundleWithAssertion;
import org.killbill.billing.catalog.api.Currency;
import org.killbill.billing.osgi.api.OSGIServiceRegistration;
import org.killbill.billing.payment.api.PaymentMethodPlugin;
+import org.killbill.billing.payment.api.PluginProperty;
import org.killbill.billing.payment.plugin.api.PaymentInfoPlugin;
import org.killbill.billing.payment.plugin.api.PaymentMethodInfoPlugin;
import org.killbill.billing.payment.plugin.api.PaymentPluginApi;
import org.killbill.billing.payment.plugin.api.PaymentPluginStatus;
import org.killbill.billing.payment.plugin.api.RefundInfoPlugin;
import org.killbill.billing.payment.plugin.api.RefundPluginStatus;
+import org.testng.Assert;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
import static org.testng.Assert.assertEquals;
@@ -61,7 +65,7 @@ public class TestJrubyPaymentPlugin extends TestOSGIBase {
// This is extracted from surefire system configuration-- needs to be added explicitly in IntelliJ for correct running
final String killbillVersion = System.getProperty("killbill.version");
- SetupBundleWithAssertion setupTest = new SetupBundleWithAssertion(BUNDLE_TEST_RESOURCE, osgiConfig, killbillVersion);
+ final SetupBundleWithAssertion setupTest = new SetupBundleWithAssertion(BUNDLE_TEST_RESOURCE, osgiConfig, killbillVersion);
setupTest.setupJrubyBundle();
}
@@ -69,12 +73,12 @@ public class TestJrubyPaymentPlugin extends TestOSGIBase {
@Test(groups = "slow")
public void testProcessPayment() throws Exception {
- PaymentPluginApi api = getTestPluginPaymentApi();
+ final PaymentPluginApi api = getTestPluginPaymentApi();
account = createAccountWithNonOsgiPaymentMethod(getAccountData(4));
final DateTime beforeCall = new DateTime().toDateTime(DateTimeZone.UTC).minusSeconds(1);
- PaymentInfoPlugin res = api.processPayment(account.getId(), UUID.randomUUID(), UUID.randomUUID(), BigDecimal.TEN, Currency.USD, callContext);
+ final PaymentInfoPlugin res = api.processPayment(account.getId(), UUID.randomUUID(), UUID.randomUUID(), BigDecimal.TEN, Currency.USD, ImmutableList.<PluginProperty>of(), callContext);
final DateTime afterCall = new DateTime().toDateTime(DateTimeZone.UTC).plusSeconds(1);
Assert.assertTrue(res.getAmount().compareTo(BigDecimal.TEN) == 0);
@@ -93,10 +97,10 @@ public class TestJrubyPaymentPlugin extends TestOSGIBase {
@Test(groups = "slow")
public void testGetPaymentInfo() throws Exception {
- PaymentPluginApi api = getTestPluginPaymentApi();
+ final PaymentPluginApi api = getTestPluginPaymentApi();
final DateTime beforeCall = new DateTime().toDateTime(DateTimeZone.UTC).minusSeconds(1);
- PaymentInfoPlugin res = api.getPaymentInfo(UUID.randomUUID(), UUID.randomUUID(), callContext);
+ final PaymentInfoPlugin res = api.getPaymentInfo(UUID.randomUUID(), UUID.randomUUID(), ImmutableList.<PluginProperty>of(), callContext);
final DateTime afterCall = new DateTime().toDateTime(DateTimeZone.UTC).plusSeconds(1);
Assert.assertTrue(res.getAmount().compareTo(BigDecimal.ZERO) == 0);
@@ -115,10 +119,10 @@ public class TestJrubyPaymentPlugin extends TestOSGIBase {
@Test(groups = "slow")
public void testProcessRefund() throws Exception {
- PaymentPluginApi api = getTestPluginPaymentApi();
+ final PaymentPluginApi api = getTestPluginPaymentApi();
final DateTime beforeCall = new DateTime().toDateTime(DateTimeZone.UTC).minusSeconds(1);
- RefundInfoPlugin res = api.processRefund(UUID.randomUUID(), UUID.randomUUID(), BigDecimal.TEN, Currency.USD, callContext);
+ final RefundInfoPlugin res = api.processRefund(UUID.randomUUID(), UUID.randomUUID(), BigDecimal.TEN, Currency.USD, ImmutableList.<PluginProperty>of(), callContext);
final DateTime afterCall = new DateTime().toDateTime(DateTimeZone.UTC).plusSeconds(1);
Assert.assertTrue(res.getAmount().compareTo(BigDecimal.TEN) == 0);
@@ -137,26 +141,26 @@ public class TestJrubyPaymentPlugin extends TestOSGIBase {
@Test(groups = "slow")
public void testAddPaymentMethod() throws Exception {
- PaymentPluginApi api = getTestPluginPaymentApi();
+ final PaymentPluginApi api = getTestPluginPaymentApi();
final DateTime beforeCall = new DateTime().toDateTime(DateTimeZone.UTC).minusSeconds(1);
final PaymentMethodPlugin info = createPaymentMethodPlugin();
- api.addPaymentMethod(UUID.randomUUID(), UUID.randomUUID(), info, true, callContext);
+ api.addPaymentMethod(UUID.randomUUID(), UUID.randomUUID(), info, true, ImmutableList.<PluginProperty>of(), callContext);
final DateTime afterCall = new DateTime().toDateTime(DateTimeZone.UTC).plusSeconds(1);
}
@Test(groups = "slow")
public void testDeletePaymentMethod() throws Exception {
- PaymentPluginApi api = getTestPluginPaymentApi();
- api.deletePaymentMethod(UUID.randomUUID(), UUID.randomUUID(), callContext);
+ final PaymentPluginApi api = getTestPluginPaymentApi();
+ api.deletePaymentMethod(UUID.randomUUID(), UUID.randomUUID(), ImmutableList.<PluginProperty>of(), callContext);
}
@Test(groups = "slow")
public void testGetPaymentMethodDetail() throws Exception {
- PaymentPluginApi api = getTestPluginPaymentApi();
- final PaymentMethodPlugin res = api.getPaymentMethodDetail(UUID.randomUUID(), UUID.randomUUID(), callContext);
+ final PaymentPluginApi api = getTestPluginPaymentApi();
+ final PaymentMethodPlugin res = api.getPaymentMethodDetail(UUID.randomUUID(), UUID.randomUUID(), ImmutableList.<PluginProperty>of(), callContext);
assertEquals(res.getExternalPaymentMethodId(), "external_payment_method_id");
Assert.assertTrue(res.isDefaultPaymentMethod());
@@ -170,17 +174,17 @@ public class TestJrubyPaymentPlugin extends TestOSGIBase {
@Test(groups = "slow")
public void testSetDefaultPaymentMethod() throws Exception {
- PaymentPluginApi api = getTestPluginPaymentApi();
+ final PaymentPluginApi api = getTestPluginPaymentApi();
final PaymentMethodPlugin info = createPaymentMethodPlugin();
- api.setDefaultPaymentMethod(UUID.randomUUID(), UUID.randomUUID(), callContext);
+ api.setDefaultPaymentMethod(UUID.randomUUID(), UUID.randomUUID(), ImmutableList.<PluginProperty>of(), callContext);
}
@Test(groups = "slow")
public void testGetPaymentMethods() throws Exception {
- PaymentPluginApi api = getTestPluginPaymentApi();
+ final PaymentPluginApi api = getTestPluginPaymentApi();
final UUID kbAccountId = UUID.randomUUID();
- final List<PaymentMethodInfoPlugin> res = api.getPaymentMethods(kbAccountId, true, callContext);
+ final List<PaymentMethodInfoPlugin> res = api.getPaymentMethods(kbAccountId, true, ImmutableList.<PluginProperty>of(), callContext);
assertEquals(res.size(), 1);
@@ -202,7 +206,7 @@ public class TestJrubyPaymentPlugin extends TestOSGIBase {
try {
log.info("Waiting for Killbill initialization to complete time = " + clock.getUTCNow());
Thread.sleep(1000);
- } catch (InterruptedException ignore) {
+ } catch (final InterruptedException ignore) {
}
}
} while (result == null && retry-- > 0);
diff --git a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/osgi/TestPaymentOSGIWithTestPaymentBundle.java b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/osgi/TestPaymentOSGIWithTestPaymentBundle.java
index d049306..46e8a09 100644
--- a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/osgi/TestPaymentOSGIWithTestPaymentBundle.java
+++ b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/osgi/TestPaymentOSGIWithTestPaymentBundle.java
@@ -1,7 +1,9 @@
/*
* Copyright 2010-2013 Ning, Inc.
+ * Copyright 2014 Groupon, Inc
+ * Copyright 2014 The Billing Project, LLC
*
- * Ning licenses this file to you under the Apache License, version 2.0
+ * The Billing Project licenses this file to you under the Apache License, version 2.0
* (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
*
@@ -24,11 +26,6 @@ import java.util.UUID;
import javax.inject.Inject;
import org.joda.time.LocalDate;
-import org.testng.Assert;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
import org.killbill.billing.account.api.Account;
import org.killbill.billing.account.api.AccountData;
import org.killbill.billing.api.TestApiListener.NextEvent;
@@ -44,9 +41,16 @@ import org.killbill.billing.invoice.api.Invoice;
import org.killbill.billing.invoice.api.InvoiceItemType;
import org.killbill.billing.osgi.api.OSGIServiceRegistration;
import org.killbill.billing.payment.api.PaymentStatus;
+import org.killbill.billing.payment.api.PluginProperty;
import org.killbill.billing.payment.plugin.api.PaymentPluginApi;
import org.killbill.billing.payment.plugin.api.PaymentPluginApiException;
import org.killbill.billing.payment.plugin.api.PaymentPluginApiWithTestControl;
+import org.testng.Assert;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
public class TestPaymentOSGIWithTestPaymentBundle extends TestOSGIBase {
@@ -62,7 +66,7 @@ public class TestPaymentOSGIWithTestPaymentBundle extends TestOSGIBase {
// This is extracted from surefire system configuration-- needs to be added explicitly in IntelliJ for correct running
final String killbillVersion = System.getProperty("killbill.version");
- SetupBundleWithAssertion setupTest = new SetupBundleWithAssertion(BUNDLE_TEST_RESOURCE, osgiConfig, killbillVersion);
+ final SetupBundleWithAssertion setupTest = new SetupBundleWithAssertion(BUNDLE_TEST_RESOURCE, osgiConfig, killbillVersion);
setupTest.setupJavaBundle();
}
@@ -76,7 +80,7 @@ public class TestPaymentOSGIWithTestPaymentBundle extends TestOSGIBase {
@Test(groups = "slow")
public void testBasicProcessPaymentOK() throws Exception {
final PaymentPluginApiWithTestControl paymentPluginApi = getTestPluginPaymentApi();
- paymentPluginApi.processPayment(UUID.randomUUID(), UUID.randomUUID(), UUID.randomUUID(), BigDecimal.TEN, Currency.USD, callContext);
+ paymentPluginApi.processPayment(UUID.randomUUID(), UUID.randomUUID(), UUID.randomUUID(), BigDecimal.TEN, Currency.USD, ImmutableList.<PluginProperty>of(), callContext);
}
@Test(groups = "slow")
@@ -88,9 +92,9 @@ public class TestPaymentOSGIWithTestPaymentBundle extends TestOSGIBase {
final PaymentPluginApiException e = new PaymentPluginApiException("test-error", "foo");
paymentPluginApi.setPaymentPluginApiExceptionOnNextCalls(e);
- paymentPluginApi.processPayment(UUID.randomUUID(), UUID.randomUUID(), UUID.randomUUID(), BigDecimal.TEN, Currency.USD, callContext);
+ paymentPluginApi.processPayment(UUID.randomUUID(), UUID.randomUUID(), UUID.randomUUID(), BigDecimal.TEN, Currency.USD, ImmutableList.<PluginProperty>of(), callContext);
Assert.fail("Expected to fail with " + e.toString());
- } catch (PaymentPluginApiException e) {
+ } catch (final PaymentPluginApiException e) {
gotException = true;
}
Assert.assertTrue(gotException);
@@ -105,9 +109,9 @@ public class TestPaymentOSGIWithTestPaymentBundle extends TestOSGIBase {
final RuntimeException e = new RuntimeException("test-error");
paymentPluginApi.setPaymentRuntimeExceptionOnNextCalls(e);
- paymentPluginApi.processPayment(UUID.randomUUID(), UUID.randomUUID(), UUID.randomUUID(), BigDecimal.TEN, Currency.USD, callContext);
+ paymentPluginApi.processPayment(UUID.randomUUID(), UUID.randomUUID(), UUID.randomUUID(), BigDecimal.TEN, Currency.USD, ImmutableList.<PluginProperty>of(), callContext);
Assert.fail("Expected to fail with " + e.toString());
- } catch (RuntimeException e) {
+ } catch (final RuntimeException e) {
gotException = true;
}
Assert.assertTrue(gotException);
@@ -164,7 +168,7 @@ public class TestPaymentOSGIWithTestPaymentBundle extends TestOSGIBase {
final DefaultEntitlement aoEntitlement = addAOEntitlementAndCheckForCompletion(baseEntitlement.getBundleId(), "Telescopic-Scope", ProductCategory.ADD_ON, BillingPeriod.MONTHLY,
expectedEvents.toArray(new NextEvent[expectedEvents.size()]));
- Invoice invoice = invoiceChecker.checkInvoice(account.getId(), 2, callContext, new ExpectedInvoiceItemCheck(new LocalDate(2012, 4, 1), new LocalDate(2012, 5, 1), InvoiceItemType.RECURRING, new BigDecimal("399.95")));
+ final Invoice invoice = invoiceChecker.checkInvoice(account.getId(), 2, callContext, new ExpectedInvoiceItemCheck(new LocalDate(2012, 4, 1), new LocalDate(2012, 5, 1), InvoiceItemType.RECURRING, new BigDecimal("399.95")));
if (expectedException == null && expectedRuntimeException == null) {
paymentChecker.checkPayment(account.getId(), 1, callContext, new ExpectedPaymentCheck(new LocalDate(2012, 4, 1), new BigDecimal("399.95"), PaymentStatus.SUCCESS, invoice.getId(), Currency.USD));
@@ -176,7 +180,7 @@ public class TestPaymentOSGIWithTestPaymentBundle extends TestOSGIBase {
}
private PaymentPluginApiWithTestControl getTestPluginPaymentApi() {
- PaymentPluginApiWithTestControl result = (PaymentPluginApiWithTestControl) paymentPluginApiOSGIServiceRegistration.getServiceForName(BeatrixIntegrationModule.OSGI_PLUGIN_NAME);
+ final PaymentPluginApiWithTestControl result = (PaymentPluginApiWithTestControl) paymentPluginApiOSGIServiceRegistration.getServiceForName(BeatrixIntegrationModule.OSGI_PLUGIN_NAME);
Assert.assertNotNull(result);
return result;
}
diff --git a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestIntegrationBase.java b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestIntegrationBase.java
index 12e24ad..d76edaf 100644
--- a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestIntegrationBase.java
+++ b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestIntegrationBase.java
@@ -1,8 +1,9 @@
/*
* Copyright 2010-2013 Ning, Inc.
- * Copyright 2014 Groupon, Inc.
+ * Copyright 2014 Groupon, Inc
+ * Copyright 2014 The Billing Project, LLC
*
- * Ning licenses this file to you under the Apache License, version 2.0
+ * The Billing Project licenses this file to you under the Apache License, version 2.0
* (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
*
@@ -31,19 +32,6 @@ import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.joda.time.LocalDate;
import org.killbill.billing.ObjectType;
-import org.killbill.billing.usage.api.UsageUserApi;
-import org.killbill.billing.util.api.TagApiException;
-import org.killbill.billing.util.api.TagDefinitionApiException;
-import org.killbill.billing.util.tag.ControlTagType;
-import org.killbill.billing.util.tag.Tag;
-import org.skife.jdbi.v2.IDBI;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.Assert;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.BeforeMethod;
-
import org.killbill.billing.account.api.Account;
import org.killbill.billing.account.api.AccountData;
import org.killbill.billing.account.api.AccountInternalApi;
@@ -60,7 +48,6 @@ import org.killbill.billing.beatrix.util.InvoiceChecker;
import org.killbill.billing.beatrix.util.PaymentChecker;
import org.killbill.billing.beatrix.util.RefundChecker;
import org.killbill.billing.beatrix.util.SubscriptionChecker;
-import org.killbill.bus.api.PersistentBus;
import org.killbill.billing.catalog.api.BillingActionPolicy;
import org.killbill.billing.catalog.api.BillingPeriod;
import org.killbill.billing.catalog.api.Currency;
@@ -85,8 +72,8 @@ import org.killbill.billing.overdue.wrapper.OverdueWrapperFactory;
import org.killbill.billing.payment.api.Payment;
import org.killbill.billing.payment.api.PaymentApi;
import org.killbill.billing.payment.api.PaymentApiException;
-import org.killbill.billing.payment.api.PaymentMethodKVInfo;
import org.killbill.billing.payment.api.PaymentMethodPlugin;
+import org.killbill.billing.payment.api.PluginProperty;
import org.killbill.billing.payment.api.TestPaymentMethodPluginBase;
import org.killbill.billing.payment.provider.MockPaymentProviderPlugin;
import org.killbill.billing.subscription.api.SubscriptionBase;
@@ -94,11 +81,23 @@ import org.killbill.billing.subscription.api.SubscriptionBaseService;
import org.killbill.billing.subscription.api.timeline.SubscriptionBaseTimelineApi;
import org.killbill.billing.subscription.api.transfer.SubscriptionBaseTransferApi;
import org.killbill.billing.subscription.api.user.DefaultSubscriptionBase;
+import org.killbill.billing.usage.api.UsageUserApi;
import org.killbill.billing.util.api.RecordIdApi;
+import org.killbill.billing.util.api.TagApiException;
+import org.killbill.billing.util.api.TagDefinitionApiException;
import org.killbill.billing.util.api.TagUserApi;
import org.killbill.billing.util.cache.CacheControllerDispatcher;
import org.killbill.billing.util.config.OSGIConfig;
import org.killbill.billing.util.svcsapi.bus.BusService;
+import org.killbill.billing.util.tag.ControlTagType;
+import org.killbill.billing.util.tag.Tag;
+import org.killbill.bus.api.PersistentBus;
+import org.skife.jdbi.v2.IDBI;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.BeforeMethod;
import com.google.common.base.Function;
import com.google.common.base.Joiner;
@@ -222,7 +221,7 @@ public class TestIntegrationBase extends BeatrixTestSuiteWithEmbeddedDB {
final Injector g = Guice.createInjector(Stage.PRODUCTION, new BeatrixIntegrationModule(configSource));
g.injectMembers(this);
- SetupBundleWithAssertion setupTest = new SetupBundleWithAssertion("whatever", osgiConfig, "whatever");
+ final SetupBundleWithAssertion setupTest = new SetupBundleWithAssertion("whatever", osgiConfig, "whatever");
setupTest.cleanBundleInstallDir();
}
@@ -306,9 +305,9 @@ public class TestIntegrationBase extends BeatrixTestSuiteWithEmbeddedDB {
private class TestPaymentMethodPlugin extends TestPaymentMethodPluginBase {
@Override
- public List<PaymentMethodKVInfo> getProperties() {
- PaymentMethodKVInfo prop = new PaymentMethodKVInfo("whatever", "cool", Boolean.TRUE);
- List<PaymentMethodKVInfo> res = new ArrayList<PaymentMethodKVInfo>();
+ public List<PluginProperty> getProperties() {
+ final PluginProperty prop = new PluginProperty("whatever", "cool", Boolean.TRUE);
+ final List<PluginProperty> res = new ArrayList<PluginProperty>();
res.add(prop);
return res;
}
@@ -375,7 +374,7 @@ public class TestIntegrationBase extends BeatrixTestSuiteWithEmbeddedDB {
public Void apply(@Nullable final Void input) {
try {
paymentApi.createPayment(account, invoice.getId(), invoice.getBalance(), callContext);
- } catch (PaymentApiException e) {
+ } catch (final PaymentApiException e) {
fail(e.toString());
}
return null;
@@ -389,7 +388,7 @@ public class TestIntegrationBase extends BeatrixTestSuiteWithEmbeddedDB {
public Void apply(@Nullable final Void input) {
try {
paymentApi.createExternalPayment(account, invoice.getId(), invoice.getBalance(), callContext);
- } catch (PaymentApiException e) {
+ } catch (final PaymentApiException e) {
fail(e.toString());
}
return null;
@@ -403,7 +402,7 @@ public class TestIntegrationBase extends BeatrixTestSuiteWithEmbeddedDB {
public Void apply(@Nullable final Void input) {
try {
paymentApi.createRefund(account, payment.getId(), payment.getPaidAmount(), callContext);
- } catch (PaymentApiException e) {
+ } catch (final PaymentApiException e) {
fail(e.toString());
}
return null;
@@ -417,7 +416,7 @@ public class TestIntegrationBase extends BeatrixTestSuiteWithEmbeddedDB {
public Void apply(@Nullable final Void input) {
try {
paymentApi.createRefundWithAdjustment(account, payment.getId(), payment.getPaidAmount(), callContext);
- } catch (PaymentApiException e) {
+ } catch (final PaymentApiException e) {
fail(e.toString());
}
return null;
@@ -431,7 +430,7 @@ public class TestIntegrationBase extends BeatrixTestSuiteWithEmbeddedDB {
public Void apply(@Nullable final Void input) {
try {
paymentApi.createRefundWithItemsAdjustments(account, payment.getId(), invoiceItems, callContext);
- } catch (PaymentApiException e) {
+ } catch (final PaymentApiException e) {
fail(e.toString());
}
return null;
@@ -445,7 +444,7 @@ public class TestIntegrationBase extends BeatrixTestSuiteWithEmbeddedDB {
public Void apply(@Nullable final Void input) {
try {
invoicePaymentApi.createChargeback(payment.getId(), payment.getAmount(), callContext);
- } catch (InvoiceApiException e) {
+ } catch (final InvoiceApiException e) {
fail(e.toString());
}
return null;
@@ -472,7 +471,7 @@ public class TestIntegrationBase extends BeatrixTestSuiteWithEmbeddedDB {
final Entitlement entitlement = entitlementApi.createBaseEntitlement(accountId, spec, bundleExternalKey, effectiveDate, callContext);
assertNotNull(entitlement);
return entitlement;
- } catch (EntitlementApiException e) {
+ } catch (final EntitlementApiException e) {
fail();
return null;
}
@@ -498,7 +497,7 @@ public class TestIntegrationBase extends BeatrixTestSuiteWithEmbeddedDB {
final Entitlement entitlement = entitlementApi.addEntitlement(bundleId, spec, effectiveDate, callContext);
assertNotNull(entitlement);
return entitlement;
- } catch (EntitlementApiException e) {
+ } catch (final EntitlementApiException e) {
fail(e.getMessage());
return null;
}
@@ -524,7 +523,7 @@ public class TestIntegrationBase extends BeatrixTestSuiteWithEmbeddedDB {
refreshedEntitlement = refreshedEntitlement.changePlanOverrideBillingPolicy(productName, billingPeriod, priceList, clock.getUTCNow().toLocalDate(), billingPolicy, callContext);
}
return refreshedEntitlement;
- } catch (EntitlementApiException e) {
+ } catch (final EntitlementApiException e) {
fail(e.getMessage());
return null;
}
@@ -532,7 +531,6 @@ public class TestIntegrationBase extends BeatrixTestSuiteWithEmbeddedDB {
}, events);
}
-
protected DefaultEntitlement changeEntitlementAndCheckForCompletion(final Entitlement entitlement,
final String productName,
final BillingPeriod billingPeriod,
@@ -552,7 +550,7 @@ public class TestIntegrationBase extends BeatrixTestSuiteWithEmbeddedDB {
Entitlement refreshedEntitlement = entitlementApi.getEntitlementForId(entitlement.getId(), callContext);
refreshedEntitlement = refreshedEntitlement.cancelEntitlementWithDate(requestedDate.toLocalDate(), false, callContext);
return refreshedEntitlement;
- } catch (EntitlementApiException e) {
+ } catch (final EntitlementApiException e) {
fail(e.getMessage());
return null;
}
@@ -567,7 +565,7 @@ public class TestIntegrationBase extends BeatrixTestSuiteWithEmbeddedDB {
try {
invoiceUserApi.insertCreditForInvoice(account.getId(), invoice.getId(), invoice.getBalance(), invoice.getInvoiceDate(),
account.getCurrency(), callContext);
- } catch (InvoiceApiException e) {
+ } catch (final InvoiceApiException e) {
fail(e.toString());
}
return null;
@@ -582,7 +580,7 @@ public class TestIntegrationBase extends BeatrixTestSuiteWithEmbeddedDB {
try {
invoiceUserApi.insertInvoiceItemAdjustment(account.getId(), invoice.getId(), invoice.getInvoiceItems().get(itemNb - 1).getId(),
invoice.getInvoiceDate(), callContext);
- } catch (InvoiceApiException e) {
+ } catch (final InvoiceApiException e) {
fail(e.toString());
}
return null;
@@ -605,8 +603,8 @@ public class TestIntegrationBase extends BeatrixTestSuiteWithEmbeddedDB {
assertListenerStatus();
}
- private <T> T doCallAndCheckForCompletion(Function<Void, T> f, final NextEvent... events) {
- Joiner joiner = Joiner.on(", ");
+ private <T> T doCallAndCheckForCompletion(final Function<Void, T> f, final NextEvent... events) {
+ final Joiner joiner = Joiner.on(", ");
log.debug(" ************ STARTING BUS HANDLER CHECK : {} ********************", joiner.join(events));
busHandler.pushExpectedEvents(events);
diff --git a/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/PaymentMethodJson.java b/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/PaymentMethodJson.java
index cd681b6..f78fe38 100644
--- a/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/PaymentMethodJson.java
+++ b/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/PaymentMethodJson.java
@@ -1,7 +1,9 @@
/*
* Copyright 2010-2013 Ning, Inc.
+ * Copyright 2014 Groupon, Inc
+ * Copyright 2014 The Billing Project, LLC
*
- * Ning licenses this file to you under the Apache License, version 2.0
+ * The Billing Project licenses this file to you under the Apache License, version 2.0
* (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
*
@@ -24,11 +26,10 @@ import java.util.UUID;
import javax.annotation.Nullable;
import org.joda.time.DateTime;
-
import org.killbill.billing.account.api.Account;
import org.killbill.billing.payment.api.PaymentMethod;
-import org.killbill.billing.payment.api.PaymentMethodKVInfo;
import org.killbill.billing.payment.api.PaymentMethodPlugin;
+import org.killbill.billing.payment.api.PluginProperty;
import org.killbill.billing.util.audit.AccountAuditLogs;
import com.fasterxml.jackson.annotation.JsonCreator;
@@ -66,9 +67,9 @@ public class PaymentMethodJson extends JsonBase {
if (pluginDetail != null) {
List<PaymentMethodProperties> properties = null;
if (pluginDetail.getProperties() != null) {
- properties = new ArrayList<PaymentMethodJson.PaymentMethodProperties>(Collections2.transform(pluginDetail.getProperties(), new Function<PaymentMethodKVInfo, PaymentMethodProperties>() {
+ properties = new ArrayList<PaymentMethodJson.PaymentMethodProperties>(Collections2.transform(pluginDetail.getProperties(), new Function<PluginProperty, PaymentMethodProperties>() {
@Override
- public PaymentMethodProperties apply(final PaymentMethodKVInfo input) {
+ public PaymentMethodProperties apply(final PluginProperty input) {
return new PaymentMethodProperties(input.getKey(), input.getValue() == null ? null : input.getValue().toString(), input.getIsUpdatable());
}
}));
@@ -217,11 +218,11 @@ public class PaymentMethodJson extends JsonBase {
}
@Override
- public List<PaymentMethodKVInfo> getProperties() {
+ public List<PluginProperty> getProperties() {
if (pluginInfo.getProperties() != null) {
- final List<PaymentMethodKVInfo> result = new LinkedList<PaymentMethodKVInfo>();
+ final List<PluginProperty> result = new LinkedList<PluginProperty>();
for (final PaymentMethodProperties cur : pluginInfo.getProperties()) {
- result.add(new PaymentMethodKVInfo(cur.getKey(), cur.getValue(), cur.isUpdatable));
+ result.add(new PluginProperty(cur.getKey(), cur.getValue(), cur.isUpdatable));
}
return result;
}
diff --git a/osgi-bundles/bundles/jruby/src/main/java/org/killbill/billing/osgi/bundles/jruby/JRubyPaymentPlugin.java b/osgi-bundles/bundles/jruby/src/main/java/org/killbill/billing/osgi/bundles/jruby/JRubyPaymentPlugin.java
index 01f13e7..daaaba9 100644
--- a/osgi-bundles/bundles/jruby/src/main/java/org/killbill/billing/osgi/bundles/jruby/JRubyPaymentPlugin.java
+++ b/osgi-bundles/bundles/jruby/src/main/java/org/killbill/billing/osgi/bundles/jruby/JRubyPaymentPlugin.java
@@ -1,7 +1,9 @@
/*
* Copyright 2010-2013 Ning, Inc.
+ * Copyright 2014 Groupon, Inc
+ * Copyright 2014 The Billing Project, LLC
*
- * Ning licenses this file to you under the Apache License, version 2.0
+ * The Billing Project licenses this file to you under the Apache License, version 2.0
* (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
*
@@ -23,17 +25,14 @@ import java.util.List;
import java.util.UUID;
import org.jruby.Ruby;
-import org.killbill.billing.payment.plugin.api.HostedPaymentPageDescriptorFields;
-import org.killbill.billing.payment.plugin.api.HostedPaymentPageFormDescriptor;
-import org.killbill.billing.payment.plugin.api.HostedPaymentPageNotification;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceRegistration;
-import org.osgi.service.log.LogService;
-
import org.killbill.billing.catalog.api.Currency;
import org.killbill.billing.osgi.api.OSGIPluginProperties;
import org.killbill.billing.osgi.api.config.PluginRubyConfig;
import org.killbill.billing.payment.api.PaymentMethodPlugin;
+import org.killbill.billing.payment.api.PluginProperty;
+import org.killbill.billing.payment.plugin.api.HostedPaymentPageDescriptorFields;
+import org.killbill.billing.payment.plugin.api.HostedPaymentPageFormDescriptor;
+import org.killbill.billing.payment.plugin.api.HostedPaymentPageNotification;
import org.killbill.billing.payment.plugin.api.PaymentInfoPlugin;
import org.killbill.billing.payment.plugin.api.PaymentMethodInfoPlugin;
import org.killbill.billing.payment.plugin.api.PaymentPluginApi;
@@ -42,6 +41,9 @@ import org.killbill.billing.payment.plugin.api.RefundInfoPlugin;
import org.killbill.billing.util.callcontext.CallContext;
import org.killbill.billing.util.callcontext.TenantContext;
import org.killbill.billing.util.entity.Pagination;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.log.LogService;
public class JRubyPaymentPlugin extends JRubyPlugin implements PaymentPluginApi {
@@ -72,170 +74,170 @@ public class JRubyPaymentPlugin extends JRubyPlugin implements PaymentPluginApi
// STEPH_DP
@Override
- public PaymentInfoPlugin authorizePayment(final UUID uuid, final UUID uuid2, final UUID uuid3, final BigDecimal bigDecimal, final Currency currency, final CallContext callContext) throws PaymentPluginApiException {
+ public PaymentInfoPlugin authorizePayment(final UUID kbAccountId, final UUID kbPaymentId, final UUID kbPaymentMethodId, final BigDecimal bigDecimal, final Currency currency, final Iterable<PluginProperty> properties, final CallContext callContext) throws PaymentPluginApiException {
return null;
}
@Override
- public PaymentInfoPlugin capturePayment(final UUID uuid, final UUID uuid2, final UUID uuid3, final BigDecimal bigDecimal, final Currency currency, final CallContext callContext) throws PaymentPluginApiException {
+ public PaymentInfoPlugin capturePayment(final UUID kbAccountId, final UUID kbPaymentId, final UUID kbPaymentMethodId, final BigDecimal bigDecimal, final Currency currency, final Iterable<PluginProperty> properties, final CallContext callContext) throws PaymentPluginApiException {
return null;
}
@Override
- public PaymentInfoPlugin processPayment(final UUID kbAccountId, final UUID kbPaymentId, final UUID kbPaymentMethodId, final BigDecimal amount, final Currency currency, final CallContext context) throws PaymentPluginApiException {
+ public PaymentInfoPlugin processPayment(final UUID kbAccountId, final UUID kbPaymentId, final UUID kbPaymentMethodId, final BigDecimal amount, final Currency currency, final Iterable<PluginProperty> properties, final CallContext context) throws PaymentPluginApiException {
return callWithRuntimeAndChecking(new PluginCallback(VALIDATION_PLUGIN_TYPE.PAYMENT) {
@Override
public PaymentInfoPlugin doCall(final Ruby runtime) throws PaymentPluginApiException {
- return ((PaymentPluginApi) pluginInstance).processPayment(kbAccountId, kbPaymentId, kbPaymentMethodId, amount, currency, context);
+ return ((PaymentPluginApi) pluginInstance).processPayment(kbAccountId, kbPaymentId, kbPaymentMethodId, amount, currency, properties, context);
}
});
}
@Override
- public PaymentInfoPlugin voidPayment(final UUID uuid, final UUID uuid2, final UUID uuid3, final CallContext callContext) throws PaymentPluginApiException {
+ public PaymentInfoPlugin voidPayment(final UUID kbAccountId, final UUID kbPaymentId, final UUID kbPaymentMethodId, final Iterable<PluginProperty> properties, final CallContext callContext) throws PaymentPluginApiException {
return null;
}
@Override
- public PaymentInfoPlugin getPaymentInfo(final UUID kbAccountId, final UUID kbPaymentId, final TenantContext context) throws PaymentPluginApiException {
+ public PaymentInfoPlugin getPaymentInfo(final UUID kbAccountId, final UUID kbPaymentId, final Iterable<PluginProperty> properties, final TenantContext context) throws PaymentPluginApiException {
return callWithRuntimeAndChecking(new PluginCallback(VALIDATION_PLUGIN_TYPE.PAYMENT) {
@Override
public PaymentInfoPlugin doCall(final Ruby runtime) throws PaymentPluginApiException {
- return ((PaymentPluginApi) pluginInstance).getPaymentInfo(kbAccountId, kbPaymentId, context);
+ return ((PaymentPluginApi) pluginInstance).getPaymentInfo(kbAccountId, kbPaymentId, properties, context);
}
});
}
@Override
- public Pagination<PaymentInfoPlugin> searchPayments(final String searchKey, final Long offset, final Long limit, final TenantContext tenantContext) throws PaymentPluginApiException {
+ public Pagination<PaymentInfoPlugin> searchPayments(final String searchKey, final Long offset, final Long limit, final Iterable<PluginProperty> properties, final TenantContext tenantContext) throws PaymentPluginApiException {
return callWithRuntimeAndChecking(new PluginCallback(VALIDATION_PLUGIN_TYPE.PAYMENT) {
@Override
public Pagination<PaymentInfoPlugin> doCall(final Ruby runtime) throws PaymentPluginApiException {
- return ((PaymentPluginApi) pluginInstance).searchPayments(searchKey, offset, limit, tenantContext);
+ return ((PaymentPluginApi) pluginInstance).searchPayments(searchKey, offset, limit, properties, tenantContext);
}
});
}
@Override
- public RefundInfoPlugin processRefund(final UUID kbAccountId, final UUID kbPaymentId, final BigDecimal refundAmount, final Currency currency, final CallContext context) throws PaymentPluginApiException {
+ public RefundInfoPlugin processRefund(final UUID kbAccountId, final UUID kbPaymentId, final BigDecimal refundAmount, final Currency currency, final Iterable<PluginProperty> properties, final CallContext context) throws PaymentPluginApiException {
return callWithRuntimeAndChecking(new PluginCallback(VALIDATION_PLUGIN_TYPE.PAYMENT) {
@Override
public RefundInfoPlugin doCall(final Ruby runtime) throws PaymentPluginApiException {
- return ((PaymentPluginApi) pluginInstance).processRefund(kbAccountId, kbPaymentId, refundAmount, currency, context);
+ return ((PaymentPluginApi) pluginInstance).processRefund(kbAccountId, kbPaymentId, refundAmount, currency, properties, context);
}
});
}
@Override
- public List<RefundInfoPlugin> getRefundInfo(final UUID kbAccountId, final UUID kbPaymentId, final TenantContext context) throws PaymentPluginApiException {
+ public List<RefundInfoPlugin> getRefundInfo(final UUID kbAccountId, final UUID kbPaymentId, final Iterable<PluginProperty> properties, final TenantContext context) throws PaymentPluginApiException {
return callWithRuntimeAndChecking(new PluginCallback(VALIDATION_PLUGIN_TYPE.PAYMENT) {
@Override
public List<RefundInfoPlugin> doCall(final Ruby runtime) throws PaymentPluginApiException {
- return ((PaymentPluginApi) pluginInstance).getRefundInfo(kbAccountId, kbPaymentId, context);
+ return ((PaymentPluginApi) pluginInstance).getRefundInfo(kbAccountId, kbPaymentId, properties, context);
}
});
}
@Override
- public Pagination<RefundInfoPlugin> searchRefunds(final String searchKey, final Long offset, final Long limit, final TenantContext tenantContext) throws PaymentPluginApiException {
+ public Pagination<RefundInfoPlugin> searchRefunds(final String searchKey, final Long offset, final Long limit, final Iterable<PluginProperty> properties, final TenantContext tenantContext) throws PaymentPluginApiException {
return callWithRuntimeAndChecking(new PluginCallback(VALIDATION_PLUGIN_TYPE.PAYMENT) {
@Override
public Pagination<RefundInfoPlugin> doCall(final Ruby runtime) throws PaymentPluginApiException {
- return ((PaymentPluginApi) pluginInstance).searchRefunds(searchKey, offset, limit, tenantContext);
+ return ((PaymentPluginApi) pluginInstance).searchRefunds(searchKey, offset, limit, properties, tenantContext);
}
});
}
@Override
- public void addPaymentMethod(final UUID kbAccountId, final UUID kbPaymentMethodId, final PaymentMethodPlugin paymentMethodProps, final boolean setDefault, final CallContext context) throws PaymentPluginApiException {
+ public void addPaymentMethod(final UUID kbAccountId, final UUID kbPaymentMethodId, final PaymentMethodPlugin paymentMethodProps, final boolean setDefault, final Iterable<PluginProperty> properties, final CallContext context) throws PaymentPluginApiException {
callWithRuntimeAndChecking(new PluginCallback(VALIDATION_PLUGIN_TYPE.PAYMENT) {
@Override
public Void doCall(final Ruby runtime) throws PaymentPluginApiException {
- ((PaymentPluginApi) pluginInstance).addPaymentMethod(kbAccountId, kbPaymentMethodId, paymentMethodProps, Boolean.valueOf(setDefault), context);
+ ((PaymentPluginApi) pluginInstance).addPaymentMethod(kbAccountId, kbPaymentMethodId, paymentMethodProps, Boolean.valueOf(setDefault), properties, context);
return null;
}
});
}
@Override
- public void deletePaymentMethod(final UUID kbAccountId, final UUID kbPaymentMethodId, final CallContext context) throws PaymentPluginApiException {
+ public void deletePaymentMethod(final UUID kbAccountId, final UUID kbPaymentMethodId, final Iterable<PluginProperty> properties, final CallContext context) throws PaymentPluginApiException {
callWithRuntimeAndChecking(new PluginCallback(VALIDATION_PLUGIN_TYPE.PAYMENT) {
@Override
public Void doCall(final Ruby runtime) throws PaymentPluginApiException {
- ((PaymentPluginApi) pluginInstance).deletePaymentMethod(kbAccountId, kbPaymentMethodId, context);
+ ((PaymentPluginApi) pluginInstance).deletePaymentMethod(kbAccountId, kbPaymentMethodId, properties, context);
return null;
}
});
}
@Override
- public PaymentMethodPlugin getPaymentMethodDetail(final UUID kbAccountId, final UUID kbPaymentMethodId, final TenantContext context) throws PaymentPluginApiException {
+ public PaymentMethodPlugin getPaymentMethodDetail(final UUID kbAccountId, final UUID kbPaymentMethodId, final Iterable<PluginProperty> properties, final TenantContext context) throws PaymentPluginApiException {
return callWithRuntimeAndChecking(new PluginCallback(VALIDATION_PLUGIN_TYPE.PAYMENT) {
@Override
public PaymentMethodPlugin doCall(final Ruby runtime) throws PaymentPluginApiException {
- return ((PaymentPluginApi) pluginInstance).getPaymentMethodDetail(kbAccountId, kbPaymentMethodId, context);
+ return ((PaymentPluginApi) pluginInstance).getPaymentMethodDetail(kbAccountId, kbPaymentMethodId, properties, context);
}
});
}
@Override
- public void setDefaultPaymentMethod(final UUID kbAccountId, final UUID kbPaymentMethodId, final CallContext context) throws PaymentPluginApiException {
+ public void setDefaultPaymentMethod(final UUID kbAccountId, final UUID kbPaymentMethodId, final Iterable<PluginProperty> properties, final CallContext context) throws PaymentPluginApiException {
callWithRuntimeAndChecking(new PluginCallback(VALIDATION_PLUGIN_TYPE.PAYMENT) {
@Override
public Void doCall(final Ruby runtime) throws PaymentPluginApiException {
- ((PaymentPluginApi) pluginInstance).setDefaultPaymentMethod(kbAccountId, kbPaymentMethodId, context);
+ ((PaymentPluginApi) pluginInstance).setDefaultPaymentMethod(kbAccountId, kbPaymentMethodId, properties, context);
return null;
}
});
}
@Override
- public List<PaymentMethodInfoPlugin> getPaymentMethods(final UUID kbAccountId, final boolean refreshFromGateway, final CallContext context) throws PaymentPluginApiException {
+ public List<PaymentMethodInfoPlugin> getPaymentMethods(final UUID kbAccountId, final boolean refreshFromGateway, final Iterable<PluginProperty> properties, final CallContext context) throws PaymentPluginApiException {
return callWithRuntimeAndChecking(new PluginCallback(VALIDATION_PLUGIN_TYPE.PAYMENT) {
@Override
public List<PaymentMethodInfoPlugin> doCall(final Ruby runtime) throws PaymentPluginApiException {
- return ((PaymentPluginApi) pluginInstance).getPaymentMethods(kbAccountId, Boolean.valueOf(refreshFromGateway), context);
+ return ((PaymentPluginApi) pluginInstance).getPaymentMethods(kbAccountId, Boolean.valueOf(refreshFromGateway), properties, context);
}
});
}
@Override
- public Pagination<PaymentMethodPlugin> searchPaymentMethods(final String searchKey, final Long offset, final Long limit, final TenantContext tenantContext) throws PaymentPluginApiException {
+ public Pagination<PaymentMethodPlugin> searchPaymentMethods(final String searchKey, final Long offset, final Long limit, final Iterable<PluginProperty> properties, final TenantContext tenantContext) throws PaymentPluginApiException {
return callWithRuntimeAndChecking(new PluginCallback(VALIDATION_PLUGIN_TYPE.PAYMENT) {
@Override
public Pagination<PaymentMethodPlugin> doCall(final Ruby runtime) throws PaymentPluginApiException {
- return ((PaymentPluginApi) pluginInstance).searchPaymentMethods(searchKey, offset, limit, tenantContext);
+ return ((PaymentPluginApi) pluginInstance).searchPaymentMethods(searchKey, offset, limit, properties, tenantContext);
}
});
}
@Override
- public void resetPaymentMethods(final UUID kbAccountId, final List<PaymentMethodInfoPlugin> paymentMethods) throws PaymentPluginApiException {
+ public void resetPaymentMethods(final UUID kbAccountId, final List<PaymentMethodInfoPlugin> paymentMethods, final Iterable<PluginProperty> properties) throws PaymentPluginApiException {
callWithRuntimeAndChecking(new PluginCallback(VALIDATION_PLUGIN_TYPE.PAYMENT) {
@Override
public Void doCall(final Ruby runtime) throws PaymentPluginApiException {
- ((PaymentPluginApi) pluginInstance).resetPaymentMethods(kbAccountId, paymentMethods);
+ ((PaymentPluginApi) pluginInstance).resetPaymentMethods(kbAccountId, paymentMethods, properties);
return null;
}
});
}
@Override
- public HostedPaymentPageFormDescriptor buildFormDescriptor(final UUID uuid, final HostedPaymentPageDescriptorFields hostedPaymentPageDescriptorFields, final TenantContext tenantContext) {
+ public HostedPaymentPageFormDescriptor buildFormDescriptor(final UUID kbAccountId, final HostedPaymentPageDescriptorFields hostedPaymentPageDescriptorFields, final Iterable<PluginProperty> properties, final TenantContext tenantContext) {
return null;
}
@Override
- public HostedPaymentPageNotification processNotification(final String s, final TenantContext tenantContext) throws PaymentPluginApiException {
+ public HostedPaymentPageNotification processNotification(final String notification, final Iterable<PluginProperty> properties, final TenantContext tenantContext) throws PaymentPluginApiException {
return null;
}
}
diff --git a/osgi-bundles/tests/beatrix/src/test/java/org/killbill/billing/osgi/bundles/test/TestPaymentPluginApi.java b/osgi-bundles/tests/beatrix/src/test/java/org/killbill/billing/osgi/bundles/test/TestPaymentPluginApi.java
index 6e7947b..fec09e0 100644
--- a/osgi-bundles/tests/beatrix/src/test/java/org/killbill/billing/osgi/bundles/test/TestPaymentPluginApi.java
+++ b/osgi-bundles/tests/beatrix/src/test/java/org/killbill/billing/osgi/bundles/test/TestPaymentPluginApi.java
@@ -1,7 +1,9 @@
/*
* Copyright 2010-2013 Ning, Inc.
+ * Copyright 2014 Groupon, Inc
+ * Copyright 2014 The Billing Project, LLC
*
- * Ning licenses this file to you under the Apache License, version 2.0
+ * The Billing Project licenses this file to you under the Apache License, version 2.0
* (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
*
@@ -19,14 +21,15 @@ package org.killbill.billing.osgi.bundles.test;
import java.math.BigDecimal;
import java.util.Collections;
import java.util.Iterator;
+import java.util.LinkedList;
import java.util.List;
import java.util.UUID;
import org.joda.time.DateTime;
-
import org.killbill.billing.catalog.api.Currency;
import org.killbill.billing.osgi.bundles.test.dao.TestDao;
import org.killbill.billing.payment.api.PaymentMethodPlugin;
+import org.killbill.billing.payment.api.PluginProperty;
import org.killbill.billing.payment.plugin.api.HostedPaymentPageDescriptorFields;
import org.killbill.billing.payment.plugin.api.HostedPaymentPageFormDescriptor;
import org.killbill.billing.payment.plugin.api.HostedPaymentPageNotification;
@@ -51,17 +54,17 @@ public class TestPaymentPluginApi implements PaymentPluginApi {
}
@Override
- public PaymentInfoPlugin authorizePayment(final UUID uuid, final UUID uuid2, final UUID uuid3, final BigDecimal bigDecimal, final Currency currency, final CallContext callContext) throws PaymentPluginApiException {
+ public PaymentInfoPlugin authorizePayment(final UUID kbAccountId, final UUID kbPaymentId, final UUID kbPaymentMethodId, final BigDecimal bigDecimal, final Currency currency, final Iterable<PluginProperty> properties, final CallContext callContext) throws PaymentPluginApiException {
return null;
}
@Override
- public PaymentInfoPlugin capturePayment(final UUID uuid, final UUID uuid2, final UUID uuid3, final BigDecimal bigDecimal, final Currency currency, final CallContext callContext) throws PaymentPluginApiException {
+ public PaymentInfoPlugin capturePayment(final UUID kbAccountId, final UUID kbPaymentId, final UUID kbPaymentMethodId, final BigDecimal bigDecimal, final Currency currency, final Iterable<PluginProperty> properties, final CallContext callContext) throws PaymentPluginApiException {
return null;
}
@Override
- public PaymentInfoPlugin processPayment(final UUID kbAccountId, final UUID kbPaymentId, final UUID kbPaymentMethodId, final BigDecimal amount, final Currency currency, final CallContext context) throws PaymentPluginApiException {
+ public PaymentInfoPlugin processPayment(final UUID kbAccountId, final UUID kbPaymentId, final UUID kbPaymentMethodId, final BigDecimal amount, final Currency currency, final Iterable<PluginProperty> properties, final CallContext context) throws PaymentPluginApiException {
testDao.insertProcessedPayment(kbPaymentId, kbPaymentMethodId, amount);
return new PaymentInfoPlugin() {
@Override
@@ -113,21 +116,26 @@ public class TestPaymentPluginApi implements PaymentPluginApi {
public String getSecondPaymentReferenceId() {
return null;
}
+
+ @Override
+ public List<PluginProperty> getProperties() {
+ return new LinkedList<PluginProperty>();
+ }
};
}
@Override
- public PaymentInfoPlugin voidPayment(final UUID uuid, final UUID uuid2, final UUID uuid3, final CallContext callContext) throws PaymentPluginApiException {
+ public PaymentInfoPlugin voidPayment(final UUID kbAccountId, final UUID kbPaymentId, final UUID kbPaymentMethodId, final Iterable<PluginProperty> properties, final CallContext callContext) throws PaymentPluginApiException {
return null;
}
@Override
- public PaymentInfoPlugin getPaymentInfo(final UUID kbAccountId, final UUID kbPaymentId, final TenantContext context) throws PaymentPluginApiException {
+ public PaymentInfoPlugin getPaymentInfo(final UUID kbAccountId, final UUID kbPaymentId, final Iterable<PluginProperty> properties, final TenantContext context) throws PaymentPluginApiException {
return null;
}
@Override
- public Pagination<PaymentInfoPlugin> searchPayments(final String searchKey, final Long offset, final Long limit, final TenantContext tenantContext) throws PaymentPluginApiException {
+ public Pagination<PaymentInfoPlugin> searchPayments(final String searchKey, final Long offset, final Long limit, final Iterable<PluginProperty> properties, final TenantContext tenantContext) throws PaymentPluginApiException {
return new Pagination<PaymentInfoPlugin>() {
@Override
public Long getCurrentOffset() {
@@ -157,17 +165,17 @@ public class TestPaymentPluginApi implements PaymentPluginApi {
}
@Override
- public RefundInfoPlugin processRefund(final UUID kbAccountId, final UUID kbPaymentId, final BigDecimal refundAmount, final Currency currency, final CallContext context) throws PaymentPluginApiException {
+ public RefundInfoPlugin processRefund(final UUID kbAccountId, final UUID kbPaymentId, final BigDecimal refundAmount, final Currency currency, final Iterable<PluginProperty> properties, final CallContext context) throws PaymentPluginApiException {
return null;
}
@Override
- public List<RefundInfoPlugin> getRefundInfo(final UUID kbAccountId, final UUID kbPaymentId, final TenantContext context) {
+ public List<RefundInfoPlugin> getRefundInfo(final UUID kbAccountId, final UUID kbPaymentId, final Iterable<PluginProperty> properties, final TenantContext context) {
return Collections.<RefundInfoPlugin>emptyList();
}
@Override
- public Pagination<RefundInfoPlugin> searchRefunds(final String searchKey, final Long offset, final Long limit, final TenantContext tenantContext) throws PaymentPluginApiException {
+ public Pagination<RefundInfoPlugin> searchRefunds(final String searchKey, final Long offset, final Long limit, final Iterable<PluginProperty> properties, final TenantContext tenantContext) throws PaymentPluginApiException {
return new Pagination<RefundInfoPlugin>() {
@Override
public Long getCurrentOffset() {
@@ -197,29 +205,29 @@ public class TestPaymentPluginApi implements PaymentPluginApi {
}
@Override
- public void addPaymentMethod(final UUID kbAccountId, final UUID kbPaymentMethodId, final PaymentMethodPlugin paymentMethodProps, final boolean setDefault, final CallContext context) throws PaymentPluginApiException {
+ public void addPaymentMethod(final UUID kbAccountId, final UUID kbPaymentMethodId, final PaymentMethodPlugin paymentMethodProps, final boolean setDefault, final Iterable<PluginProperty> properties, final CallContext context) throws PaymentPluginApiException {
}
@Override
- public void deletePaymentMethod(final UUID kbAccountId, final UUID kbPaymentMethodId, final CallContext context) throws PaymentPluginApiException {
+ public void deletePaymentMethod(final UUID kbAccountId, final UUID kbPaymentMethodId, final Iterable<PluginProperty> properties, final CallContext context) throws PaymentPluginApiException {
}
@Override
- public PaymentMethodPlugin getPaymentMethodDetail(final UUID kbAccountId, final UUID kbPaymentMethodId, final TenantContext context) throws PaymentPluginApiException {
+ public PaymentMethodPlugin getPaymentMethodDetail(final UUID kbAccountId, final UUID kbPaymentMethodId, final Iterable<PluginProperty> properties, final TenantContext context) throws PaymentPluginApiException {
return null;
}
@Override
- public void setDefaultPaymentMethod(final UUID kbAccountId, final UUID kbPaymentMethodId, final CallContext context) throws PaymentPluginApiException {
+ public void setDefaultPaymentMethod(final UUID kbAccountId, final UUID kbPaymentMethodId, final Iterable<PluginProperty> properties, final CallContext context) throws PaymentPluginApiException {
}
@Override
- public List<PaymentMethodInfoPlugin> getPaymentMethods(final UUID kbAccountId, final boolean refreshFromGateway, final CallContext context) throws PaymentPluginApiException {
+ public List<PaymentMethodInfoPlugin> getPaymentMethods(final UUID kbAccountId, final boolean refreshFromGateway, final Iterable<PluginProperty> properties, final CallContext context) throws PaymentPluginApiException {
return Collections.emptyList();
}
@Override
- public Pagination<PaymentMethodPlugin> searchPaymentMethods(final String searchKey, final Long offset, final Long limit, final TenantContext tenantContext) throws PaymentPluginApiException {
+ public Pagination<PaymentMethodPlugin> searchPaymentMethods(final String searchKey, final Long offset, final Long limit, final Iterable<PluginProperty> properties, final TenantContext tenantContext) throws PaymentPluginApiException {
return new Pagination<PaymentMethodPlugin>() {
@Override
public Long getCurrentOffset() {
@@ -249,16 +257,16 @@ public class TestPaymentPluginApi implements PaymentPluginApi {
}
@Override
- public void resetPaymentMethods(final UUID kbAccountId, final List<PaymentMethodInfoPlugin> paymentMethods) throws PaymentPluginApiException {
+ public void resetPaymentMethods(final UUID kbAccountId, final List<PaymentMethodInfoPlugin> paymentMethods, final Iterable<PluginProperty> properties) throws PaymentPluginApiException {
}
@Override
- public HostedPaymentPageFormDescriptor buildFormDescriptor(final UUID uuid, final HostedPaymentPageDescriptorFields hostedPaymentPageDescriptorFields, final TenantContext tenantContext) {
+ public HostedPaymentPageFormDescriptor buildFormDescriptor(final UUID kbAccountId, final HostedPaymentPageDescriptorFields hostedPaymentPageDescriptorFields, final Iterable<PluginProperty> properties, final TenantContext tenantContext) {
return null;
}
@Override
- public HostedPaymentPageNotification processNotification(final String s, final TenantContext tenantContext) throws PaymentPluginApiException {
+ public HostedPaymentPageNotification processNotification(final String notification, final Iterable<PluginProperty> properties, final TenantContext tenantContext) throws PaymentPluginApiException {
return null;
}
}
diff --git a/osgi-bundles/tests/payment/src/test/java/org/killbill/billing/osgi/bundles/test/TestPaymentPluginApi.java b/osgi-bundles/tests/payment/src/test/java/org/killbill/billing/osgi/bundles/test/TestPaymentPluginApi.java
index 46d5685..5d391cf 100644
--- a/osgi-bundles/tests/payment/src/test/java/org/killbill/billing/osgi/bundles/test/TestPaymentPluginApi.java
+++ b/osgi-bundles/tests/payment/src/test/java/org/killbill/billing/osgi/bundles/test/TestPaymentPluginApi.java
@@ -1,7 +1,9 @@
/*
* Copyright 2010-2013 Ning, Inc.
+ * Copyright 2014 Groupon, Inc
+ * Copyright 2014 The Billing Project, LLC
*
- * Ning licenses this file to you under the Apache License, version 2.0
+ * The Billing Project licenses this file to you under the Apache License, version 2.0
* (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
*
@@ -23,9 +25,9 @@ import java.util.List;
import java.util.UUID;
import org.joda.time.DateTime;
-
import org.killbill.billing.catalog.api.Currency;
import org.killbill.billing.payment.api.PaymentMethodPlugin;
+import org.killbill.billing.payment.api.PluginProperty;
import org.killbill.billing.payment.plugin.api.HostedPaymentPageDescriptorFields;
import org.killbill.billing.payment.plugin.api.HostedPaymentPageFormDescriptor;
import org.killbill.billing.payment.plugin.api.HostedPaymentPageNotification;
@@ -40,6 +42,8 @@ import org.killbill.billing.util.callcontext.CallContext;
import org.killbill.billing.util.callcontext.TenantContext;
import org.killbill.billing.util.entity.Pagination;
+import com.google.common.collect.ImmutableList;
+
public class TestPaymentPluginApi implements PaymentPluginApiWithTestControl {
private final String name;
@@ -53,19 +57,19 @@ public class TestPaymentPluginApi implements PaymentPluginApiWithTestControl {
}
@Override
- public PaymentInfoPlugin authorizePayment(UUID kbAccountId, UUID kbPaymentId, UUID kbPaymentMethodId, BigDecimal amount, Currency currency, CallContext context)
+ public PaymentInfoPlugin authorizePayment(final UUID kbAccountId, final UUID kbPaymentId, final UUID kbPaymentMethodId, final BigDecimal amount, final Currency currency, final Iterable<PluginProperty> properties, final CallContext context)
throws PaymentPluginApiException {
return getPaymentInfoPluginResult(kbPaymentId, amount, currency);
}
@Override
- public PaymentInfoPlugin capturePayment(UUID kbAccountId, UUID kbPaymentId, UUID kbPaymentMethodId, BigDecimal amount, Currency currency, CallContext context)
+ public PaymentInfoPlugin capturePayment(final UUID kbAccountId, final UUID kbPaymentId, final UUID kbPaymentMethodId, final BigDecimal amount, final Currency currency, final Iterable<PluginProperty> properties, final CallContext context)
throws PaymentPluginApiException {
return getPaymentInfoPluginResult(kbPaymentId, amount, currency);
}
@Override
- public PaymentInfoPlugin processPayment(final UUID accountId, final UUID kbPaymentId, final UUID kbPaymentMethodId, final BigDecimal amount, final Currency currency, final CallContext context) throws PaymentPluginApiException {
+ public PaymentInfoPlugin processPayment(final UUID accountId, final UUID kbPaymentId, final UUID kbPaymentMethodId, final BigDecimal amount, final Currency currency, final Iterable<PluginProperty> properties, final CallContext context) throws PaymentPluginApiException {
return getPaymentInfoPluginResult(kbPaymentId, amount, currency);
}
@@ -120,25 +124,30 @@ public class TestPaymentPluginApi implements PaymentPluginApiWithTestControl {
public String getSecondPaymentReferenceId() {
return null;
}
+
+ @Override
+ public List<PluginProperty> getProperties() {
+ return ImmutableList.<PluginProperty>of();
+ }
});
}
@Override
- public PaymentInfoPlugin voidPayment(UUID kbAccountId, UUID kbPaymentId, UUID kbPaymentMethodId, CallContext context)
+ public PaymentInfoPlugin voidPayment(final UUID kbAccountId, final UUID kbPaymentId, final UUID kbPaymentMethodId, final Iterable<PluginProperty> properties, final CallContext context)
throws PaymentPluginApiException {
return getPaymentInfoPluginResult(kbPaymentId, BigDecimal.ZERO, null);
}
@Override
- public PaymentInfoPlugin getPaymentInfo(final UUID accountId, final UUID kbPaymentId, final TenantContext context) throws PaymentPluginApiException {
+ public PaymentInfoPlugin getPaymentInfo(final UUID accountId, final UUID kbPaymentId, final Iterable<PluginProperty> properties, final TenantContext context) throws PaymentPluginApiException {
final BigDecimal someAmount = new BigDecimal("12.45");
return getPaymentInfoPluginResult(kbPaymentId, someAmount, null);
}
@Override
- public Pagination<PaymentInfoPlugin> searchPayments(final String searchKey, final Long offset, final Long limit, final TenantContext tenantContext) throws PaymentPluginApiException {
+ public Pagination<PaymentInfoPlugin> searchPayments(final String searchKey, final Long offset, final Long limit, final Iterable<PluginProperty> properties, final TenantContext tenantContext) throws PaymentPluginApiException {
return new Pagination<PaymentInfoPlugin>() {
@Override
public Long getCurrentOffset() {
@@ -168,7 +177,7 @@ public class TestPaymentPluginApi implements PaymentPluginApiWithTestControl {
}
@Override
- public RefundInfoPlugin processRefund(final UUID accountId, final UUID kbPaymentId, final BigDecimal refundAmount, final Currency currency, final CallContext context) throws PaymentPluginApiException {
+ public RefundInfoPlugin processRefund(final UUID accountId, final UUID kbPaymentId, final BigDecimal refundAmount, final Currency currency, final Iterable<PluginProperty> properties, final CallContext context) throws PaymentPluginApiException {
return withRuntimeCheckForExceptions(new RefundInfoPlugin() {
@Override
public UUID getKbPaymentId() {
@@ -219,16 +228,21 @@ public class TestPaymentPluginApi implements PaymentPluginApiWithTestControl {
public String getSecondRefundReferenceId() {
return null;
}
+
+ @Override
+ public List<PluginProperty> getProperties() {
+ return ImmutableList.<PluginProperty>of();
+ }
});
}
@Override
- public List<RefundInfoPlugin> getRefundInfo(final UUID kbAccountId, final UUID kbPaymentId, final TenantContext context) {
+ public List<RefundInfoPlugin> getRefundInfo(final UUID kbAccountId, final UUID kbPaymentId, final Iterable<PluginProperty> properties, final TenantContext context) {
return Collections.<RefundInfoPlugin>emptyList();
}
@Override
- public Pagination<RefundInfoPlugin> searchRefunds(final String searchKey, final Long offset, final Long limit, final TenantContext tenantContext) throws PaymentPluginApiException {
+ public Pagination<RefundInfoPlugin> searchRefunds(final String searchKey, final Long offset, final Long limit, final Iterable<PluginProperty> properties, final TenantContext tenantContext) throws PaymentPluginApiException {
return new Pagination<RefundInfoPlugin>() {
@Override
public Long getCurrentOffset() {
@@ -258,29 +272,29 @@ public class TestPaymentPluginApi implements PaymentPluginApiWithTestControl {
}
@Override
- public void addPaymentMethod(final UUID kbAccountId, final UUID kbPaymentMethodId, final PaymentMethodPlugin paymentMethodProps, final boolean setDefault, final CallContext context) throws PaymentPluginApiException {
+ public void addPaymentMethod(final UUID kbAccountId, final UUID kbPaymentMethodId, final PaymentMethodPlugin paymentMethodProps, final boolean setDefault, final Iterable<PluginProperty> properties, final CallContext context) throws PaymentPluginApiException {
}
@Override
- public void deletePaymentMethod(final UUID accountId, final UUID kbPaymentMethodId, final CallContext context) throws PaymentPluginApiException {
+ public void deletePaymentMethod(final UUID accountId, final UUID kbPaymentMethodId, final Iterable<PluginProperty> properties, final CallContext context) throws PaymentPluginApiException {
}
@Override
- public PaymentMethodPlugin getPaymentMethodDetail(final UUID kbAccountId, final UUID kbPaymentMethodId, final TenantContext context) throws PaymentPluginApiException {
+ public PaymentMethodPlugin getPaymentMethodDetail(final UUID kbAccountId, final UUID kbPaymentMethodId, final Iterable<PluginProperty> properties, final TenantContext context) throws PaymentPluginApiException {
return null;
}
@Override
- public void setDefaultPaymentMethod(final UUID accountId, final UUID kbPaymentMethodId, final CallContext context) throws PaymentPluginApiException {
+ public void setDefaultPaymentMethod(final UUID accountId, final UUID kbPaymentMethodId, final Iterable<PluginProperty> properties, final CallContext context) throws PaymentPluginApiException {
}
@Override
- public List<PaymentMethodInfoPlugin> getPaymentMethods(final UUID kbAccountId, final boolean refreshFromGateway, final CallContext context) throws PaymentPluginApiException {
+ public List<PaymentMethodInfoPlugin> getPaymentMethods(final UUID kbAccountId, final boolean refreshFromGateway, final Iterable<PluginProperty> properties, final CallContext context) throws PaymentPluginApiException {
return Collections.emptyList();
}
@Override
- public Pagination<PaymentMethodPlugin> searchPaymentMethods(final String searchKey, final Long offset, final Long limit, final TenantContext tenantContext) throws PaymentPluginApiException {
+ public Pagination<PaymentMethodPlugin> searchPaymentMethods(final String searchKey, final Long offset, final Long limit, final Iterable<PluginProperty> properties, final TenantContext tenantContext) throws PaymentPluginApiException {
return new Pagination<PaymentMethodPlugin>() {
@Override
public Long getCurrentOffset() {
@@ -310,16 +324,16 @@ public class TestPaymentPluginApi implements PaymentPluginApiWithTestControl {
}
@Override
- public void resetPaymentMethods(final UUID accountId, final List<PaymentMethodInfoPlugin> paymentMethods) throws PaymentPluginApiException {
+ public void resetPaymentMethods(final UUID accountId, final List<PaymentMethodInfoPlugin> paymentMethods, final Iterable<PluginProperty> properties) throws PaymentPluginApiException {
}
@Override
- public HostedPaymentPageFormDescriptor buildFormDescriptor(final UUID uuid, final HostedPaymentPageDescriptorFields hostedPaymentPageDescriptorFields, final TenantContext tenantContext) {
+ public HostedPaymentPageFormDescriptor buildFormDescriptor(final UUID kbAccountId, final HostedPaymentPageDescriptorFields hostedPaymentPageDescriptorFields, final Iterable<PluginProperty> properties, final TenantContext tenantContext) {
return null;
}
@Override
- public HostedPaymentPageNotification processNotification(final String s, final TenantContext tenantContext) throws PaymentPluginApiException {
+ public HostedPaymentPageNotification processNotification(final String notification, final Iterable<PluginProperty> properties, final TenantContext tenantContext) throws PaymentPluginApiException {
return null;
}
diff --git a/payment/src/main/java/org/killbill/billing/payment/core/DirectPaymentProcessor.java b/payment/src/main/java/org/killbill/billing/payment/core/DirectPaymentProcessor.java
index 995635b..0d38183 100644
--- a/payment/src/main/java/org/killbill/billing/payment/core/DirectPaymentProcessor.java
+++ b/payment/src/main/java/org/killbill/billing/payment/core/DirectPaymentProcessor.java
@@ -1,7 +1,9 @@
/*
+ * Copyright 2010-2013 Ning, Inc.
* Copyright 2014 Groupon, Inc
+ * Copyright 2014 The Billing Project, LLC
*
- * Groupon licenses this file to you under the Apache License, version 2.0
+ * The Billing Project licenses this file to you under the Apache License, version 2.0
* (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
*
@@ -24,7 +26,6 @@ import java.util.UUID;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.TimeUnit;
-import javax.annotation.Nullable;
import javax.inject.Inject;
import org.joda.time.DateTime;
@@ -33,7 +34,6 @@ import org.killbill.billing.account.api.Account;
import org.killbill.billing.account.api.AccountInternalApi;
import org.killbill.billing.callcontext.InternalCallContext;
import org.killbill.billing.callcontext.InternalTenantContext;
-import org.killbill.billing.catalog.api.Currency;
import org.killbill.billing.invoice.api.InvoiceInternalApi;
import org.killbill.billing.osgi.api.OSGIServiceRegistration;
import org.killbill.billing.payment.api.DefaultDirectPayment;
@@ -43,6 +43,7 @@ import org.killbill.billing.payment.api.DirectPaymentTransaction;
import org.killbill.billing.payment.api.Payment;
import org.killbill.billing.payment.api.PaymentApiException;
import org.killbill.billing.payment.api.PaymentStatus;
+import org.killbill.billing.payment.api.PluginProperty;
import org.killbill.billing.payment.api.TransactionType;
import org.killbill.billing.payment.dao.DirectPaymentModelDao;
import org.killbill.billing.payment.dao.DirectPaymentTransactionModelDao;
@@ -109,11 +110,11 @@ public class DirectPaymentProcessor extends ProcessorBase {
final PaymentPluginApi plugin = getPaymentProviderPlugin(account, callContext);
- DateTime utcNow = clock.getUTCNow();
+ final DateTime utcNow = clock.getUTCNow();
final DirectPaymentModelDao pmd = new DirectPaymentModelDao(utcNow, utcNow, account.getId(), account.getPaymentMethodId(), externalKey);
final DirectPaymentTransactionModelDao ptmd = new DirectPaymentTransactionModelDao(utcNow, utcNow, pmd.getId(),
- TransactionType.AUTHORIZE, utcNow, PaymentStatus.UNKNOWN,
- amount, account.getCurrency(), null, null);
+ TransactionType.AUTHORIZE, utcNow, PaymentStatus.UNKNOWN,
+ amount, account.getCurrency(), null, null);
final DirectPaymentModelDao inserted = paymentDao.insertDirectPaymentWithFirstTransaction(pmd, ptmd, callContext);
final UUID tenantId = nonEntityDao.retrieveIdFromObject(callContext.getTenantRecordId(), ObjectType.TENANT);
@@ -122,10 +123,9 @@ public class DirectPaymentProcessor extends ProcessorBase {
PaymentInfoPlugin infoPlugin;
try {
-
try {
- infoPlugin = plugin.authorizePayment(account.getId(), pmd.getId(), ptmd.getId(), amount, account.getCurrency(), callContext.toCallContext(tenantId));
- } catch (RuntimeException e) {
+ infoPlugin = plugin.authorizePayment(account.getId(), pmd.getId(), ptmd.getId(), amount, account.getCurrency(), ImmutableList.<PluginProperty>of(), callContext.toCallContext(tenantId));
+ } catch (final RuntimeException e) {
// Handle case of plugin RuntimeException to be handled the same as a Plugin failure (PaymentPluginApiException)
final String formatError = String.format("Plugin threw RuntimeException for payment %s", pmd.getId());
throw new PaymentPluginApiException(formatError, e);
@@ -152,7 +152,7 @@ public class DirectPaymentProcessor extends ProcessorBase {
// This caught right below as a retryable Plugin failure
throw new PaymentPluginApiException("", formatError);
}
- } catch (PaymentPluginApiException e) {
+ } catch (final PaymentPluginApiException e) {
paymentStatus = PaymentStatus.PAYMENT_FAILURE_ABORTED;
infoPlugin = null;
paymentDao.updateDirectPaymentAndTransactionOnCompletion(pmd.getId(), paymentStatus, amount, account.getCurrency(),
@@ -160,11 +160,11 @@ public class DirectPaymentProcessor extends ProcessorBase {
} finally {
}
- DirectPaymentTransaction transaction = new DefaultDirectPaymentTransaction(ptmd.getId(), utcNow, utcNow, pmd.getId(), ptmd.getTransactionType(), utcNow, 0,
- paymentStatus, amount, account.getCurrency(),
- ((infoPlugin != null) ? infoPlugin.getGatewayErrorCode() : null),
- ((infoPlugin != null) ? infoPlugin.getGatewayError() : null),
- infoPlugin);
+ final DirectPaymentTransaction transaction = new DefaultDirectPaymentTransaction(ptmd.getId(), utcNow, utcNow, pmd.getId(), ptmd.getTransactionType(), utcNow, 0,
+ paymentStatus, amount, account.getCurrency(),
+ ((infoPlugin != null) ? infoPlugin.getGatewayErrorCode() : null),
+ ((infoPlugin != null) ? infoPlugin.getGatewayError() : null),
+ infoPlugin);
final List<DirectPaymentTransaction> transactions = Collections.singletonList(transaction);
final DirectPayment result = new DefaultDirectPayment(inserted.getId(), utcNow, utcNow, account.getId(), account.getPaymentMethodId(), inserted.getPaymentNumber(), externalKey, transactions);
return result;
@@ -205,8 +205,8 @@ public class DirectPaymentProcessor extends ProcessorBase {
public DirectPayment getPayment(final UUID directPaymentId, final boolean withPluginInfo, final InternalTenantContext tenantContext) throws PaymentApiException {
final DirectPaymentModelDao paymentModelDao = paymentDao.getDirectPayment(directPaymentId, tenantContext);
- final InternalTenantContext tenantContextWithAccountRecordId = internalCallContextFactory.createInternalTenantContext(paymentModelDao.getAccountId(), tenantContext);
- final List<DirectPaymentTransactionModelDao> transactionsForAccount = paymentDao.getDirectTransactionsForAccount(paymentModelDao.getAccountId(), tenantContextWithAccountRecordId);
+ final InternalTenantContext tenantContextWithAccountRecordId = internalCallContextFactory.createInternalTenantContext(paymentModelDao.getAccountId(), tenantContext);
+ final List<DirectPaymentTransactionModelDao> transactionsForAccount = paymentDao.getDirectTransactionsForAccount(paymentModelDao.getAccountId(), tenantContextWithAccountRecordId);
return toDirectPayment(paymentModelDao, transactionsForAccount);
}
@@ -241,6 +241,4 @@ public class DirectPaymentProcessor extends ProcessorBase {
return new DefaultDirectPayment(curDirectPaymentModelDao.getId(), curDirectPaymentModelDao.getCreatedDate(), curDirectPaymentModelDao.getUpdatedDate(), curDirectPaymentModelDao.getAccountId(),
curDirectPaymentModelDao.getPaymentMethodId(), curDirectPaymentModelDao.getPaymentNumber(), curDirectPaymentModelDao.getExternalKey(), sortedTransactions);
}
-
-
}
diff --git a/payment/src/main/java/org/killbill/billing/payment/core/PaymentMethodProcessor.java b/payment/src/main/java/org/killbill/billing/payment/core/PaymentMethodProcessor.java
index 81dba8a..687982a 100644
--- a/payment/src/main/java/org/killbill/billing/payment/core/PaymentMethodProcessor.java
+++ b/payment/src/main/java/org/killbill/billing/payment/core/PaymentMethodProcessor.java
@@ -1,7 +1,9 @@
/*
* Copyright 2010-2013 Ning, Inc.
+ * Copyright 2014 Groupon, Inc
+ * Copyright 2014 The Billing Project, LLC
*
- * Ning licenses this file to you under the Apache License, version 2.0
+ * The Billing Project licenses this file to you under the Apache License, version 2.0
* (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
*
@@ -24,25 +26,20 @@ import java.util.concurrent.ExecutorService;
import javax.annotation.Nullable;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import org.killbill.billing.ErrorCode;
import org.killbill.billing.ObjectType;
import org.killbill.billing.account.api.Account;
import org.killbill.billing.account.api.AccountApiException;
import org.killbill.billing.account.api.AccountInternalApi;
-import org.killbill.bus.api.PersistentBus;
import org.killbill.billing.callcontext.InternalCallContext;
import org.killbill.billing.callcontext.InternalTenantContext;
-import org.killbill.commons.locker.GlobalLocker;
import org.killbill.billing.invoice.api.InvoiceInternalApi;
import org.killbill.billing.osgi.api.OSGIServiceRegistration;
import org.killbill.billing.payment.api.DefaultPaymentMethod;
import org.killbill.billing.payment.api.PaymentApiException;
import org.killbill.billing.payment.api.PaymentMethod;
-import org.killbill.billing.payment.api.PaymentMethodKVInfo;
import org.killbill.billing.payment.api.PaymentMethodPlugin;
+import org.killbill.billing.payment.api.PluginProperty;
import org.killbill.billing.payment.dao.PaymentDao;
import org.killbill.billing.payment.dao.PaymentMethodModelDao;
import org.killbill.billing.payment.plugin.api.PaymentMethodInfoPlugin;
@@ -57,6 +54,10 @@ import org.killbill.billing.util.dao.NonEntityDao;
import org.killbill.billing.util.entity.Pagination;
import org.killbill.billing.util.entity.dao.DefaultPaginationHelper.EntityPaginationBuilder;
import org.killbill.billing.util.entity.dao.DefaultPaginationHelper.SourcePaginationBuilder;
+import org.killbill.bus.api.PersistentBus;
+import org.killbill.commons.locker.GlobalLocker;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import com.google.common.base.Function;
import com.google.common.collect.Collections2;
@@ -99,7 +100,7 @@ public class PaymentMethodProcessor extends ProcessorBase {
try {
pluginApi = getPaymentPluginApi(paymentPluginServiceName);
pm = new DefaultPaymentMethod(account.getId(), paymentPluginServiceName, paymentMethodProps);
- pluginApi.addPaymentMethod(account.getId(), pm.getId(), paymentMethodProps, setDefault, context.toCallContext(tenantId));
+ pluginApi.addPaymentMethod(account.getId(), pm.getId(), paymentMethodProps, setDefault, ImmutableList.<PluginProperty>of(), context.toCallContext(tenantId));
final PaymentMethodModelDao pmModel = new PaymentMethodModelDao(pm.getId(), pm.getCreatedDate(), pm.getUpdatedDate(),
pm.getAccountId(), pm.getPluginName(), pm.isActive());
paymentDao.insertPaymentMethod(pmModel, context);
@@ -107,11 +108,11 @@ public class PaymentMethodProcessor extends ProcessorBase {
if (setDefault) {
accountInternalApi.updatePaymentMethod(account.getId(), pm.getId(), context);
}
- } catch (PaymentPluginApiException e) {
+ } catch (final PaymentPluginApiException e) {
log.warn("Error adding payment method " + pm.getId() + " for plugin " + paymentPluginServiceName, e);
// STEPH all errors should also take a pluginName
throw new PaymentApiException(ErrorCode.PAYMENT_ADD_PAYMENT_METHOD, account.getId(), e.getErrorMessage());
- } catch (AccountApiException e) {
+ } catch (final AccountApiException e) {
throw new PaymentApiException(e);
}
return pm.getId();
@@ -143,8 +144,8 @@ public class PaymentMethodProcessor extends ProcessorBase {
if (withPluginInfo) {
try {
final PaymentPluginApi pluginApi = getPaymentPluginApi(paymentMethodModelDao.getPluginName());
- paymentMethodPlugin = pluginApi.getPaymentMethodDetail(paymentMethodModelDao.getAccountId(), paymentMethodModelDao.getId(), buildTenantContext(context));
- } catch (PaymentPluginApiException e) {
+ paymentMethodPlugin = pluginApi.getPaymentMethodDetail(paymentMethodModelDao.getAccountId(), paymentMethodModelDao.getId(), ImmutableList.<PluginProperty>of(), buildTenantContext(context));
+ } catch (final PaymentPluginApiException e) {
log.warn("Error retrieving payment method " + paymentMethodModelDao.getId() + " from plugin " + paymentMethodModelDao.getPluginName(), e);
throw new PaymentApiException(ErrorCode.PAYMENT_GET_PAYMENT_METHODS, paymentMethodModelDao.getAccountId(), paymentMethodModelDao.getId());
}
@@ -164,7 +165,8 @@ public class PaymentMethodProcessor extends ProcessorBase {
public Pagination<PaymentMethod> build(final Long offset, final Long limit, final String pluginName) throws PaymentApiException {
return getPaymentMethods(offset, limit, pluginName, tenantContext, internalTenantContext);
}
- });
+ }
+ );
}
public Pagination<PaymentMethod> getPaymentMethods(final Long offset, final Long limit, final String pluginName, final TenantContext tenantContext, final InternalTenantContext internalTenantContext) throws PaymentApiException {
@@ -183,7 +185,7 @@ public class PaymentMethodProcessor extends ProcessorBase {
public PaymentMethod apply(final PaymentMethodModelDao paymentMethodModelDao) {
PaymentMethodPlugin paymentMethodPlugin = null;
try {
- paymentMethodPlugin = pluginApi.getPaymentMethodDetail(paymentMethodModelDao.getAccountId(), paymentMethodModelDao.getId(), tenantContext);
+ paymentMethodPlugin = pluginApi.getPaymentMethodDetail(paymentMethodModelDao.getAccountId(), paymentMethodModelDao.getId(), ImmutableList.<PluginProperty>of(), tenantContext);
} catch (final PaymentPluginApiException e) {
log.warn("Unable to find payment method id " + paymentMethodModelDao.getId() + " in plugin " + pluginName);
// We still want to return a payment method object, even though the plugin details are missing
@@ -204,7 +206,8 @@ public class PaymentMethodProcessor extends ProcessorBase {
public Pagination<PaymentMethod> build(final Long offset, final Long limit, final String pluginName) throws PaymentApiException {
return searchPaymentMethods(searchKey, offset, limit, pluginName, internalTenantContext);
}
- });
+ }
+ );
}
public Pagination<PaymentMethod> searchPaymentMethods(final String searchKey, final Long offset, final Long limit, final String pluginName, final InternalTenantContext internalTenantContext) throws PaymentApiException {
@@ -215,7 +218,7 @@ public class PaymentMethodProcessor extends ProcessorBase {
@Override
public Pagination<PaymentMethodPlugin> build() throws PaymentApiException {
try {
- return pluginApi.searchPaymentMethods(searchKey, offset, limit, buildTenantContext(internalTenantContext));
+ return pluginApi.searchPaymentMethods(searchKey, offset, limit, ImmutableList.<PluginProperty>of(), buildTenantContext(internalTenantContext));
} catch (final PaymentPluginApiException e) {
throw new PaymentApiException(e, ErrorCode.PAYMENT_PLUGIN_SEARCH_PAYMENT_METHODS, pluginName, searchKey);
}
@@ -257,7 +260,7 @@ public class PaymentMethodProcessor extends ProcessorBase {
// Check if this account has already used the external payment plugin
// If not, it's the first time - add a payment method for it
if (getExternalPaymentMethod(account, context) == null) {
- final DefaultNoOpPaymentMethodPlugin props = new DefaultNoOpPaymentMethodPlugin(UUID.randomUUID().toString(), false, ImmutableList.<PaymentMethodKVInfo>of());
+ final DefaultNoOpPaymentMethodPlugin props = new DefaultNoOpPaymentMethodPlugin(UUID.randomUUID().toString(), false, ImmutableList.<PluginProperty>of());
addPaymentMethod(ExternalPaymentProviderPlugin.PLUGIN_NAME, account, false, props, context);
}
@@ -304,13 +307,13 @@ public class PaymentMethodProcessor extends ProcessorBase {
}
}
final PaymentPluginApi pluginApi = getPluginApi(paymentMethodId, context);
- pluginApi.deletePaymentMethod(account.getId(), paymentMethodId, context.toCallContext(tenantId));
+ pluginApi.deletePaymentMethod(account.getId(), paymentMethodId, ImmutableList.<PluginProperty>of(), context.toCallContext(tenantId));
paymentDao.deletedPaymentMethod(paymentMethodId, context);
return null;
- } catch (PaymentPluginApiException e) {
+ } catch (final PaymentPluginApiException e) {
log.warn("Error deleting payment method " + paymentMethodId, e);
throw new PaymentApiException(ErrorCode.PAYMENT_DEL_PAYMENT_METHOD, account.getId(), e.getErrorMessage());
- } catch (AccountApiException e) {
+ } catch (final AccountApiException e) {
throw new PaymentApiException(e);
}
}
@@ -333,12 +336,12 @@ public class PaymentMethodProcessor extends ProcessorBase {
try {
final PaymentPluginApi pluginApi = getPluginApi(paymentMethodId, context);
- pluginApi.setDefaultPaymentMethod(account.getId(), paymentMethodId, context.toCallContext(tenantId));
+ pluginApi.setDefaultPaymentMethod(account.getId(), paymentMethodId, ImmutableList.<PluginProperty>of(), context.toCallContext(tenantId));
accountInternalApi.updatePaymentMethod(account.getId(), paymentMethodId, context);
return null;
- } catch (PaymentPluginApiException e) {
+ } catch (final PaymentPluginApiException e) {
throw new PaymentApiException(ErrorCode.PAYMENT_UPD_PAYMENT_METHOD, account.getId(), e.getErrorMessage());
- } catch (AccountApiException e) {
+ } catch (final AccountApiException e) {
throw new PaymentApiException(e);
}
}
@@ -372,13 +375,13 @@ public class PaymentMethodProcessor extends ProcessorBase {
final PaymentPluginApi pluginApi = getPaymentPluginApi(pluginName);
final List<PaymentMethodInfoPlugin> pluginPms;
try {
- pluginPms = pluginApi.getPaymentMethods(account.getId(), true, context.toCallContext(tenantId));
+ pluginPms = pluginApi.getPaymentMethods(account.getId(), true, ImmutableList.<PluginProperty>of(), context.toCallContext(tenantId));
// The method should never return null by convention, but let's not trust the plugin...
if (pluginPms == null) {
log.debug("No payment methods defined on the account {} for plugin {}", account.getId(), pluginName);
return ImmutableList.<PaymentMethod>of();
}
- } catch (PaymentPluginApiException e) {
+ } catch (final PaymentPluginApiException e) {
log.warn("Error refreshing payment methods for account " + account.getId() + " and plugin " + pluginName, e);
throw new PaymentApiException(ErrorCode.PAYMENT_REFRESH_PAYMENT_METHOD, account.getId(), e.getErrorMessage());
}
@@ -415,15 +418,15 @@ public class PaymentMethodProcessor extends ProcessorBase {
finalPaymentMethods,
context);
try {
- pluginApi.resetPaymentMethods(account.getId(), pluginPmsWithId);
- } catch (PaymentPluginApiException e) {
+ pluginApi.resetPaymentMethods(account.getId(), pluginPmsWithId, ImmutableList.<PluginProperty>of());
+ } catch (final PaymentPluginApiException e) {
log.warn("Error resetting payment methods for account " + account.getId() + " and plugin " + pluginName, e);
throw new PaymentApiException(ErrorCode.PAYMENT_REFRESH_PAYMENT_METHOD, account.getId(), e.getErrorMessage());
}
try {
updateDefaultPaymentMethodIfNeeded(pluginName, account, defaultPaymentMethodId, context);
- } catch (AccountApiException e) {
+ } catch (final AccountApiException e) {
throw new PaymentApiException(e);
}
diff --git a/payment/src/main/java/org/killbill/billing/payment/core/PaymentProcessor.java b/payment/src/main/java/org/killbill/billing/payment/core/PaymentProcessor.java
index b2fe6ab..504a59d 100644
--- a/payment/src/main/java/org/killbill/billing/payment/core/PaymentProcessor.java
+++ b/payment/src/main/java/org/killbill/billing/payment/core/PaymentProcessor.java
@@ -1,7 +1,9 @@
/*
* Copyright 2010-2013 Ning, Inc.
+ * Copyright 2014 Groupon, Inc
+ * Copyright 2014 The Billing Project, LLC
*
- * Ning licenses this file to you under the Apache License, version 2.0
+ * The Billing Project licenses this file to you under the Apache License, version 2.0
* (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
*
@@ -17,7 +19,6 @@
package org.killbill.billing.payment.core;
import java.math.BigDecimal;
-import java.math.RoundingMode;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;
@@ -30,19 +31,13 @@ import java.util.concurrent.TimeoutException;
import javax.annotation.Nullable;
import javax.inject.Inject;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import org.killbill.billing.ErrorCode;
import org.killbill.billing.ObjectType;
import org.killbill.billing.account.api.Account;
import org.killbill.billing.account.api.AccountApiException;
import org.killbill.billing.account.api.AccountInternalApi;
-import org.killbill.bus.api.PersistentBus;
import org.killbill.billing.callcontext.InternalCallContext;
import org.killbill.billing.callcontext.InternalTenantContext;
-import org.killbill.clock.Clock;
-import org.killbill.commons.locker.GlobalLocker;
import org.killbill.billing.events.BusInternalEvent;
import org.killbill.billing.events.PaymentErrorInternalEvent;
import org.killbill.billing.invoice.api.Invoice;
@@ -56,6 +51,7 @@ import org.killbill.billing.payment.api.DefaultPaymentPluginErrorEvent;
import org.killbill.billing.payment.api.Payment;
import org.killbill.billing.payment.api.PaymentApiException;
import org.killbill.billing.payment.api.PaymentStatus;
+import org.killbill.billing.payment.api.PluginProperty;
import org.killbill.billing.payment.dao.PaymentAttemptModelDao;
import org.killbill.billing.payment.dao.PaymentDao;
import org.killbill.billing.payment.dao.PaymentModelDao;
@@ -75,10 +71,16 @@ import org.killbill.billing.util.dao.NonEntityDao;
import org.killbill.billing.util.entity.Pagination;
import org.killbill.billing.util.entity.dao.DefaultPaginationHelper.EntityPaginationBuilder;
import org.killbill.billing.util.entity.dao.DefaultPaginationHelper.SourcePaginationBuilder;
+import org.killbill.bus.api.PersistentBus;
+import org.killbill.clock.Clock;
+import org.killbill.commons.locker.GlobalLocker;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import com.google.common.base.Function;
import com.google.common.base.Predicate;
import com.google.common.collect.Collections2;
+import com.google.common.collect.ImmutableList;
import com.google.inject.name.Named;
import static org.killbill.billing.payment.glue.PaymentModule.PLUGIN_EXECUTOR_NAMED;
@@ -140,8 +142,8 @@ public class PaymentProcessor extends ProcessorBase {
PaymentInfoPlugin pluginInfo = null;
if (plugin != null) {
try {
- pluginInfo = plugin.getPaymentInfo(model.getAccountId(), paymentId, buildTenantContext(context));
- } catch (PaymentPluginApiException e) {
+ pluginInfo = plugin.getPaymentInfo(model.getAccountId(), paymentId, ImmutableList.<PluginProperty>of(), buildTenantContext(context));
+ } catch (final PaymentPluginApiException e) {
throw new PaymentApiException(ErrorCode.PAYMENT_PLUGIN_GET_PAYMENT_INFO, paymentId, e.toString());
}
}
@@ -157,7 +159,8 @@ public class PaymentProcessor extends ProcessorBase {
public Pagination<Payment> build(final Long offset, final Long limit, final String pluginName) throws PaymentApiException {
return getPayments(offset, limit, pluginName, tenantContext, internalTenantContext);
}
- });
+ }
+ );
}
public Pagination<Payment> getPayments(final Long offset, final Long limit, final String pluginName, final TenantContext tenantContext, final InternalTenantContext internalTenantContext) throws PaymentApiException {
@@ -176,7 +179,7 @@ public class PaymentProcessor extends ProcessorBase {
public Payment apply(final PaymentModelDao paymentModelDao) {
PaymentInfoPlugin pluginInfo = null;
try {
- pluginInfo = pluginApi.getPaymentInfo(paymentModelDao.getAccountId(), paymentModelDao.getId(), tenantContext);
+ pluginInfo = pluginApi.getPaymentInfo(paymentModelDao.getAccountId(), paymentModelDao.getId(), ImmutableList.<PluginProperty>of(), tenantContext);
} catch (final PaymentPluginApiException e) {
log.warn("Unable to find payment id " + paymentModelDao.getId() + " in plugin " + pluginName);
// We still want to return a payment object, even though the plugin details are missing
@@ -197,7 +200,8 @@ public class PaymentProcessor extends ProcessorBase {
public Pagination<Payment> build(final Long offset, final Long limit, final String pluginName) throws PaymentApiException {
return searchPayments(searchKey, offset, limit, pluginName, internalTenantContext);
}
- });
+ }
+ );
}
public Pagination<Payment> searchPayments(final String searchKey, final Long offset, final Long limit, final String pluginName, final InternalTenantContext internalTenantContext) throws PaymentApiException {
@@ -208,7 +212,7 @@ public class PaymentProcessor extends ProcessorBase {
@Override
public Pagination<PaymentInfoPlugin> build() throws PaymentApiException {
try {
- return pluginApi.searchPayments(searchKey, offset, limit, buildTenantContext(internalTenantContext));
+ return pluginApi.searchPayments(searchKey, offset, limit, ImmutableList.<PluginProperty>of(), buildTenantContext(internalTenantContext));
} catch (final PaymentPluginApiException e) {
throw new PaymentApiException(e, ErrorCode.PAYMENT_PLUGIN_SEARCH_PAYMENTS, pluginName, searchKey);
}
@@ -284,7 +288,7 @@ public class PaymentProcessor extends ProcessorBase {
}
});
// Insert one retry event for each payment left in AUTO_PAY_OFF
- for (PaymentModelDao cur : paymentsToBeCompleted) {
+ for (final PaymentModelDao cur : paymentsToBeCompleted) {
switch (cur.getPaymentStatus()) {
case AUTO_PAY_OFF:
autoPayoffRetryService.scheduleRetry(cur.getId(), clock.getUTCNow());
@@ -304,8 +308,9 @@ public class PaymentProcessor extends ProcessorBase {
}
return null;
}
- }));
- } catch (TimeoutException e) {
+ }
+ ));
+ } catch (final TimeoutException e) {
throw new PaymentApiException(ErrorCode.UNEXPECTED_ERROR, "Unexpected timeout for payment creation (AUTO_PAY_OFF)");
}
}
@@ -356,7 +361,7 @@ public class PaymentProcessor extends ProcessorBase {
plugin = getPaymentProviderPlugin(account, context);
paymentMethodId = account.getPaymentMethodId();
}
- } catch (PaymentApiException e) {
+ } catch (final PaymentApiException e) {
// Insert a payment entry with one attempt in a terminal state to keep a record of the failure
processNewPaymentForMissingDefaultPaymentMethodWithAccountLocked(account, invoice, requestedAmount, context);
@@ -380,12 +385,13 @@ public class PaymentProcessor extends ProcessorBase {
} else {
return processNewPaymentWithAccountLocked(paymentMethodId, plugin, account, invoice, requestedAmount, isInstantPayment, context);
}
- } catch (InvoiceApiException e) {
+ } catch (final InvoiceApiException e) {
throw new PaymentApiException(e);
}
}
- }));
- } catch (TimeoutException e) {
+ }
+ ));
+ } catch (final TimeoutException e) {
if (isInstantPayment) {
throw new PaymentApiException(ErrorCode.PAYMENT_PLUGIN_TIMEOUT, account.getId(), invoiceId);
} else {
@@ -396,7 +402,7 @@ public class PaymentProcessor extends ProcessorBase {
// swallowing exception
return null;
}
- } catch (RuntimeException e) {
+ } catch (final RuntimeException e) {
log.error("Failure when dispatching payment for invoice " + invoiceId, e);
if (isInstantPayment) {
throw new PaymentApiException(ErrorCode.PAYMENT_INTERNAL_ERROR, invoiceId);
@@ -534,16 +540,17 @@ public class PaymentProcessor extends ProcessorBase {
}
processRetryPaymentWithAccountLocked(plugin, account, invoice, payment, invoice.getBalance(), context);
return null;
- } catch (InvoiceApiException e) {
+ } catch (final InvoiceApiException e) {
throw new PaymentApiException(e);
}
}
- }));
- } catch (AccountApiException e) {
+ }
+ ));
+ } catch (final AccountApiException e) {
log.error(String.format("Failed to retry payment for paymentId %s", paymentId), e);
- } catch (PaymentApiException e) {
+ } catch (final PaymentApiException e) {
log.info(String.format("Failed to retry payment for paymentId %s", paymentId), e);
- } catch (TimeoutException e) {
+ } catch (final TimeoutException e) {
log.warn(String.format("Retry for payment %s timedout", paymentId));
// STEPH we should throw some exception so NotificationQ does not clear status and retries us
}
@@ -640,8 +647,8 @@ public class PaymentProcessor extends ProcessorBase {
try {
try {
paymentPluginInfo = plugin.processPayment(account.getId(), paymentInput.getId(), attemptInput.getPaymentMethodId(),
- attemptInput.getRequestedAmount(), account.getCurrency(), context.toCallContext(tenantId));
- } catch (RuntimeException e) {
+ attemptInput.getRequestedAmount(), account.getCurrency(), ImmutableList.<PluginProperty>of(), context.toCallContext(tenantId));
+ } catch (final RuntimeException e) {
// Handle case of plugin RuntimeException to be handled the same as a Plugin failure (PaymentPluginApiException)
final String formatError = String.format("Plugin threw RuntimeException for payment %s", paymentInput.getId());
throw new PaymentPluginApiException(formatError, e);
@@ -710,7 +717,7 @@ public class PaymentProcessor extends ProcessorBase {
throw new PaymentPluginApiException("", formatError);
}
- } catch (PaymentPluginApiException e) {
+ } catch (final PaymentPluginApiException e) {
//
// An exception occurred, we are left in an unknown state, we need to schedule a retry
//
@@ -725,7 +732,7 @@ public class PaymentProcessor extends ProcessorBase {
);
throw new PaymentApiException(ErrorCode.PAYMENT_CREATE_PAYMENT, account.getId(), e.toString());
- } catch (InvoiceApiException e) {
+ } catch (final InvoiceApiException e) {
throw new PaymentApiException(ErrorCode.INVOICE_NOT_FOUND, invoice.getId(), e.toString());
} finally {
if (event != null) {
diff --git a/payment/src/main/java/org/killbill/billing/payment/core/RefundProcessor.java b/payment/src/main/java/org/killbill/billing/payment/core/RefundProcessor.java
index f621999..d509840 100644
--- a/payment/src/main/java/org/killbill/billing/payment/core/RefundProcessor.java
+++ b/payment/src/main/java/org/killbill/billing/payment/core/RefundProcessor.java
@@ -30,24 +30,20 @@ import java.util.concurrent.ExecutorService;
import javax.annotation.Nullable;
import javax.inject.Inject;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import org.killbill.billing.ErrorCode;
import org.killbill.billing.ObjectType;
import org.killbill.billing.account.api.Account;
import org.killbill.billing.account.api.AccountApiException;
import org.killbill.billing.account.api.AccountInternalApi;
-import org.killbill.bus.api.PersistentBus;
import org.killbill.billing.callcontext.InternalCallContext;
import org.killbill.billing.callcontext.InternalTenantContext;
-import org.killbill.commons.locker.GlobalLocker;
import org.killbill.billing.invoice.api.InvoiceApiException;
import org.killbill.billing.invoice.api.InvoiceInternalApi;
import org.killbill.billing.invoice.api.InvoiceItem;
import org.killbill.billing.osgi.api.OSGIServiceRegistration;
import org.killbill.billing.payment.api.DefaultRefund;
import org.killbill.billing.payment.api.PaymentApiException;
+import org.killbill.billing.payment.api.PluginProperty;
import org.killbill.billing.payment.api.Refund;
import org.killbill.billing.payment.api.RefundStatus;
import org.killbill.billing.payment.dao.PaymentDao;
@@ -66,6 +62,10 @@ import org.killbill.billing.util.dao.NonEntityDao;
import org.killbill.billing.util.entity.Pagination;
import org.killbill.billing.util.entity.dao.DefaultPaginationHelper.EntityPaginationBuilder;
import org.killbill.billing.util.entity.dao.DefaultPaginationHelper.SourcePaginationBuilder;
+import org.killbill.bus.api.PersistentBus;
+import org.killbill.commons.locker.GlobalLocker;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import com.google.common.base.Function;
import com.google.common.base.Objects;
@@ -135,7 +135,7 @@ public class RefundProcessor extends ProcessorBase {
paymentDao.insertRefund(refundInfo, context);
final PaymentPluginApi plugin = getPaymentProviderPlugin(payment.getPaymentMethodId(), context);
- final RefundInfoPlugin refundInfoPlugin = plugin.processRefund(account.getId(), paymentId, refundAmount, account.getCurrency(), context.toCallContext(tenantId));
+ final RefundInfoPlugin refundInfoPlugin = plugin.processRefund(account.getId(), paymentId, refundAmount, account.getCurrency(), ImmutableList.<PluginProperty>of(), context.toCallContext(tenantId));
switch (refundInfoPlugin.getStatus()) {
case PROCESSED:
@@ -162,7 +162,8 @@ public class RefundProcessor extends ProcessorBase {
refundInfoPlugin.getGatewayError(),
refundInfoPlugin.getGatewayErrorCode(),
refundInfoPlugin.getFirstRefundReferenceId(),
- refundInfoPlugin.getSecondRefundReferenceId()));
+ refundInfoPlugin.getSecondRefundReferenceId())
+ );
}
} catch (PaymentPluginApiException e) {
throw new PaymentApiException(ErrorCode.PAYMENT_CREATE_REFUND, account.getId(), e.getErrorMessage());
@@ -265,7 +266,7 @@ public class RefundProcessor extends ProcessorBase {
List<RefundInfoPlugin> refundInfoPlugins = ImmutableList.<RefundInfoPlugin>of();
if (plugin != null) {
try {
- refundInfoPlugins = plugin.getRefundInfo(result.getAccountId(), result.getPaymentId(), buildTenantContext(context));
+ refundInfoPlugins = plugin.getRefundInfo(result.getAccountId(), result.getPaymentId(), ImmutableList.<PluginProperty>of(), buildTenantContext(context));
} catch (final PaymentPluginApiException e) {
throw new PaymentApiException(ErrorCode.PAYMENT_PLUGIN_GET_REFUND_INFO, refundId, e.toString());
}
@@ -285,7 +286,8 @@ public class RefundProcessor extends ProcessorBase {
public boolean apply(final RefundInfoPlugin refundInfoPlugin) {
return refundObjectsMatch(refundModelDao, refundInfoPlugin);
}
- }).orNull();
+ }
+ ).orNull();
}
private boolean refundObjectsMatch(final RefundModelDao refundModelDao, final RefundInfoPlugin refundInfoPlugin) {
@@ -307,7 +309,8 @@ public class RefundProcessor extends ProcessorBase {
public Pagination<Refund> build(final Long offset, final Long limit, final String pluginName) throws PaymentApiException {
return getRefunds(offset, limit, pluginName, tenantContext, internalTenantContext);
}
- });
+ }
+ );
}
public Pagination<Refund> getRefunds(final Long offset, final Long limit, final String pluginName, final TenantContext tenantContext, final InternalTenantContext internalTenantContext) throws PaymentApiException {
@@ -326,7 +329,7 @@ public class RefundProcessor extends ProcessorBase {
public Refund apply(final RefundModelDao refundModelDao) {
List<RefundInfoPlugin> refundInfoPlugins = null;
try {
- refundInfoPlugins = pluginApi.getRefundInfo(refundModelDao.getAccountId(), refundModelDao.getId(), tenantContext);
+ refundInfoPlugins = pluginApi.getRefundInfo(refundModelDao.getAccountId(), refundModelDao.getId(), ImmutableList.<PluginProperty>of(), tenantContext);
} catch (final PaymentPluginApiException e) {
log.warn("Unable to find refund id " + refundModelDao.getId() + " in plugin " + pluginName);
// We still want to return a refund object, even though the plugin details are missing
@@ -348,7 +351,8 @@ public class RefundProcessor extends ProcessorBase {
public Pagination<Refund> build(final Long offset, final Long limit, final String pluginName) throws PaymentApiException {
return searchRefunds(searchKey, offset, limit, pluginName, internalTenantContext);
}
- });
+ }
+ );
}
public Pagination<Refund> searchRefunds(final String searchKey, final Long offset, final Long limit, final String pluginName, final InternalTenantContext internalTenantContext) throws PaymentApiException {
@@ -363,7 +367,7 @@ public class RefundProcessor extends ProcessorBase {
public Pagination<RefundInfoPlugin> build() throws PaymentApiException {
final Pagination<RefundInfoPlugin> refunds;
try {
- refunds = pluginApi.searchRefunds(searchKey, offset, limit, buildTenantContext(internalTenantContext));
+ refunds = pluginApi.searchRefunds(searchKey, offset, limit, ImmutableList.<PluginProperty>of(), buildTenantContext(internalTenantContext));
} catch (final PaymentPluginApiException e) {
throw new PaymentApiException(e, ErrorCode.PAYMENT_PLUGIN_SEARCH_REFUNDS, pluginName, searchKey);
}
@@ -407,7 +411,8 @@ public class RefundProcessor extends ProcessorBase {
public boolean apply(final RefundModelDao refundModelDao) {
return refundObjectsMatch(refundModelDao, refundInfoPlugin);
}
- }).orNull();
+ }
+ ).orNull();
if (model == null) {
log.warn("Unable to find refund for payment id " + refundInfoPlugin.getKbPaymentId() + " present in plugin " + pluginName);
diff --git a/payment/src/main/java/org/killbill/billing/payment/provider/DefaultNoOpPaymentInfoPlugin.java b/payment/src/main/java/org/killbill/billing/payment/provider/DefaultNoOpPaymentInfoPlugin.java
index 4e5aa69..4c60a0e 100644
--- a/payment/src/main/java/org/killbill/billing/payment/provider/DefaultNoOpPaymentInfoPlugin.java
+++ b/payment/src/main/java/org/killbill/billing/payment/provider/DefaultNoOpPaymentInfoPlugin.java
@@ -17,14 +17,18 @@
package org.killbill.billing.payment.provider;
import java.math.BigDecimal;
+import java.util.List;
import java.util.UUID;
import org.joda.time.DateTime;
import org.killbill.billing.catalog.api.Currency;
+import org.killbill.billing.payment.api.PluginProperty;
import org.killbill.billing.payment.plugin.api.PaymentInfoPlugin;
import org.killbill.billing.payment.plugin.api.PaymentPluginStatus;
+import com.google.common.collect.ImmutableList;
+
public class DefaultNoOpPaymentInfoPlugin implements PaymentInfoPlugin {
private final UUID kbPaymentId;
@@ -97,6 +101,11 @@ public class DefaultNoOpPaymentInfoPlugin implements PaymentInfoPlugin {
}
@Override
+ public List<PluginProperty> getProperties() {
+ return ImmutableList.<PluginProperty>of();
+ }
+
+ @Override
public String toString() {
final StringBuilder sb = new StringBuilder("DefaultNoOpPaymentInfoPlugin{");
sb.append("kbPaymentId=").append(kbPaymentId);
diff --git a/payment/src/main/java/org/killbill/billing/payment/provider/DefaultNoOpPaymentMethodPlugin.java b/payment/src/main/java/org/killbill/billing/payment/provider/DefaultNoOpPaymentMethodPlugin.java
index f22baa9..266e303 100644
--- a/payment/src/main/java/org/killbill/billing/payment/provider/DefaultNoOpPaymentMethodPlugin.java
+++ b/payment/src/main/java/org/killbill/billing/payment/provider/DefaultNoOpPaymentMethodPlugin.java
@@ -1,7 +1,9 @@
/*
* Copyright 2010-2013 Ning, Inc.
+ * Copyright 2014 Groupon, Inc
+ * Copyright 2014 The Billing Project, LLC
*
- * Ning licenses this file to you under the Apache License, version 2.0
+ * The Billing Project licenses this file to you under the Apache License, version 2.0
* (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
*
@@ -21,15 +23,15 @@ import java.util.UUID;
import javax.annotation.Nullable;
-import org.killbill.billing.payment.api.PaymentMethodKVInfo;
import org.killbill.billing.payment.api.PaymentMethodPlugin;
+import org.killbill.billing.payment.api.PluginProperty;
public class DefaultNoOpPaymentMethodPlugin implements PaymentMethodPlugin {
private final UUID kbPaymentMethodId;
private final String externalId;
private final boolean isDefault;
- private List<PaymentMethodKVInfo> props;
+ private List<PluginProperty> props;
public DefaultNoOpPaymentMethodPlugin(final UUID kbPaymentMethodId, final PaymentMethodPlugin src) {
this.kbPaymentMethodId = kbPaymentMethodId;
@@ -40,14 +42,14 @@ public class DefaultNoOpPaymentMethodPlugin implements PaymentMethodPlugin {
public DefaultNoOpPaymentMethodPlugin(final String externalId,
final boolean isDefault,
- final List<PaymentMethodKVInfo> props) {
+ final List<PluginProperty> props) {
this(null, externalId, isDefault, props);
}
public DefaultNoOpPaymentMethodPlugin(@Nullable final UUID kbPaymentMethodId,
final String externalId,
final boolean isDefault,
- final List<PaymentMethodKVInfo> props) {
+ final List<PluginProperty> props) {
this.kbPaymentMethodId = kbPaymentMethodId;
this.externalId = externalId;
this.isDefault = isDefault;
@@ -70,11 +72,11 @@ public class DefaultNoOpPaymentMethodPlugin implements PaymentMethodPlugin {
}
@Override
- public List<PaymentMethodKVInfo> getProperties() {
+ public List<PluginProperty> getProperties() {
return props;
}
- public void setProps(final List<PaymentMethodKVInfo> props) {
+ public void setProps(final List<PluginProperty> props) {
this.props = props;
}
diff --git a/payment/src/main/java/org/killbill/billing/payment/provider/DefaultNoOpPaymentProviderPlugin.java b/payment/src/main/java/org/killbill/billing/payment/provider/DefaultNoOpPaymentProviderPlugin.java
index 5cdebfe..d479074 100644
--- a/payment/src/main/java/org/killbill/billing/payment/provider/DefaultNoOpPaymentProviderPlugin.java
+++ b/payment/src/main/java/org/killbill/billing/payment/provider/DefaultNoOpPaymentProviderPlugin.java
@@ -1,7 +1,9 @@
/*
* Copyright 2010-2013 Ning, Inc.
+ * Copyright 2014 Groupon, Inc
+ * Copyright 2014 The Billing Project, LLC
*
- * Ning licenses this file to you under the Apache License, version 2.0
+ * The Billing Project licenses this file to you under the Apache License, version 2.0
* (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
*
@@ -25,11 +27,11 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicBoolean;
import org.killbill.billing.catalog.api.Currency;
+import org.killbill.billing.payment.api.PaymentMethodPlugin;
+import org.killbill.billing.payment.api.PluginProperty;
import org.killbill.billing.payment.plugin.api.HostedPaymentPageDescriptorFields;
import org.killbill.billing.payment.plugin.api.HostedPaymentPageFormDescriptor;
import org.killbill.billing.payment.plugin.api.HostedPaymentPageNotification;
-import org.killbill.clock.Clock;
-import org.killbill.billing.payment.api.PaymentMethodPlugin;
import org.killbill.billing.payment.plugin.api.NoOpPaymentPluginApi;
import org.killbill.billing.payment.plugin.api.PaymentInfoPlugin;
import org.killbill.billing.payment.plugin.api.PaymentMethodInfoPlugin;
@@ -41,6 +43,7 @@ import org.killbill.billing.util.callcontext.CallContext;
import org.killbill.billing.util.callcontext.TenantContext;
import org.killbill.billing.util.entity.DefaultPagination;
import org.killbill.billing.util.entity.Pagination;
+import org.killbill.clock.Clock;
import com.google.common.base.Predicate;
import com.google.common.collect.ImmutableList;
@@ -93,30 +96,30 @@ public class DefaultNoOpPaymentProviderPlugin implements NoOpPaymentPluginApi {
}
@Override
- public PaymentInfoPlugin authorizePayment(UUID kbAccountId, UUID kbPaymentId, UUID kbPaymentMethodId, BigDecimal amount, Currency currency, CallContext context)
+ public PaymentInfoPlugin authorizePayment(final UUID kbAccountId, final UUID kbPaymentId, final UUID kbPaymentMethodId, final BigDecimal amount, final Currency currency, final Iterable<PluginProperty> properties, final CallContext context)
throws PaymentPluginApiException {
return getInternalNoopPaymentInfoResult(kbPaymentId, amount, currency);
}
@Override
- public PaymentInfoPlugin capturePayment(UUID kbAccountId, UUID kbPaymentId, UUID kbPaymentMethodId, BigDecimal amount, Currency currency, CallContext context)
+ public PaymentInfoPlugin capturePayment(final UUID kbAccountId, final UUID kbPaymentId, final UUID kbPaymentMethodId, final BigDecimal amount, final Currency currency, final Iterable<PluginProperty> properties, final CallContext context)
throws PaymentPluginApiException {
return getInternalNoopPaymentInfoResult(kbPaymentId, amount, currency);
}
@Override
- public PaymentInfoPlugin processPayment(final UUID kbAccountId, final UUID kbPaymentId, final UUID kbPaymentMethodId, final BigDecimal amount, final Currency currency, final CallContext context) throws PaymentPluginApiException {
+ public PaymentInfoPlugin processPayment(final UUID kbAccountId, final UUID kbPaymentId, final UUID kbPaymentMethodId, final BigDecimal amount, final Currency currency, final Iterable<PluginProperty> properties, final CallContext context) throws PaymentPluginApiException {
return getInternalNoopPaymentInfoResult(kbPaymentId, amount, currency);
}
@Override
- public PaymentInfoPlugin voidPayment(UUID kbAccountId, UUID kbPaymentId, UUID kbPaymentMethodId, CallContext context)
+ public PaymentInfoPlugin voidPayment(final UUID kbAccountId, final UUID kbPaymentId, final UUID kbPaymentMethodId, final Iterable<PluginProperty> properties, final CallContext context)
throws PaymentPluginApiException {
return getInternalNoopPaymentInfoResult(kbPaymentId, BigDecimal.ZERO, null);
}
@Override
- public PaymentInfoPlugin getPaymentInfo(final UUID kbAccountId, final UUID kbPaymentId, final TenantContext context) throws PaymentPluginApiException {
+ public PaymentInfoPlugin getPaymentInfo(final UUID kbAccountId, final UUID kbPaymentId, final Iterable<PluginProperty> properties, final TenantContext context) throws PaymentPluginApiException {
final PaymentInfoPlugin payment = payments.get(kbPaymentId.toString());
if (payment == null) {
throw new PaymentPluginApiException("", "No payment found for payment id " + kbPaymentId.toString());
@@ -125,7 +128,7 @@ public class DefaultNoOpPaymentProviderPlugin implements NoOpPaymentPluginApi {
}
@Override
- public Pagination<PaymentInfoPlugin> searchPayments(final String searchKey, final Long offset, final Long limit, final TenantContext tenantContext) throws PaymentPluginApiException {
+ public Pagination<PaymentInfoPlugin> searchPayments(final String searchKey, final Long offset, final Long limit, final Iterable<PluginProperty> properties, final TenantContext tenantContext) throws PaymentPluginApiException {
final ImmutableList<PaymentInfoPlugin> allResults = ImmutableList.<PaymentInfoPlugin>copyOf(Iterables.<PaymentInfoPlugin>filter(Iterables.<PaymentInfoPlugin>concat(payments.values()), new Predicate<PaymentInfoPlugin>() {
@Override
public boolean apply(final PaymentInfoPlugin input) {
@@ -148,7 +151,7 @@ public class DefaultNoOpPaymentProviderPlugin implements NoOpPaymentPluginApi {
}
@Override
- public void addPaymentMethod(final UUID kbAccountId, final UUID kbPaymentMethodId, final PaymentMethodPlugin paymentMethodProps, final boolean setDefault, final CallContext context) throws PaymentPluginApiException {
+ public void addPaymentMethod(final UUID kbAccountId, final UUID kbPaymentMethodId, final PaymentMethodPlugin paymentMethodProps, final boolean setDefault, final Iterable<PluginProperty> properties, final CallContext context) throws PaymentPluginApiException {
final PaymentMethodPlugin realWithID = new DefaultNoOpPaymentMethodPlugin(kbPaymentMethodId, paymentMethodProps);
List<PaymentMethodPlugin> pms = paymentMethods.get(kbPaymentMethodId.toString());
if (pms == null) {
@@ -159,7 +162,7 @@ public class DefaultNoOpPaymentProviderPlugin implements NoOpPaymentPluginApi {
}
@Override
- public void deletePaymentMethod(final UUID kbAccountId, final UUID kbPaymentMethodId, final CallContext context) throws PaymentPluginApiException {
+ public void deletePaymentMethod(final UUID kbAccountId, final UUID kbPaymentMethodId, final Iterable<PluginProperty> properties, final CallContext context) throws PaymentPluginApiException {
PaymentMethodPlugin toBeDeleted = null;
final List<PaymentMethodPlugin> pms = paymentMethods.get(kbPaymentMethodId.toString());
if (pms != null) {
@@ -177,7 +180,7 @@ public class DefaultNoOpPaymentProviderPlugin implements NoOpPaymentPluginApi {
}
@Override
- public PaymentMethodPlugin getPaymentMethodDetail(final UUID kbAccountId, final UUID kbPaymentMethodId, final TenantContext context) throws PaymentPluginApiException {
+ public PaymentMethodPlugin getPaymentMethodDetail(final UUID kbAccountId, final UUID kbPaymentMethodId, final Iterable<PluginProperty> properties, final TenantContext context) throws PaymentPluginApiException {
final List<PaymentMethodPlugin> paymentMethodPlugins = paymentMethods.get(kbPaymentMethodId.toString());
if (paymentMethodPlugins == null || paymentMethodPlugins.size() == 0) {
return null;
@@ -187,16 +190,16 @@ public class DefaultNoOpPaymentProviderPlugin implements NoOpPaymentPluginApi {
}
@Override
- public void setDefaultPaymentMethod(final UUID kbAccountId, final UUID kbPaymentMethodId, final CallContext context) throws PaymentPluginApiException {
+ public void setDefaultPaymentMethod(final UUID kbAccountId, final UUID kbPaymentMethodId, final Iterable<PluginProperty> properties, final CallContext context) throws PaymentPluginApiException {
}
@Override
- public List<PaymentMethodInfoPlugin> getPaymentMethods(final UUID kbAccountId, final boolean refreshFromGateway, final CallContext context) {
+ public List<PaymentMethodInfoPlugin> getPaymentMethods(final UUID kbAccountId, final boolean refreshFromGateway, final Iterable<PluginProperty> properties, final CallContext context) {
return ImmutableList.<PaymentMethodInfoPlugin>of();
}
@Override
- public Pagination<PaymentMethodPlugin> searchPaymentMethods(final String searchKey, final Long offset, final Long limit, final TenantContext tenantContext) throws PaymentPluginApiException {
+ public Pagination<PaymentMethodPlugin> searchPaymentMethods(final String searchKey, final Long offset, final Long limit, final Iterable<PluginProperty> properties, final TenantContext tenantContext) throws PaymentPluginApiException {
final ImmutableList<PaymentMethodPlugin> allResults = ImmutableList.<PaymentMethodPlugin>copyOf(Iterables.<PaymentMethodPlugin>filter(Iterables.<PaymentMethodPlugin>concat(paymentMethods.values()), new Predicate<PaymentMethodPlugin>() {
@Override
public boolean apply(final PaymentMethodPlugin input) {
@@ -223,22 +226,22 @@ public class DefaultNoOpPaymentProviderPlugin implements NoOpPaymentPluginApi {
}
@Override
- public void resetPaymentMethods(final UUID kbAccountId, final List<PaymentMethodInfoPlugin> paymentMethods) {
+ public void resetPaymentMethods(final UUID kbAccountId, final List<PaymentMethodInfoPlugin> paymentMethods, final Iterable<PluginProperty> properties) {
}
@Override
- public HostedPaymentPageFormDescriptor buildFormDescriptor(final UUID uuid, final HostedPaymentPageDescriptorFields hostedPaymentPageDescriptorFields, final TenantContext tenantContext) {
+ public HostedPaymentPageFormDescriptor buildFormDescriptor(final UUID kbAccountId, final HostedPaymentPageDescriptorFields hostedPaymentPageDescriptorFields, final Iterable<PluginProperty> properties, final TenantContext tenantContext) {
return null;
}
@Override
- public HostedPaymentPageNotification processNotification(final String s, final TenantContext tenantContext) throws PaymentPluginApiException {
+ public HostedPaymentPageNotification processNotification(final String notification, final Iterable<PluginProperty> properties, final TenantContext tenantContext) throws PaymentPluginApiException {
return null;
}
@Override
- public RefundInfoPlugin processRefund(final UUID kbAccountId, final UUID kbPaymentId, final BigDecimal refundAmount, final Currency currency, final CallContext context) throws PaymentPluginApiException {
- final PaymentInfoPlugin paymentInfoPlugin = getPaymentInfo(kbAccountId, kbPaymentId, context);
+ public RefundInfoPlugin processRefund(final UUID kbAccountId, final UUID kbPaymentId, final BigDecimal refundAmount, final Currency currency, final Iterable<PluginProperty> properties, final CallContext context) throws PaymentPluginApiException {
+ final PaymentInfoPlugin paymentInfoPlugin = getPaymentInfo(kbAccountId, kbPaymentId, properties, context);
if (paymentInfoPlugin == null) {
throw new PaymentPluginApiException("", String.format("No payment found for payment id %s (plugin %s)", kbPaymentId.toString(), PLUGIN_NAME));
}
@@ -259,12 +262,12 @@ public class DefaultNoOpPaymentProviderPlugin implements NoOpPaymentPluginApi {
}
@Override
- public List<RefundInfoPlugin> getRefundInfo(final UUID kbAccountId, final UUID kbPaymentId, final TenantContext context) {
+ public List<RefundInfoPlugin> getRefundInfo(final UUID kbAccountId, final UUID kbPaymentId, final Iterable<PluginProperty> properties, final TenantContext context) {
return ImmutableList.<RefundInfoPlugin>copyOf(refunds.get(kbPaymentId.toString()));
}
@Override
- public Pagination<RefundInfoPlugin> searchRefunds(final String searchKey, final Long offset, final Long limit, final TenantContext tenantContext) throws PaymentPluginApiException {
+ public Pagination<RefundInfoPlugin> searchRefunds(final String searchKey, final Long offset, final Long limit, final Iterable<PluginProperty> properties, final TenantContext tenantContext) throws PaymentPluginApiException {
final ImmutableList<RefundInfoPlugin> allResults = ImmutableList.<RefundInfoPlugin>copyOf(Iterables.<RefundInfoPlugin>filter(Iterables.<RefundInfoPlugin>concat(refunds.values()), new Predicate<RefundInfoPlugin>() {
@Override
public boolean apply(final RefundInfoPlugin input) {
@@ -295,5 +298,4 @@ public class DefaultNoOpPaymentProviderPlugin implements NoOpPaymentPluginApi {
payments.put(kbPaymentId.toString(), result);
return result;
}
-
}
diff --git a/payment/src/main/java/org/killbill/billing/payment/provider/DefaultNoOpRefundInfoPlugin.java b/payment/src/main/java/org/killbill/billing/payment/provider/DefaultNoOpRefundInfoPlugin.java
index 66c4145..a67ba1d 100644
--- a/payment/src/main/java/org/killbill/billing/payment/provider/DefaultNoOpRefundInfoPlugin.java
+++ b/payment/src/main/java/org/killbill/billing/payment/provider/DefaultNoOpRefundInfoPlugin.java
@@ -1,7 +1,9 @@
/*
* Copyright 2010-2013 Ning, Inc.
+ * Copyright 2014 Groupon, Inc
+ * Copyright 2014 The Billing Project, LLC
*
- * Ning licenses this file to you under the Apache License, version 2.0
+ * The Billing Project licenses this file to you under the Apache License, version 2.0
* (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
*
@@ -17,14 +19,17 @@
package org.killbill.billing.payment.provider;
import java.math.BigDecimal;
+import java.util.List;
import java.util.UUID;
import org.joda.time.DateTime;
-
import org.killbill.billing.catalog.api.Currency;
+import org.killbill.billing.payment.api.PluginProperty;
import org.killbill.billing.payment.plugin.api.RefundInfoPlugin;
import org.killbill.billing.payment.plugin.api.RefundPluginStatus;
+import com.google.common.collect.ImmutableList;
+
public class DefaultNoOpRefundInfoPlugin implements RefundInfoPlugin {
private final UUID kbPaymentId;
@@ -97,6 +102,11 @@ public class DefaultNoOpRefundInfoPlugin implements RefundInfoPlugin {
}
@Override
+ public List<PluginProperty> getProperties() {
+ return ImmutableList.<PluginProperty>of();
+ }
+
+ @Override
public String toString() {
final StringBuilder sb = new StringBuilder("DefaultNoOpRefundInfoPlugin{");
sb.append("kbPaymentId=").append(kbPaymentId);
diff --git a/payment/src/main/java/org/killbill/billing/payment/provider/ExternalPaymentProviderPlugin.java b/payment/src/main/java/org/killbill/billing/payment/provider/ExternalPaymentProviderPlugin.java
index dc5a304..045c8d1 100644
--- a/payment/src/main/java/org/killbill/billing/payment/provider/ExternalPaymentProviderPlugin.java
+++ b/payment/src/main/java/org/killbill/billing/payment/provider/ExternalPaymentProviderPlugin.java
@@ -1,7 +1,9 @@
/*
* Copyright 2010-2013 Ning, Inc.
+ * Copyright 2014 Groupon, Inc
+ * Copyright 2014 The Billing Project, LLC
*
- * Ning licenses this file to you under the Apache License, version 2.0
+ * The Billing Project licenses this file to you under the Apache License, version 2.0
* (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
*
@@ -22,12 +24,11 @@ import java.util.List;
import java.util.UUID;
import org.killbill.billing.catalog.api.Currency;
+import org.killbill.billing.payment.api.PaymentMethodPlugin;
+import org.killbill.billing.payment.api.PluginProperty;
import org.killbill.billing.payment.plugin.api.HostedPaymentPageDescriptorFields;
import org.killbill.billing.payment.plugin.api.HostedPaymentPageFormDescriptor;
import org.killbill.billing.payment.plugin.api.HostedPaymentPageNotification;
-import org.killbill.clock.Clock;
-import org.killbill.billing.payment.api.PaymentMethodKVInfo;
-import org.killbill.billing.payment.api.PaymentMethodPlugin;
import org.killbill.billing.payment.plugin.api.PaymentInfoPlugin;
import org.killbill.billing.payment.plugin.api.PaymentMethodInfoPlugin;
import org.killbill.billing.payment.plugin.api.PaymentPluginApi;
@@ -39,6 +40,7 @@ import org.killbill.billing.util.callcontext.CallContext;
import org.killbill.billing.util.callcontext.TenantContext;
import org.killbill.billing.util.entity.DefaultPagination;
import org.killbill.billing.util.entity.Pagination;
+import org.killbill.clock.Clock;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterators;
@@ -62,88 +64,88 @@ public class ExternalPaymentProviderPlugin implements PaymentPluginApi {
}
@Override
- public PaymentInfoPlugin authorizePayment(final UUID kbAccountId, final UUID kbPaymentId, final UUID kbPaymentMethodId, final BigDecimal amount, final Currency currency, final CallContext callContext) throws PaymentPluginApiException {
+ public PaymentInfoPlugin authorizePayment(final UUID kbAccountId, final UUID kbPaymentId, final UUID kbPaymentMethodId, final BigDecimal amount, final Currency currency, final Iterable<PluginProperty> properties, final CallContext callContext) throws PaymentPluginApiException {
return new DefaultNoOpPaymentInfoPlugin(kbPaymentId, amount, currency, clock.getUTCNow(), clock.getUTCNow(), PaymentPluginStatus.PROCESSED, null);
}
@Override
- public PaymentInfoPlugin capturePayment(final UUID kbAccountId, final UUID kbPaymentId, final UUID kbPaymentMethodId, final BigDecimal amount, final Currency currency, final CallContext callContext) throws PaymentPluginApiException {
+ public PaymentInfoPlugin capturePayment(final UUID kbAccountId, final UUID kbPaymentId, final UUID kbPaymentMethodId, final BigDecimal amount, final Currency currency, final Iterable<PluginProperty> properties, final CallContext callContext) throws PaymentPluginApiException {
return new DefaultNoOpPaymentInfoPlugin(kbPaymentId, amount, currency, clock.getUTCNow(), clock.getUTCNow(), PaymentPluginStatus.PROCESSED, null);
}
@Override
- public PaymentInfoPlugin processPayment(final UUID kbAccountId, final UUID kbPaymentId, final UUID kbPaymentMethodId, final BigDecimal amount, final Currency currency, final CallContext context) throws PaymentPluginApiException {
+ public PaymentInfoPlugin processPayment(final UUID kbAccountId, final UUID kbPaymentId, final UUID kbPaymentMethodId, final BigDecimal amount, final Currency currency, final Iterable<PluginProperty> properties, final CallContext context) throws PaymentPluginApiException {
return new DefaultNoOpPaymentInfoPlugin(kbPaymentId, amount, currency, clock.getUTCNow(), clock.getUTCNow(), PaymentPluginStatus.PROCESSED, null);
}
@Override
- public PaymentInfoPlugin voidPayment(final UUID kbAccountId, final UUID kbPaymentId, final UUID kbPaymentMethodId, final CallContext callContext) throws PaymentPluginApiException {
+ public PaymentInfoPlugin voidPayment(final UUID kbAccountId, final UUID kbPaymentId, final UUID kbPaymentMethodId, final Iterable<PluginProperty> properties, final CallContext callContext) throws PaymentPluginApiException {
return new DefaultNoOpPaymentInfoPlugin(kbPaymentId, BigDecimal.ZERO, null, clock.getUTCNow(), clock.getUTCNow(), PaymentPluginStatus.PROCESSED, null);
}
@Override
- public PaymentInfoPlugin getPaymentInfo(final UUID kbAccountId, final UUID kbPaymentId, final TenantContext context) throws PaymentPluginApiException {
+ public PaymentInfoPlugin getPaymentInfo(final UUID kbAccountId, final UUID kbPaymentId, final Iterable<PluginProperty> properties, final TenantContext context) throws PaymentPluginApiException {
return new DefaultNoOpPaymentInfoPlugin(kbPaymentId, BigDecimal.ZERO, null, clock.getUTCNow(), clock.getUTCNow(), PaymentPluginStatus.PROCESSED, null);
}
@Override
- public Pagination<PaymentInfoPlugin> searchPayments(final String searchKey, final Long offset, final Long limit, final TenantContext tenantContext) throws PaymentPluginApiException {
+ public Pagination<PaymentInfoPlugin> searchPayments(final String searchKey, final Long offset, final Long limit, final Iterable<PluginProperty> properties, final TenantContext tenantContext) throws PaymentPluginApiException {
return new DefaultPagination<PaymentInfoPlugin>(offset, limit, 0L, 0L, Iterators.<PaymentInfoPlugin>emptyIterator());
}
@Override
- public RefundInfoPlugin processRefund(final UUID kbAccountId, final UUID kbPaymentId, final BigDecimal refundAmount, final Currency currency, final CallContext context) throws PaymentPluginApiException {
+ public RefundInfoPlugin processRefund(final UUID kbAccountId, final UUID kbPaymentId, final BigDecimal refundAmount, final Currency currency, final Iterable<PluginProperty> properties, final CallContext context) throws PaymentPluginApiException {
return new DefaultNoOpRefundInfoPlugin(kbPaymentId, BigDecimal.ZERO, currency, clock.getUTCNow(), clock.getUTCNow(), RefundPluginStatus.PROCESSED, null);
}
@Override
- public List<RefundInfoPlugin> getRefundInfo(final UUID kbAccountId, final UUID kbPaymentId, final TenantContext context) throws PaymentPluginApiException {
+ public List<RefundInfoPlugin> getRefundInfo(final UUID kbAccountId, final UUID kbPaymentId, final Iterable<PluginProperty> properties, final TenantContext context) throws PaymentPluginApiException {
return Collections.emptyList();
}
@Override
- public Pagination<RefundInfoPlugin> searchRefunds(final String searchKey, final Long offset, final Long limit, final TenantContext tenantContext) throws PaymentPluginApiException {
+ public Pagination<RefundInfoPlugin> searchRefunds(final String searchKey, final Long offset, final Long limit, final Iterable<PluginProperty> properties, final TenantContext tenantContext) throws PaymentPluginApiException {
return new DefaultPagination<RefundInfoPlugin>(offset, limit, 0L, 0L, Iterators.<RefundInfoPlugin>emptyIterator());
}
@Override
- public void addPaymentMethod(final UUID kbAccountId, final UUID kbPaymentMethodId, final PaymentMethodPlugin paymentMethodProps, final boolean setDefault, final CallContext context) throws PaymentPluginApiException {
+ public void addPaymentMethod(final UUID kbAccountId, final UUID kbPaymentMethodId, final PaymentMethodPlugin paymentMethodProps, final boolean setDefault, final Iterable<PluginProperty> properties, final CallContext context) throws PaymentPluginApiException {
}
@Override
- public void deletePaymentMethod(final UUID kbAccountId, final UUID kbPaymentMethodId, final CallContext context) throws PaymentPluginApiException {
+ public void deletePaymentMethod(final UUID kbAccountId, final UUID kbPaymentMethodId, final Iterable<PluginProperty> properties, final CallContext context) throws PaymentPluginApiException {
}
@Override
- public PaymentMethodPlugin getPaymentMethodDetail(final UUID kbAccountId, final UUID kbPaymentMethodId, final TenantContext context) throws PaymentPluginApiException {
- return new DefaultNoOpPaymentMethodPlugin(kbPaymentMethodId, "unknown", false, Collections.<PaymentMethodKVInfo>emptyList());
+ public PaymentMethodPlugin getPaymentMethodDetail(final UUID kbAccountId, final UUID kbPaymentMethodId, final Iterable<PluginProperty> properties, final TenantContext context) throws PaymentPluginApiException {
+ return new DefaultNoOpPaymentMethodPlugin(kbPaymentMethodId, "unknown", false, Collections.<PluginProperty>emptyList());
}
@Override
- public void setDefaultPaymentMethod(final UUID kbAccountId, final UUID kbPaymentMethodId, final CallContext context) throws PaymentPluginApiException {
+ public void setDefaultPaymentMethod(final UUID kbAccountId, final UUID kbPaymentMethodId, final Iterable<PluginProperty> properties, final CallContext context) throws PaymentPluginApiException {
}
@Override
- public List<PaymentMethodInfoPlugin> getPaymentMethods(final UUID kbAccountId, final boolean refreshFromGateway, final CallContext context) throws PaymentPluginApiException {
+ public List<PaymentMethodInfoPlugin> getPaymentMethods(final UUID kbAccountId, final boolean refreshFromGateway, final Iterable<PluginProperty> properties, final CallContext context) throws PaymentPluginApiException {
return ImmutableList.<PaymentMethodInfoPlugin>of();
}
@Override
- public Pagination<PaymentMethodPlugin> searchPaymentMethods(final String searchKey, final Long offset, final Long limit, final TenantContext tenantContext) throws PaymentPluginApiException {
+ public Pagination<PaymentMethodPlugin> searchPaymentMethods(final String searchKey, final Long offset, final Long limit, final Iterable<PluginProperty> properties, final TenantContext tenantContext) throws PaymentPluginApiException {
return new DefaultPagination<PaymentMethodPlugin>(offset, limit, 0L, 0L, Iterators.<PaymentMethodPlugin>emptyIterator());
}
@Override
- public void resetPaymentMethods(final UUID kbAccountId, final List<PaymentMethodInfoPlugin> paymentMethods) throws PaymentPluginApiException {
+ public void resetPaymentMethods(final UUID kbAccountId, final List<PaymentMethodInfoPlugin> paymentMethods, final Iterable<PluginProperty> properties) throws PaymentPluginApiException {
}
@Override
- public HostedPaymentPageFormDescriptor buildFormDescriptor(final UUID uuid, final HostedPaymentPageDescriptorFields hostedPaymentPageDescriptorFields, final TenantContext tenantContext) {
+ public HostedPaymentPageFormDescriptor buildFormDescriptor(final UUID kbAccountId, final HostedPaymentPageDescriptorFields hostedPaymentPageDescriptorFields, final Iterable<PluginProperty> properties, final TenantContext tenantContext) {
return null;
}
@Override
- public HostedPaymentPageNotification processNotification(final String s, final TenantContext tenantContext) throws PaymentPluginApiException {
+ public HostedPaymentPageNotification processNotification(final String notification, final Iterable<PluginProperty> properties, final TenantContext tenantContext) throws PaymentPluginApiException {
return null;
}
}
diff --git a/payment/src/test/java/org/killbill/billing/payment/api/TestPaymentMethodPlugin.java b/payment/src/test/java/org/killbill/billing/payment/api/TestPaymentMethodPlugin.java
index b393341..1280407 100644
--- a/payment/src/test/java/org/killbill/billing/payment/api/TestPaymentMethodPlugin.java
+++ b/payment/src/test/java/org/killbill/billing/payment/api/TestPaymentMethodPlugin.java
@@ -1,7 +1,9 @@
/*
* Copyright 2010-2013 Ning, Inc.
+ * Copyright 2014 Groupon, Inc
+ * Copyright 2014 The Billing Project, LLC
*
- * Ning licenses this file to you under the Apache License, version 2.0
+ * The Billing Project licenses this file to you under the Apache License, version 2.0
* (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
*
@@ -24,7 +26,7 @@ public class TestPaymentMethodPlugin extends TestPaymentMethodPluginBase impleme
private final UUID kbPaymentMethodId;
private final String externalPaymentMethodId;
private final boolean isDefaultPaymentMethod;
- private final List<PaymentMethodKVInfo> properties;
+ private final List<PluginProperty> properties;
public TestPaymentMethodPlugin(final UUID kbPaymentMethodId, final PaymentMethodPlugin src, final String externalPaymentId) {
this.kbPaymentMethodId = kbPaymentMethodId;
@@ -49,7 +51,7 @@ public class TestPaymentMethodPlugin extends TestPaymentMethodPluginBase impleme
}
@Override
- public List<PaymentMethodKVInfo> getProperties() {
+ public List<PluginProperty> getProperties() {
return properties;
}
}
diff --git a/payment/src/test/java/org/killbill/billing/payment/core/TestPaymentMethodProcessorRefreshWithDB.java b/payment/src/test/java/org/killbill/billing/payment/core/TestPaymentMethodProcessorRefreshWithDB.java
index b4b4bd9..99ade9c 100644
--- a/payment/src/test/java/org/killbill/billing/payment/core/TestPaymentMethodProcessorRefreshWithDB.java
+++ b/payment/src/test/java/org/killbill/billing/payment/core/TestPaymentMethodProcessorRefreshWithDB.java
@@ -1,7 +1,9 @@
/*
* Copyright 2010-2013 Ning, Inc.
+ * Copyright 2014 Groupon, Inc
+ * Copyright 2014 The Billing Project, LLC
*
- * Ning licenses this file to you under the Apache License, version 2.0
+ * The Billing Project licenses this file to you under the Apache License, version 2.0
* (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
*
@@ -19,40 +21,39 @@ package org.killbill.billing.payment.core;
import java.util.List;
import java.util.UUID;
-import org.testng.Assert;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
import org.killbill.billing.account.api.Account;
import org.killbill.billing.payment.PaymentTestSuiteWithEmbeddedDB;
import org.killbill.billing.payment.api.PaymentMethod;
-import org.killbill.billing.payment.api.PaymentMethodKVInfo;
+import org.killbill.billing.payment.api.PluginProperty;
import org.killbill.billing.payment.dao.PaymentMethodModelDao;
import org.killbill.billing.payment.plugin.api.PaymentPluginApi;
import org.killbill.billing.payment.provider.DefaultNoOpPaymentMethodPlugin;
import org.killbill.billing.payment.provider.MockPaymentProviderPlugin;
+import org.testng.Assert;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
import com.google.common.collect.ImmutableList;
public class TestPaymentMethodProcessorRefreshWithDB extends PaymentTestSuiteWithEmbeddedDB {
-
@BeforeMethod(groups = "slow")
public void beforeMethod() throws Exception {
super.beforeMethod();
- getPluginApi().resetPaymentMethods(null, null);
+ getPluginApi().resetPaymentMethods(null, null, ImmutableList.<PluginProperty>of());
}
@Test(groups = "slow")
public void testRefreshWithNewPaymentMethod() throws Exception {
+ final ImmutableList<PluginProperty> pluginProperties = ImmutableList.<PluginProperty>of();
final Account account = testHelper.createTestAccount("foo@bar.com", true);
- Assert.assertEquals(getPluginApi().getPaymentMethods(account.getId(), true, callContext).size(), 1);
+ Assert.assertEquals(getPluginApi().getPaymentMethods(account.getId(), true, pluginProperties, callContext).size(), 1);
final UUID existingPMId = account.getPaymentMethodId();
// Add new payment in plugin directly
final UUID newPmId = UUID.randomUUID();
- getPluginApi().addPaymentMethod(account.getId(), newPmId, new DefaultNoOpPaymentMethodPlugin(UUID.randomUUID().toString(), false, ImmutableList.<PaymentMethodKVInfo>of()), false, callContext);
+ getPluginApi().addPaymentMethod(account.getId(), newPmId, new DefaultNoOpPaymentMethodPlugin(UUID.randomUUID().toString(), false, ImmutableList.<PluginProperty>of()), false, pluginProperties, callContext);
// Verify that the refresh does indeed show 2 PMs
final List<PaymentMethod> methods = paymentMethodProcessor.refreshPaymentMethods(MockPaymentProviderPlugin.PLUGIN_NAME, account, internalCallContext);
@@ -61,21 +62,21 @@ public class TestPaymentMethodProcessorRefreshWithDB extends PaymentTestSuiteWit
checkPaymentMethodExistsWithStatus(methods, newPmId, true);
}
-
@Test(groups = "slow")
public void testRefreshWithDeletedPaymentMethod() throws Exception {
+ final ImmutableList<PluginProperty> pluginProperties = ImmutableList.<PluginProperty>of();
final Account account = testHelper.createTestAccount("super@bar.com", true);
- Assert.assertEquals(getPluginApi().getPaymentMethods(account.getId(), true, callContext).size(), 1);
+ Assert.assertEquals(getPluginApi().getPaymentMethods(account.getId(), true, pluginProperties, callContext).size(), 1);
final UUID firstPmId = account.getPaymentMethodId();
final UUID secondPmId = paymentApi.addPaymentMethod(MockPaymentProviderPlugin.PLUGIN_NAME, account, true, new DefaultNoOpPaymentMethodPlugin(UUID.randomUUID().toString(), false, null), callContext);
- Assert.assertEquals(getPluginApi().getPaymentMethods(account.getId(), true, callContext).size(), 2);
+ Assert.assertEquals(getPluginApi().getPaymentMethods(account.getId(), true, pluginProperties, callContext).size(), 2);
Assert.assertEquals(paymentApi.getPaymentMethods(account, false, callContext).size(), 2);
// Remove second PM from plugin
- getPluginApi().deletePaymentMethod(account.getId(), secondPmId, callContext);
- Assert.assertEquals(getPluginApi().getPaymentMethods(account.getId(), true, callContext).size(), 1);
+ getPluginApi().deletePaymentMethod(account.getId(), secondPmId, pluginProperties, callContext);
+ Assert.assertEquals(getPluginApi().getPaymentMethods(account.getId(), true, pluginProperties, callContext).size(), 1);
Assert.assertEquals(paymentApi.getPaymentMethods(account, false, callContext).size(), 2);
// Verify that the refresh sees that PM as being deleted now
@@ -83,15 +84,14 @@ public class TestPaymentMethodProcessorRefreshWithDB extends PaymentTestSuiteWit
Assert.assertEquals(methods.size(), 1);
checkPaymentMethodExistsWithStatus(methods, firstPmId, true);
- PaymentMethodModelDao deletedPMModel = paymentDao.getPaymentMethodIncludedDeleted(secondPmId, internalCallContext);
+ final PaymentMethodModelDao deletedPMModel = paymentDao.getPaymentMethodIncludedDeleted(secondPmId, internalCallContext);
Assert.assertNotNull(deletedPMModel);
Assert.assertFalse(deletedPMModel.isActive());
}
-
- private void checkPaymentMethodExistsWithStatus(final List<PaymentMethod> methods, UUID expectedPaymentMethodId, boolean expectedActive) {
+ private void checkPaymentMethodExistsWithStatus(final List<PaymentMethod> methods, final UUID expectedPaymentMethodId, final boolean expectedActive) {
PaymentMethod foundPM = null;
- for (PaymentMethod cur : methods) {
+ for (final PaymentMethod cur : methods) {
if (cur.getId().equals(expectedPaymentMethodId)) {
foundPM = cur;
break;
@@ -101,7 +101,6 @@ public class TestPaymentMethodProcessorRefreshWithDB extends PaymentTestSuiteWit
Assert.assertEquals(foundPM.isActive().booleanValue(), expectedActive);
}
-
private PaymentPluginApi getPluginApi() {
final PaymentPluginApi pluginApi = registry.getServiceForName(MockPaymentProviderPlugin.PLUGIN_NAME);
Assert.assertNotNull(pluginApi);
diff --git a/payment/src/test/java/org/killbill/billing/payment/provider/MockPaymentProviderPlugin.java b/payment/src/test/java/org/killbill/billing/payment/provider/MockPaymentProviderPlugin.java
index e2341ac..665108d 100644
--- a/payment/src/test/java/org/killbill/billing/payment/provider/MockPaymentProviderPlugin.java
+++ b/payment/src/test/java/org/killbill/billing/payment/provider/MockPaymentProviderPlugin.java
@@ -1,7 +1,9 @@
/*
* Copyright 2010-2013 Ning, Inc.
+ * Copyright 2014 Groupon, Inc
+ * Copyright 2014 The Billing Project, LLC
*
- * Ning licenses this file to you under the Apache License, version 2.0
+ * The Billing Project licenses this file to you under the Apache License, version 2.0
* (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
*
@@ -26,6 +28,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
import org.killbill.billing.catalog.api.Currency;
import org.killbill.billing.payment.api.PaymentMethodPlugin;
+import org.killbill.billing.payment.api.PluginProperty;
import org.killbill.billing.payment.api.TestPaymentMethodPlugin;
import org.killbill.billing.payment.plugin.api.HostedPaymentPageDescriptorFields;
import org.killbill.billing.payment.plugin.api.HostedPaymentPageFormDescriptor;
@@ -52,7 +55,7 @@ import com.google.inject.Inject;
/**
* This MockPaymentProviderPlugin only works for a single accounts as we don't specify the accountId
- * for opeartions such as addPaymentMethod.
+ * for operations such as addPaymentMethod.
*/
public class MockPaymentProviderPlugin implements NoOpPaymentPluginApi {
@@ -99,30 +102,30 @@ public class MockPaymentProviderPlugin implements NoOpPaymentPluginApi {
}
@Override
- public PaymentInfoPlugin authorizePayment(UUID kbAccountId, UUID kbPaymentId, UUID kbPaymentMethodId, BigDecimal amount, Currency currency, CallContext context)
+ public PaymentInfoPlugin authorizePayment(final UUID kbAccountId, final UUID kbPaymentId, final UUID kbPaymentMethodId, final BigDecimal amount, final Currency currency, final Iterable<PluginProperty> properties, final CallContext context)
throws PaymentPluginApiException {
return getPaymentInfoPluginResult(kbPaymentId, amount, currency);
}
@Override
- public PaymentInfoPlugin capturePayment(UUID kbAccountId, UUID kbPaymentId, UUID kbPaymentMethodId, BigDecimal amount, Currency currency, CallContext context)
+ public PaymentInfoPlugin capturePayment(final UUID kbAccountId, final UUID kbPaymentId, final UUID kbPaymentMethodId, final BigDecimal amount, final Currency currency, final Iterable<PluginProperty> properties, final CallContext context)
throws PaymentPluginApiException {
return getPaymentInfoPluginResult(kbPaymentId, amount, currency);
}
@Override
- public PaymentInfoPlugin processPayment(final UUID kbAccountId, final UUID kbPaymentId, final UUID kbPaymentMethodId, final BigDecimal amount, final Currency currency, final CallContext context) throws PaymentPluginApiException {
+ public PaymentInfoPlugin processPayment(final UUID kbAccountId, final UUID kbPaymentId, final UUID kbPaymentMethodId, final BigDecimal amount, final Currency currency, final Iterable<PluginProperty> properties, final CallContext context) throws PaymentPluginApiException {
return getPaymentInfoPluginResult(kbPaymentId, amount, currency);
}
@Override
- public PaymentInfoPlugin voidPayment(UUID kbAccountId, UUID kbPaymentId, UUID kbPaymentMethodId, CallContext context)
+ public PaymentInfoPlugin voidPayment(final UUID kbAccountId, final UUID kbPaymentId, final UUID kbPaymentMethodId, final Iterable<PluginProperty> properties, final CallContext context)
throws PaymentPluginApiException {
return getPaymentInfoPluginResult(kbPaymentId, BigDecimal.ZERO, null);
}
@Override
- public PaymentInfoPlugin getPaymentInfo(final UUID kbAccountId, final UUID kbPaymentId, final TenantContext context) throws PaymentPluginApiException {
+ public PaymentInfoPlugin getPaymentInfo(final UUID kbAccountId, final UUID kbPaymentId, final Iterable<PluginProperty> properties, final TenantContext context) throws PaymentPluginApiException {
final PaymentInfoPlugin payment = payments.get(kbPaymentId.toString());
if (payment == null) {
throw new PaymentPluginApiException("", "No payment found for payment id " + kbPaymentId.toString());
@@ -131,7 +134,7 @@ public class MockPaymentProviderPlugin implements NoOpPaymentPluginApi {
}
@Override
- public Pagination<PaymentInfoPlugin> searchPayments(final String searchKey, final Long offset, final Long limit, final TenantContext tenantContext) throws PaymentPluginApiException {
+ public Pagination<PaymentInfoPlugin> searchPayments(final String searchKey, final Long offset, final Long limit, final Iterable<PluginProperty> properties, final TenantContext tenantContext) throws PaymentPluginApiException {
final ImmutableList<PaymentInfoPlugin> results = ImmutableList.<PaymentInfoPlugin>copyOf(Iterables.<PaymentInfoPlugin>filter(payments.values(), new Predicate<PaymentInfoPlugin>() {
@Override
public boolean apply(final PaymentInfoPlugin input) {
@@ -144,7 +147,7 @@ public class MockPaymentProviderPlugin implements NoOpPaymentPluginApi {
}
@Override
- public void addPaymentMethod(final UUID kbAccountId, final UUID kbPaymentMethodId, final PaymentMethodPlugin paymentMethodProps, final boolean setDefault, final CallContext context) throws PaymentPluginApiException {
+ public void addPaymentMethod(final UUID kbAccountId, final UUID kbPaymentMethodId, final PaymentMethodPlugin paymentMethodProps, final boolean setDefault, final Iterable<PluginProperty> properties, final CallContext context) throws PaymentPluginApiException {
// externalPaymentMethodId is set to a random value
final PaymentMethodPlugin realWithID = new TestPaymentMethodPlugin(kbPaymentMethodId, paymentMethodProps, UUID.randomUUID().toString());
paymentMethods.put(kbPaymentMethodId.toString(), realWithID);
@@ -154,27 +157,27 @@ public class MockPaymentProviderPlugin implements NoOpPaymentPluginApi {
}
@Override
- public void deletePaymentMethod(final UUID kbAccountId, final UUID kbPaymentMethodId, final CallContext context) throws PaymentPluginApiException {
+ public void deletePaymentMethod(final UUID kbAccountId, final UUID kbPaymentMethodId, final Iterable<PluginProperty> properties, final CallContext context) throws PaymentPluginApiException {
paymentMethods.remove(kbPaymentMethodId.toString());
paymentMethodsInfo.remove(kbPaymentMethodId.toString());
}
@Override
- public PaymentMethodPlugin getPaymentMethodDetail(final UUID kbAccountId, final UUID kbPaymentMethodId, final TenantContext context) throws PaymentPluginApiException {
+ public PaymentMethodPlugin getPaymentMethodDetail(final UUID kbAccountId, final UUID kbPaymentMethodId, final Iterable<PluginProperty> properties, final TenantContext context) throws PaymentPluginApiException {
return paymentMethods.get(kbPaymentMethodId.toString());
}
@Override
- public void setDefaultPaymentMethod(final UUID kbAccountId, final UUID kbPaymentMethodId, final CallContext context) throws PaymentPluginApiException {
+ public void setDefaultPaymentMethod(final UUID kbAccountId, final UUID kbPaymentMethodId, final Iterable<PluginProperty> properties, final CallContext context) throws PaymentPluginApiException {
}
@Override
- public List<PaymentMethodInfoPlugin> getPaymentMethods(final UUID kbAccountId, final boolean refreshFromGateway, final CallContext context) {
+ public List<PaymentMethodInfoPlugin> getPaymentMethods(final UUID kbAccountId, final boolean refreshFromGateway, final Iterable<PluginProperty> properties, final CallContext context) {
return ImmutableList.<PaymentMethodInfoPlugin>copyOf(paymentMethodsInfo.values());
}
@Override
- public Pagination<PaymentMethodPlugin> searchPaymentMethods(final String searchKey, final Long offset, final Long limit, final TenantContext tenantContext) throws PaymentPluginApiException {
+ public Pagination<PaymentMethodPlugin> searchPaymentMethods(final String searchKey, final Long offset, final Long limit, final Iterable<PluginProperty> properties, final TenantContext tenantContext) throws PaymentPluginApiException {
final ImmutableList<PaymentMethodPlugin> results = ImmutableList.<PaymentMethodPlugin>copyOf(Iterables.<PaymentMethodPlugin>filter(paymentMethods.values(), new Predicate<PaymentMethodPlugin>() {
@Override
public boolean apply(final PaymentMethodPlugin input) {
@@ -191,7 +194,7 @@ public class MockPaymentProviderPlugin implements NoOpPaymentPluginApi {
}
@Override
- public void resetPaymentMethods(final UUID kbAccountId, final List<PaymentMethodInfoPlugin> input) {
+ public void resetPaymentMethods(final UUID kbAccountId, final List<PaymentMethodInfoPlugin> input, final Iterable<PluginProperty> properties) {
paymentMethodsInfo.clear();
if (input != null) {
for (final PaymentMethodInfoPlugin cur : input) {
@@ -201,18 +204,18 @@ public class MockPaymentProviderPlugin implements NoOpPaymentPluginApi {
}
@Override
- public HostedPaymentPageFormDescriptor buildFormDescriptor(final UUID uuid, final HostedPaymentPageDescriptorFields hostedPaymentPageDescriptorFields, final TenantContext tenantContext) {
+ public HostedPaymentPageFormDescriptor buildFormDescriptor(final UUID kbAccountId, final HostedPaymentPageDescriptorFields hostedPaymentPageDescriptorFields, final Iterable<PluginProperty> properties, final TenantContext tenantContext) {
return null;
}
@Override
- public HostedPaymentPageNotification processNotification(final String s, final TenantContext tenantContext) throws PaymentPluginApiException {
+ public HostedPaymentPageNotification processNotification(final String notification, final Iterable<PluginProperty> properties, final TenantContext tenantContext) throws PaymentPluginApiException {
return null;
}
@Override
- public RefundInfoPlugin processRefund(final UUID kbAccountId, final UUID kbPaymentId, final BigDecimal refundAmount, final Currency currency, final CallContext context) throws PaymentPluginApiException {
- final PaymentInfoPlugin paymentInfoPlugin = getPaymentInfo(kbAccountId, kbPaymentId, context);
+ public RefundInfoPlugin processRefund(final UUID kbAccountId, final UUID kbPaymentId, final BigDecimal refundAmount, final Currency currency, final Iterable<PluginProperty> properties, final CallContext context) throws PaymentPluginApiException {
+ final PaymentInfoPlugin paymentInfoPlugin = getPaymentInfo(kbAccountId, kbPaymentId, properties, context);
if (paymentInfoPlugin == null) {
throw new PaymentPluginApiException("", String.format("No payment found for payment id %s (plugin %s)", kbPaymentId.toString(), PLUGIN_NAME));
}
@@ -233,12 +236,12 @@ public class MockPaymentProviderPlugin implements NoOpPaymentPluginApi {
}
@Override
- public List<RefundInfoPlugin> getRefundInfo(final UUID kbAccountId, final UUID kbPaymentId, final TenantContext context) throws PaymentPluginApiException {
+ public List<RefundInfoPlugin> getRefundInfo(final UUID kbAccountId, final UUID kbPaymentId, final Iterable<PluginProperty> properties, final TenantContext context) throws PaymentPluginApiException {
return Collections.<RefundInfoPlugin>emptyList();
}
@Override
- public Pagination<RefundInfoPlugin> searchRefunds(final String searchKey, final Long offset, final Long limit, final TenantContext tenantContext) throws PaymentPluginApiException {
+ public Pagination<RefundInfoPlugin> searchRefunds(final String searchKey, final Long offset, final Long limit, final Iterable<PluginProperty> properties, final TenantContext tenantContext) throws PaymentPluginApiException {
final ImmutableList<RefundInfoPlugin> results = ImmutableList.<RefundInfoPlugin>copyOf(Iterables.<RefundInfoPlugin>filter(refunds.values(), new Predicate<RefundInfoPlugin>() {
@Override
public boolean apply(final RefundInfoPlugin input) {
diff --git a/payment/src/test/java/org/killbill/billing/payment/provider/TestDefaultNoOpPaymentMethodPlugin.java b/payment/src/test/java/org/killbill/billing/payment/provider/TestDefaultNoOpPaymentMethodPlugin.java
index 566cf50..04808e4 100644
--- a/payment/src/test/java/org/killbill/billing/payment/provider/TestDefaultNoOpPaymentMethodPlugin.java
+++ b/payment/src/test/java/org/killbill/billing/payment/provider/TestDefaultNoOpPaymentMethodPlugin.java
@@ -1,7 +1,9 @@
/*
* Copyright 2010-2013 Ning, Inc.
+ * Copyright 2014 Groupon, Inc
+ * Copyright 2014 The Billing Project, LLC
*
- * Ning licenses this file to you under the Apache License, version 2.0
+ * The Billing Project licenses this file to you under the Apache License, version 2.0
* (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
*
@@ -19,12 +21,11 @@ package org.killbill.billing.payment.provider;
import java.util.List;
import java.util.UUID;
+import org.killbill.billing.payment.PaymentTestSuiteNoDB;
+import org.killbill.billing.payment.api.PluginProperty;
import org.testng.Assert;
import org.testng.annotations.Test;
-import org.killbill.billing.payment.PaymentTestSuiteNoDB;
-import org.killbill.billing.payment.api.PaymentMethodKVInfo;
-
import com.google.common.collect.ImmutableList;
public class TestDefaultNoOpPaymentMethodPlugin extends PaymentTestSuiteNoDB {
@@ -33,7 +34,7 @@ public class TestDefaultNoOpPaymentMethodPlugin extends PaymentTestSuiteNoDB {
public void testEquals() throws Exception {
final String externalId = UUID.randomUUID().toString();
final boolean isDefault = false;
- final List<PaymentMethodKVInfo> props = ImmutableList.<PaymentMethodKVInfo>of(new PaymentMethodKVInfo(UUID.randomUUID().toString(), UUID.randomUUID().toString(), false));
+ final List<PluginProperty> props = ImmutableList.<PluginProperty>of(new PluginProperty(UUID.randomUUID().toString(), UUID.randomUUID().toString(), false));
final DefaultNoOpPaymentMethodPlugin paymentMethod = new DefaultNoOpPaymentMethodPlugin(externalId, isDefault, props);
Assert.assertEquals(paymentMethod, paymentMethod);
@@ -41,23 +42,23 @@ public class TestDefaultNoOpPaymentMethodPlugin extends PaymentTestSuiteNoDB {
final DefaultNoOpPaymentMethodPlugin samePaymentMethod = new DefaultNoOpPaymentMethodPlugin(externalId, isDefault, props);
Assert.assertEquals(samePaymentMethod, paymentMethod);
- final DefaultNoOpPaymentMethodPlugin otherPaymentMethod = new DefaultNoOpPaymentMethodPlugin(externalId, isDefault, ImmutableList.<PaymentMethodKVInfo>of());
+ final DefaultNoOpPaymentMethodPlugin otherPaymentMethod = new DefaultNoOpPaymentMethodPlugin(externalId, isDefault, ImmutableList.<PluginProperty>of());
Assert.assertNotEquals(otherPaymentMethod, paymentMethod);
}
@Test(groups = "fast")
- public void testEqualsForPaymentMethodKVInfo() throws Exception {
+ public void testEqualsForPluginProperty() throws Exception {
final String key = UUID.randomUUID().toString();
final Object value = UUID.randomUUID();
final boolean updatable = false;
- final PaymentMethodKVInfo kvInfo = new PaymentMethodKVInfo(key, value, updatable);
+ final PluginProperty kvInfo = new PluginProperty(key, value, updatable);
Assert.assertEquals(kvInfo, kvInfo);
- final PaymentMethodKVInfo sameKvInfo = new PaymentMethodKVInfo(key, value, updatable);
+ final PluginProperty sameKvInfo = new PluginProperty(key, value, updatable);
Assert.assertEquals(sameKvInfo, kvInfo);
- final PaymentMethodKVInfo otherKvInfo = new PaymentMethodKVInfo(key, value, !updatable);
+ final PluginProperty otherKvInfo = new PluginProperty(key, value, !updatable);
Assert.assertNotEquals(otherKvInfo, kvInfo);
}
}
diff --git a/payment/src/test/java/org/killbill/billing/payment/provider/TestExternalPaymentProviderPlugin.java b/payment/src/test/java/org/killbill/billing/payment/provider/TestExternalPaymentProviderPlugin.java
index fe00cea..2bb455e 100644
--- a/payment/src/test/java/org/killbill/billing/payment/provider/TestExternalPaymentProviderPlugin.java
+++ b/payment/src/test/java/org/killbill/billing/payment/provider/TestExternalPaymentProviderPlugin.java
@@ -1,7 +1,9 @@
/*
* Copyright 2010-2013 Ning, Inc.
+ * Copyright 2014 Groupon, Inc
+ * Copyright 2014 The Billing Project, LLC
*
- * Ning licenses this file to you under the Apache License, version 2.0
+ * The Billing Project licenses this file to you under the Apache License, version 2.0
* (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
*
@@ -17,21 +19,21 @@
package org.killbill.billing.payment.provider;
import java.math.BigDecimal;
+import java.util.List;
import java.util.UUID;
-import org.mockito.Mockito;
-import org.testng.Assert;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import org.killbill.billing.account.api.Account;
import org.killbill.billing.catalog.api.Currency;
import org.killbill.billing.payment.PaymentTestSuiteNoDB;
+import org.killbill.billing.payment.api.PluginProperty;
import org.killbill.billing.payment.plugin.api.PaymentInfoPlugin;
import org.killbill.billing.payment.plugin.api.PaymentPluginStatus;
-import org.killbill.billing.payment.plugin.api.PaymentPluginApiException;
import org.killbill.clock.Clock;
import org.killbill.clock.ClockMock;
+import org.testng.Assert;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
public class TestExternalPaymentProviderPlugin extends PaymentTestSuiteNoDB {
@@ -45,22 +47,21 @@ public class TestExternalPaymentProviderPlugin extends PaymentTestSuiteNoDB {
plugin = new ExternalPaymentProviderPlugin(clock);
}
-
@Test(groups = "fast")
public void testProcessPayment() throws Exception {
-
+ final List<PluginProperty> properties = ImmutableList.<PluginProperty>of();
final UUID accountId = UUID.randomUUID();
final UUID paymentId = UUID.randomUUID();
final UUID paymentMethodId = UUID.randomUUID();
final BigDecimal amount = BigDecimal.TEN;
- final PaymentInfoPlugin paymentInfoPlugin = plugin.processPayment(accountId, paymentId, paymentMethodId, amount, Currency.BRL, callContext);
+ final PaymentInfoPlugin paymentInfoPlugin = plugin.processPayment(accountId, paymentId, paymentMethodId, amount, Currency.BRL, properties, callContext);
Assert.assertEquals(paymentInfoPlugin.getAmount(), amount);
Assert.assertNull(paymentInfoPlugin.getGatewayError());
Assert.assertNull(paymentInfoPlugin.getGatewayErrorCode());
Assert.assertEquals(paymentInfoPlugin.getStatus(), PaymentPluginStatus.PROCESSED);
- final PaymentInfoPlugin retrievedPaymentInfoPlugin = plugin.getPaymentInfo(accountId, paymentId, callContext);
+ final PaymentInfoPlugin retrievedPaymentInfoPlugin = plugin.getPaymentInfo(accountId, paymentId, properties, callContext);
Assert.assertEquals(retrievedPaymentInfoPlugin.getStatus(), PaymentPluginStatus.PROCESSED);
}
}
pom.xml 2(+1 -1)
diff --git a/pom.xml b/pom.xml
index 7f85a63..0f5373e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -19,7 +19,7 @@
<parent>
<artifactId>killbill-oss-parent</artifactId>
<groupId>org.kill-bill.billing</groupId>
- <version>0.7.0</version>
+ <version>0.7.1</version>
</parent>
<artifactId>killbill</artifactId>
<version>0.11.2-SNAPSHOT</version>
diff --git a/util/src/test/java/org/killbill/billing/payment/api/TestPaymentMethodPluginBase.java b/util/src/test/java/org/killbill/billing/payment/api/TestPaymentMethodPluginBase.java
index 8e96363..4515bb9 100644
--- a/util/src/test/java/org/killbill/billing/payment/api/TestPaymentMethodPluginBase.java
+++ b/util/src/test/java/org/killbill/billing/payment/api/TestPaymentMethodPluginBase.java
@@ -1,7 +1,9 @@
/*
* Copyright 2010-2013 Ning, Inc.
+ * Copyright 2014 Groupon, Inc
+ * Copyright 2014 The Billing Project, LLC
*
- * Ning licenses this file to you under the Apache License, version 2.0
+ * The Billing Project licenses this file to you under the Apache License, version 2.0
* (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
*
@@ -99,7 +101,7 @@ public class TestPaymentMethodPluginBase implements PaymentMethodPlugin {
}
@Override
- public List<PaymentMethodKVInfo> getProperties() {
- return ImmutableList.<PaymentMethodKVInfo>of();
+ public List<PluginProperty> getProperties() {
+ return ImmutableList.<PluginProperty>of();
}
}