killbill-memoizeit
Changes
beatrix/src/test/java/com/ning/billing/beatrix/integration/osgi/TestBasicOSGIWithTestBundle.java 3(+2 -1)
beatrix/src/test/java/com/ning/billing/beatrix/integration/osgi/TestJrubyPaymentPlugin.java 11(+6 -5)
beatrix/src/test/java/com/ning/billing/beatrix/integration/osgi/TestPaymentOSGIWithTestPaymentBundle.java 6(+3 -3)
osgi-bundles/bundles/jruby/src/main/java/com/ning/billing/osgi/bundles/jruby/JRubyPaymentPlugin.java 25(+13 -12)
osgi-bundles/tests/beatrix/src/test/java/com/ning/billing/osgi/bundles/test/TestPaymentPluginApi.java 13(+7 -6)
osgi-bundles/tests/payment/src/test/java/com/ning/billing/osgi/bundles/test/TestPaymentPluginApi.java 13(+7 -6)
payment/src/main/java/com/ning/billing/payment/provider/DefaultNoOpPaymentProviderPlugin.java 15(+8 -7)
Details
diff --git a/api/src/main/java/com/ning/billing/payment/plugin/api/PaymentPluginApi.java b/api/src/main/java/com/ning/billing/payment/plugin/api/PaymentPluginApi.java
index 0a0815b..200be59 100644
--- a/api/src/main/java/com/ning/billing/payment/plugin/api/PaymentPluginApi.java
+++ b/api/src/main/java/com/ning/billing/payment/plugin/api/PaymentPluginApi.java
@@ -20,6 +20,7 @@ import java.math.BigDecimal;
import java.util.List;
import java.util.UUID;
+import com.ning.billing.catalog.api.Currency;
import com.ning.billing.payment.api.PaymentMethodPlugin;
import com.ning.billing.util.callcontext.CallContext;
import com.ning.billing.util.callcontext.TenantContext;
@@ -34,39 +35,44 @@ public interface PaymentPluginApi {
/**
* Charge a specific amount in the Gateway. Required.
*
- * @param kbPaymentId killbill payment id (for reference)
- * @param kbPaymentMethodId killbill payment method id
- * @param amount amount to charge
- * @param context call context
+ * @param kbAccountId killbill accountId
+ * @param kbPaymentId killbill payment id (for reference)
+ * @param kbPaymentMethodId killbill payment method id
+ * @param amount amount to charge
+ * @param currency currency
+ * @param context call context
* @return information about the payment in the gateway
* @throws PaymentPluginApiException
*/
- public PaymentInfoPlugin processPayment(UUID kbPaymentId, UUID kbPaymentMethodId, BigDecimal amount, CallContext context)
+ public PaymentInfoPlugin processPayment(UUID kbAccountId, UUID kbPaymentId, UUID kbPaymentMethodId, BigDecimal amount, Currency currency, CallContext context)
throws PaymentPluginApiException;
/**
* Retrieve information about a given payment. Optional (not all gateways will support it).
*
*
+ * @param kbAccountId killbill accountId
* @param kbPaymentId killbill payment id (for reference)
* @param context call context
* @return information about the payment in the gateway
* @throws PaymentPluginApiException
*/
- public PaymentInfoPlugin getPaymentInfo(UUID kbPaymentId, TenantContext context)
+ public PaymentInfoPlugin getPaymentInfo(UUID kbAccountId, UUID kbPaymentId, TenantContext context)
throws PaymentPluginApiException;
/**
* Process a refund against a given payment. Required.
*
*
+ * @param kbAccountId killbill accountId
* @param kbPaymentId killbill payment id (for reference)
- * @param refundAmount call context
+ * @param refundAmount refund amount
+ * @param currency currency
* @param context call context
* @return information about the refund in the gateway
* @throws PaymentPluginApiException
*/
- public RefundInfoPlugin processRefund(UUID kbPaymentId, BigDecimal refundAmount, CallContext context)
+ public RefundInfoPlugin processRefund(UUID kbAccountId, UUID kbPaymentId, BigDecimal refundAmount, Currency currency, CallContext context)
throws PaymentPluginApiException;
/**
@@ -87,11 +93,12 @@ public interface PaymentPluginApi {
/**
* Delete a payment method in the gateway. Optional.
*
+ * @param kbAccountId killbill accountId
* @param kbPaymentMethodId killbill payment method id
* @param context call context
* @throws PaymentPluginApiException
*/
- public void deletePaymentMethod(UUID kbPaymentMethodId, CallContext context)
+ public void deletePaymentMethod(UUID kbAccountId, UUID kbPaymentMethodId, CallContext context)
throws PaymentPluginApiException;
/**
@@ -109,11 +116,12 @@ public interface PaymentPluginApi {
/**
* Set a payment method as default in the gateway. Optional.
*
+ * @param kbAccountId killbill accountId
* @param kbPaymentMethodId killbill payment method id
* @param context call context
* @throws PaymentPluginApiException
*/
- public void setDefaultPaymentMethod(UUID kbPaymentMethodId, CallContext context)
+ public void setDefaultPaymentMethod(UUID kbAccountId, UUID kbPaymentMethodId, CallContext context)
throws PaymentPluginApiException;
/**
@@ -135,8 +143,9 @@ public interface PaymentPluginApi {
/**
* This is used after Killbill decided to refresh its state from the gateway
*
+ * @param kbAccountId killbill accountId
* @param paymentMethods the list of payment methods
*/
- public void resetPaymentMethods(List<PaymentMethodInfoPlugin> paymentMethods)
+ public void resetPaymentMethods(UUID kbAccountId, List<PaymentMethodInfoPlugin> paymentMethods)
throws PaymentPluginApiException;
}
diff --git a/beatrix/src/test/java/com/ning/billing/beatrix/integration/osgi/TestBasicOSGIWithTestBundle.java b/beatrix/src/test/java/com/ning/billing/beatrix/integration/osgi/TestBasicOSGIWithTestBundle.java
index f89fe31..a3de7a6 100644
--- a/beatrix/src/test/java/com/ning/billing/beatrix/integration/osgi/TestBasicOSGIWithTestBundle.java
+++ b/beatrix/src/test/java/com/ning/billing/beatrix/integration/osgi/TestBasicOSGIWithTestBundle.java
@@ -39,6 +39,7 @@ import org.testng.annotations.Test;
import com.ning.billing.account.api.Account;
import com.ning.billing.beatrix.osgi.SetupBundleWithAssertion;
+import com.ning.billing.catalog.api.Currency;
import com.ning.billing.dbi.DBTestingHelper;
import com.ning.billing.osgi.api.OSGIServiceRegistration;
import com.ning.billing.osgi.glue.OSGIDataSourceConfig;
@@ -102,7 +103,7 @@ 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(paymentId, account.getPaymentMethodId(), paymentAmount, callContext);
+ final PaymentInfoPlugin r = paymentPluginApi.processPayment(account.getId(), paymentId, account.getPaymentMethodId(), paymentAmount, Currency.USD, callContext);
assertTor.assertPluginCreatedPayment(paymentId, account.getPaymentMethodId(), paymentAmount);
}
diff --git a/beatrix/src/test/java/com/ning/billing/beatrix/integration/osgi/TestJrubyPaymentPlugin.java b/beatrix/src/test/java/com/ning/billing/beatrix/integration/osgi/TestJrubyPaymentPlugin.java
index 9a552ac..9e5dd93 100644
--- a/beatrix/src/test/java/com/ning/billing/beatrix/integration/osgi/TestJrubyPaymentPlugin.java
+++ b/beatrix/src/test/java/com/ning/billing/beatrix/integration/osgi/TestJrubyPaymentPlugin.java
@@ -29,6 +29,7 @@ import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import com.ning.billing.beatrix.osgi.SetupBundleWithAssertion;
+import com.ning.billing.catalog.api.Currency;
import com.ning.billing.osgi.api.OSGIServiceRegistration;
import com.ning.billing.payment.api.PaymentMethodPlugin;
import com.ning.billing.payment.plugin.api.PaymentInfoPlugin;
@@ -67,7 +68,7 @@ public class TestJrubyPaymentPlugin extends TestOSGIBase {
PaymentPluginApi api = getTestPluginPaymentApi();
final DateTime beforeCall = new DateTime().toDateTime(DateTimeZone.UTC).minusSeconds(1);
- PaymentInfoPlugin res = api.processPayment(UUID.randomUUID(), UUID.randomUUID(), BigDecimal.TEN, callContext);
+ PaymentInfoPlugin res = api.processPayment(UUID.randomUUID(), UUID.randomUUID(), UUID.randomUUID(), BigDecimal.TEN, Currency.USD, callContext);
final DateTime afterCall = new DateTime().toDateTime(DateTimeZone.UTC).plusSeconds(1);
@@ -90,7 +91,7 @@ public class TestJrubyPaymentPlugin extends TestOSGIBase {
PaymentPluginApi api = getTestPluginPaymentApi();
final DateTime beforeCall = new DateTime().toDateTime(DateTimeZone.UTC).minusSeconds(1);
- PaymentInfoPlugin res = api.getPaymentInfo(UUID.randomUUID(), callContext);
+ PaymentInfoPlugin res = api.getPaymentInfo(UUID.randomUUID(), UUID.randomUUID(), callContext);
final DateTime afterCall = new DateTime().toDateTime(DateTimeZone.UTC).plusSeconds(1);
@@ -114,7 +115,7 @@ public class TestJrubyPaymentPlugin extends TestOSGIBase {
PaymentPluginApi api = getTestPluginPaymentApi();
final DateTime beforeCall = new DateTime().toDateTime(DateTimeZone.UTC).minusSeconds(1);
- RefundInfoPlugin res = api.processRefund(UUID.randomUUID(), BigDecimal.TEN, callContext);
+ RefundInfoPlugin res = api.processRefund(UUID.randomUUID(), UUID.randomUUID(), BigDecimal.TEN, Currency.USD, callContext);
final DateTime afterCall = new DateTime().toDateTime(DateTimeZone.UTC).plusSeconds(1);
@@ -147,7 +148,7 @@ public class TestJrubyPaymentPlugin extends TestOSGIBase {
public void testDeletePaymentMethod() throws Exception {
PaymentPluginApi api = getTestPluginPaymentApi();
- api.deletePaymentMethod(UUID.randomUUID(), callContext);
+ api.deletePaymentMethod(UUID.randomUUID(), UUID.randomUUID(), callContext);
}
@Test(groups = "slow", enabled = true)
@@ -166,7 +167,7 @@ public class TestJrubyPaymentPlugin extends TestOSGIBase {
PaymentPluginApi api = getTestPluginPaymentApi();
final PaymentMethodPlugin info = createPaymentMethodPlugin();
- api.setDefaultPaymentMethod(UUID.randomUUID(), callContext);
+ api.setDefaultPaymentMethod(UUID.randomUUID(), UUID.randomUUID(), callContext);
}
@Test(groups = "slow", enabled = true)
diff --git a/beatrix/src/test/java/com/ning/billing/beatrix/integration/osgi/TestPaymentOSGIWithTestPaymentBundle.java b/beatrix/src/test/java/com/ning/billing/beatrix/integration/osgi/TestPaymentOSGIWithTestPaymentBundle.java
index 5a8d2a2..1fb576e 100644
--- a/beatrix/src/test/java/com/ning/billing/beatrix/integration/osgi/TestPaymentOSGIWithTestPaymentBundle.java
+++ b/beatrix/src/test/java/com/ning/billing/beatrix/integration/osgi/TestPaymentOSGIWithTestPaymentBundle.java
@@ -77,7 +77,7 @@ public class TestPaymentOSGIWithTestPaymentBundle extends TestOSGIBase {
@Test(groups = "slow")
public void testBasicProcessPaymentOK() throws Exception {
final PaymentPluginApiWithTestControl paymentPluginApi = getTestPluginPaymentApi();
- paymentPluginApi.processPayment(UUID.randomUUID(), UUID.randomUUID(), BigDecimal.TEN, callContext);
+ paymentPluginApi.processPayment(UUID.randomUUID(), UUID.randomUUID(), UUID.randomUUID(), BigDecimal.TEN, Currency.USD, callContext);
}
@Test(groups = "slow")
@@ -89,7 +89,7 @@ public class TestPaymentOSGIWithTestPaymentBundle extends TestOSGIBase {
final PaymentPluginApiException e = new PaymentPluginApiException("test-error", "foo");
paymentPluginApi.setPaymentPluginApiExceptionOnNextCalls(e);
- paymentPluginApi.processPayment(UUID.randomUUID(), UUID.randomUUID(), BigDecimal.TEN, callContext);
+ paymentPluginApi.processPayment(UUID.randomUUID(), UUID.randomUUID(), UUID.randomUUID(), BigDecimal.TEN, Currency.USD, callContext);
Assert.fail("Expected to fail with " + e.toString());
} catch (PaymentPluginApiException e) {
gotException = true;
@@ -106,7 +106,7 @@ public class TestPaymentOSGIWithTestPaymentBundle extends TestOSGIBase {
final RuntimeException e = new RuntimeException("test-error");
paymentPluginApi.setPaymentRuntimeExceptionOnNextCalls(e);
- paymentPluginApi.processPayment(UUID.randomUUID(), UUID.randomUUID(), BigDecimal.TEN, callContext);
+ paymentPluginApi.processPayment(UUID.randomUUID(), UUID.randomUUID(), UUID.randomUUID(), BigDecimal.TEN, Currency.USD, callContext);
Assert.fail("Expected to fail with " + e.toString());
} catch (RuntimeException e) {
gotException = true;
diff --git a/osgi-bundles/bundles/jruby/src/main/java/com/ning/billing/osgi/bundles/jruby/JRubyPaymentPlugin.java b/osgi-bundles/bundles/jruby/src/main/java/com/ning/billing/osgi/bundles/jruby/JRubyPaymentPlugin.java
index d63f273..c4383ce 100644
--- a/osgi-bundles/bundles/jruby/src/main/java/com/ning/billing/osgi/bundles/jruby/JRubyPaymentPlugin.java
+++ b/osgi-bundles/bundles/jruby/src/main/java/com/ning/billing/osgi/bundles/jruby/JRubyPaymentPlugin.java
@@ -30,6 +30,7 @@ import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
import org.osgi.service.log.LogService;
+import com.ning.billing.catalog.api.Currency;
import com.ning.billing.osgi.api.OSGIPluginProperties;
import com.ning.billing.osgi.api.config.PluginRubyConfig;
import com.ning.billing.payment.api.PaymentMethodPlugin;
@@ -74,34 +75,34 @@ public class JRubyPaymentPlugin extends JRubyPlugin implements PaymentPluginApi
@Override
- public PaymentInfoPlugin processPayment(final UUID kbPaymentId, final UUID kbPaymentMethodId, final BigDecimal amount, final CallContext context) throws PaymentPluginApiException {
+ public PaymentInfoPlugin processPayment(final UUID kbAccountId, final UUID kbPaymentId, final UUID kbPaymentMethodId, final BigDecimal amount, final Currency currency, final CallContext context) throws PaymentPluginApiException {
return callWithRuntimeAndChecking(new PluginCallback() {
@Override
public PaymentInfoPlugin doCall(final Ruby runtime) throws PaymentPluginApiException {
- return ((PaymentPluginApi) pluginInstance).processPayment(kbPaymentId, kbPaymentMethodId, amount, context);
+ return ((PaymentPluginApi) pluginInstance).processPayment(kbAccountId, kbPaymentId, kbPaymentMethodId, amount, currency, context);
}
});
}
@Override
- public PaymentInfoPlugin getPaymentInfo(final UUID kbPaymentId, final TenantContext context) throws PaymentPluginApiException {
+ public PaymentInfoPlugin getPaymentInfo(final UUID kbAccountId, final UUID kbPaymentId, final TenantContext context) throws PaymentPluginApiException {
return callWithRuntimeAndChecking(new PluginCallback() {
@Override
public PaymentInfoPlugin doCall(final Ruby runtime) throws PaymentPluginApiException {
- return ((PaymentPluginApi) pluginInstance).getPaymentInfo(kbPaymentId, context);
+ return ((PaymentPluginApi) pluginInstance).getPaymentInfo(kbAccountId, kbPaymentId, context);
}
});
}
@Override
- public RefundInfoPlugin processRefund(final UUID kbPaymentId, final BigDecimal refundAmount, final CallContext context) throws PaymentPluginApiException {
+ public RefundInfoPlugin processRefund(final UUID kbAccountId, final UUID kbPaymentId, final BigDecimal refundAmount, final Currency currency, final CallContext context) throws PaymentPluginApiException {
return callWithRuntimeAndChecking(new PluginCallback() {
@Override
public RefundInfoPlugin doCall(final Ruby runtime) throws PaymentPluginApiException {
- return ((PaymentPluginApi) pluginInstance).processRefund(kbPaymentId, refundAmount, context);
+ return ((PaymentPluginApi) pluginInstance).processRefund(kbAccountId, kbPaymentId, refundAmount, currency, context);
}
});
@@ -120,12 +121,12 @@ public class JRubyPaymentPlugin extends JRubyPlugin implements PaymentPluginApi
}
@Override
- public void deletePaymentMethod(final UUID kbPaymentMethodId, final CallContext context) throws PaymentPluginApiException {
+ public void deletePaymentMethod(final UUID kbAccountId, final UUID kbPaymentMethodId, final CallContext context) throws PaymentPluginApiException {
callWithRuntimeAndChecking(new PluginCallback() {
@Override
public Void doCall(final Ruby runtime) throws PaymentPluginApiException {
- ((PaymentPluginApi) pluginInstance).deletePaymentMethod(kbPaymentMethodId, context);
+ ((PaymentPluginApi) pluginInstance).deletePaymentMethod(kbAccountId, kbPaymentMethodId, context);
return null;
}
});
@@ -143,12 +144,12 @@ public class JRubyPaymentPlugin extends JRubyPlugin implements PaymentPluginApi
}
@Override
- public void setDefaultPaymentMethod(final UUID kbPaymentMethodId, final CallContext context) throws PaymentPluginApiException {
+ public void setDefaultPaymentMethod(final UUID kbAccountId, final UUID kbPaymentMethodId, final CallContext context) throws PaymentPluginApiException {
callWithRuntimeAndChecking(new PluginCallback() {
@Override
public Void doCall(final Ruby runtime) throws PaymentPluginApiException {
- ((PaymentPluginApi) pluginInstance).setDefaultPaymentMethod(kbPaymentMethodId, context);
+ ((PaymentPluginApi) pluginInstance).setDefaultPaymentMethod(kbAccountId, kbPaymentMethodId, context);
return null;
}
});
@@ -165,12 +166,12 @@ public class JRubyPaymentPlugin extends JRubyPlugin implements PaymentPluginApi
}
@Override
- public void resetPaymentMethods(final List<PaymentMethodInfoPlugin> paymentMethods) throws PaymentPluginApiException {
+ public void resetPaymentMethods(final UUID kbAccountId, final List<PaymentMethodInfoPlugin> paymentMethods) throws PaymentPluginApiException {
callWithRuntimeAndChecking(new PluginCallback() {
@Override
public Void doCall(final Ruby runtime) throws PaymentPluginApiException {
- ((PaymentPluginApi) pluginInstance).resetPaymentMethods(paymentMethods);
+ ((PaymentPluginApi) pluginInstance).resetPaymentMethods(kbAccountId, paymentMethods);
return null;
}
});
diff --git a/osgi-bundles/tests/beatrix/src/test/java/com/ning/billing/osgi/bundles/test/TestPaymentPluginApi.java b/osgi-bundles/tests/beatrix/src/test/java/com/ning/billing/osgi/bundles/test/TestPaymentPluginApi.java
index 2b05d87..90ad690 100644
--- a/osgi-bundles/tests/beatrix/src/test/java/com/ning/billing/osgi/bundles/test/TestPaymentPluginApi.java
+++ b/osgi-bundles/tests/beatrix/src/test/java/com/ning/billing/osgi/bundles/test/TestPaymentPluginApi.java
@@ -22,6 +22,7 @@ import java.util.UUID;
import org.joda.time.DateTime;
+import com.ning.billing.catalog.api.Currency;
import com.ning.billing.osgi.bundles.test.dao.TestDao;
import com.ning.billing.payment.api.PaymentMethodPlugin;
import com.ning.billing.payment.plugin.api.PaymentInfoPlugin;
@@ -48,7 +49,7 @@ public class TestPaymentPluginApi implements PaymentPluginApi {
}
@Override
- public PaymentInfoPlugin processPayment(final UUID kbPaymentId, final UUID kbPaymentMethodId, final BigDecimal amount, final CallContext context) throws PaymentPluginApiException {
+ public PaymentInfoPlugin processPayment(final UUID kbAccountId, final UUID kbPaymentId, final UUID kbPaymentMethodId, final BigDecimal amount, final Currency currency, final CallContext context) throws PaymentPluginApiException {
testDao.insertProcessedPayment(kbPaymentId, kbPaymentMethodId, amount);
return new PaymentInfoPlugin() {
@Override
@@ -79,12 +80,12 @@ public class TestPaymentPluginApi implements PaymentPluginApi {
}
@Override
- public PaymentInfoPlugin getPaymentInfo(final UUID kbPaymentId, final TenantContext context) throws PaymentPluginApiException {
+ public PaymentInfoPlugin getPaymentInfo(final UUID kbAccountId, final UUID kbPaymentId, final TenantContext context) throws PaymentPluginApiException {
return null;
}
@Override
- public RefundInfoPlugin processRefund(final UUID kbPaymentId, final BigDecimal refundAmount, final CallContext context) throws PaymentPluginApiException {
+ public RefundInfoPlugin processRefund(final UUID kbAccountId, final UUID kbPaymentId, final BigDecimal refundAmount, final Currency currency, final CallContext context) throws PaymentPluginApiException {
return null;
}
@@ -93,7 +94,7 @@ public class TestPaymentPluginApi implements PaymentPluginApi {
}
@Override
- public void deletePaymentMethod(final UUID kbPaymentMethodId, final CallContext context) throws PaymentPluginApiException {
+ public void deletePaymentMethod(final UUID kbAccountId, final UUID kbPaymentMethodId, final CallContext context) throws PaymentPluginApiException {
}
@Override
@@ -102,7 +103,7 @@ public class TestPaymentPluginApi implements PaymentPluginApi {
}
@Override
- public void setDefaultPaymentMethod(final UUID kbPaymentMethodId, final CallContext context) throws PaymentPluginApiException {
+ public void setDefaultPaymentMethod(final UUID kbAccountId, final UUID kbPaymentMethodId, final CallContext context) throws PaymentPluginApiException {
}
@Override
@@ -111,7 +112,7 @@ public class TestPaymentPluginApi implements PaymentPluginApi {
}
@Override
- public void resetPaymentMethods(final List<PaymentMethodInfoPlugin> paymentMethods) throws PaymentPluginApiException {
+ public void resetPaymentMethods(final UUID kbAccountId, final List<PaymentMethodInfoPlugin> paymentMethods) throws PaymentPluginApiException {
}
diff --git a/osgi-bundles/tests/payment/src/test/java/com/ning/billing/osgi/bundles/test/TestPaymentPluginApi.java b/osgi-bundles/tests/payment/src/test/java/com/ning/billing/osgi/bundles/test/TestPaymentPluginApi.java
index 0c77cf2..129e1c5 100644
--- a/osgi-bundles/tests/payment/src/test/java/com/ning/billing/osgi/bundles/test/TestPaymentPluginApi.java
+++ b/osgi-bundles/tests/payment/src/test/java/com/ning/billing/osgi/bundles/test/TestPaymentPluginApi.java
@@ -22,6 +22,7 @@ import java.util.UUID;
import org.joda.time.DateTime;
+import com.ning.billing.catalog.api.Currency;
import com.ning.billing.payment.api.PaymentMethodPlugin;
import com.ning.billing.payment.plugin.api.PaymentInfoPlugin;
import com.ning.billing.payment.plugin.api.PaymentMethodInfoPlugin;
@@ -49,7 +50,7 @@ public class TestPaymentPluginApi implements PaymentPluginApiWithTestControl {
}
@Override
- public PaymentInfoPlugin processPayment(final UUID kbPaymentId, final UUID kbPaymentMethodId, final BigDecimal amount, final CallContext context) throws PaymentPluginApiException {
+ public PaymentInfoPlugin processPayment(final UUID accountId, final UUID kbPaymentId, final UUID kbPaymentMethodId, final BigDecimal amount, final Currency currency, final CallContext context) throws PaymentPluginApiException {
return withRuntimeCheckForExceptions(new PaymentInfoPlugin() {
@Override
public BigDecimal getAmount() {
@@ -79,7 +80,7 @@ public class TestPaymentPluginApi implements PaymentPluginApiWithTestControl {
}
@Override
- public PaymentInfoPlugin getPaymentInfo(final UUID kbPaymentId, final TenantContext context) throws PaymentPluginApiException {
+ public PaymentInfoPlugin getPaymentInfo(final UUID accountId, final UUID kbPaymentId, final TenantContext context) throws PaymentPluginApiException {
final BigDecimal someAmount = new BigDecimal("12.45");
return withRuntimeCheckForExceptions(new PaymentInfoPlugin() {
@@ -111,7 +112,7 @@ public class TestPaymentPluginApi implements PaymentPluginApiWithTestControl {
}
@Override
- public RefundInfoPlugin processRefund(final UUID kbPaymentId, final BigDecimal refundAmount, final CallContext context) throws PaymentPluginApiException {
+ public RefundInfoPlugin processRefund(final UUID accountId, final UUID kbPaymentId, final BigDecimal refundAmount, final Currency currency, final CallContext context) throws PaymentPluginApiException {
final BigDecimal someAmount = new BigDecimal("12.45");
return withRuntimeCheckForExceptions(new RefundInfoPlugin() {
@@ -147,7 +148,7 @@ public class TestPaymentPluginApi implements PaymentPluginApiWithTestControl {
}
@Override
- public void deletePaymentMethod(final UUID kbPaymentMethodId, final CallContext context) throws PaymentPluginApiException {
+ public void deletePaymentMethod(final UUID accountId, final UUID kbPaymentMethodId, final CallContext context) throws PaymentPluginApiException {
}
@Override
@@ -156,7 +157,7 @@ public class TestPaymentPluginApi implements PaymentPluginApiWithTestControl {
}
@Override
- public void setDefaultPaymentMethod(final UUID kbPaymentMethodId, final CallContext context) throws PaymentPluginApiException {
+ public void setDefaultPaymentMethod(final UUID accountId, final UUID kbPaymentMethodId, final CallContext context) throws PaymentPluginApiException {
}
@Override
@@ -165,7 +166,7 @@ public class TestPaymentPluginApi implements PaymentPluginApiWithTestControl {
}
@Override
- public void resetPaymentMethods(final List<PaymentMethodInfoPlugin> paymentMethods) throws PaymentPluginApiException {
+ public void resetPaymentMethods(final UUID accountId, final List<PaymentMethodInfoPlugin> paymentMethods) throws PaymentPluginApiException {
}
diff --git a/payment/src/main/java/com/ning/billing/payment/core/PaymentMethodProcessor.java b/payment/src/main/java/com/ning/billing/payment/core/PaymentMethodProcessor.java
index f4fe009..d3efe4b 100644
--- a/payment/src/main/java/com/ning/billing/payment/core/PaymentMethodProcessor.java
+++ b/payment/src/main/java/com/ning/billing/payment/core/PaymentMethodProcessor.java
@@ -209,7 +209,7 @@ public class PaymentMethodProcessor extends ProcessorBase {
}
}
final PaymentPluginApi pluginApi = getPluginApi(paymentMethodId, context);
- pluginApi.deletePaymentMethod(paymentMethodId, context.toCallContext());
+ pluginApi.deletePaymentMethod(account.getId(), paymentMethodId, context.toCallContext());
paymentDao.deletedPaymentMethod(paymentMethodId, context);
return null;
} catch (PaymentPluginApiException e) {
@@ -236,7 +236,7 @@ public class PaymentMethodProcessor extends ProcessorBase {
try {
final PaymentPluginApi pluginApi = getPluginApi(paymentMethodId, context);
- pluginApi.setDefaultPaymentMethod(paymentMethodId, context.toCallContext());
+ pluginApi.setDefaultPaymentMethod(account.getId(), paymentMethodId, context.toCallContext());
accountInternalApi.updatePaymentMethod(account.getId(), paymentMethodId, context);
return null;
} catch (PaymentPluginApiException e) {
@@ -314,7 +314,7 @@ public class PaymentMethodProcessor extends ProcessorBase {
finalPaymentMethods,
context);
try {
- pluginApi.resetPaymentMethods(pluginPmsWithId);
+ pluginApi.resetPaymentMethods(account.getId(), pluginPmsWithId);
} catch (PaymentPluginApiException e) {
throw new PaymentApiException(ErrorCode.PAYMENT_REFRESH_PAYMENT_METHOD, account.getId(), e.getErrorMessage());
}
diff --git a/payment/src/main/java/com/ning/billing/payment/core/PaymentProcessor.java b/payment/src/main/java/com/ning/billing/payment/core/PaymentProcessor.java
index 2f70a84..f33a55e 100644
--- a/payment/src/main/java/com/ning/billing/payment/core/PaymentProcessor.java
+++ b/payment/src/main/java/com/ning/billing/payment/core/PaymentProcessor.java
@@ -424,7 +424,7 @@ public class PaymentProcessor extends ProcessorBase {
PaymentStatus paymentStatus;
try {
- final PaymentInfoPlugin paymentPluginInfo = plugin.processPayment(paymentInput.getId(), paymentInput.getPaymentMethodId(), attemptInput.getRequestedAmount(), context.toCallContext());
+ final PaymentInfoPlugin paymentPluginInfo = plugin.processPayment(account.getId(), paymentInput.getId(), paymentInput.getPaymentMethodId(), attemptInput.getRequestedAmount(), account.getCurrency(), context.toCallContext());
switch (paymentPluginInfo.getStatus()) {
case PROCESSED:
// Update Payment/PaymentAttempt status
diff --git a/payment/src/main/java/com/ning/billing/payment/core/RefundProcessor.java b/payment/src/main/java/com/ning/billing/payment/core/RefundProcessor.java
index a1e2783..6778994 100644
--- a/payment/src/main/java/com/ning/billing/payment/core/RefundProcessor.java
+++ b/payment/src/main/java/com/ning/billing/payment/core/RefundProcessor.java
@@ -122,7 +122,7 @@ public class RefundProcessor extends ProcessorBase {
paymentDao.insertRefund(refundInfo, context);
final PaymentPluginApi plugin = getPaymentProviderPlugin(payment.getPaymentMethodId(), context);
- plugin.processRefund(paymentId, refundAmount, context.toCallContext());
+ plugin.processRefund(account.getId(), paymentId, refundAmount, account.getCurrency(), context.toCallContext());
paymentDao.updateRefundStatus(refundInfo.getId(), RefundStatus.PLUGIN_COMPLETED, context);
diff --git a/payment/src/main/java/com/ning/billing/payment/provider/DefaultNoOpPaymentProviderPlugin.java b/payment/src/main/java/com/ning/billing/payment/provider/DefaultNoOpPaymentProviderPlugin.java
index 7a41e27..670a81d 100644
--- a/payment/src/main/java/com/ning/billing/payment/provider/DefaultNoOpPaymentProviderPlugin.java
+++ b/payment/src/main/java/com/ning/billing/payment/provider/DefaultNoOpPaymentProviderPlugin.java
@@ -24,6 +24,7 @@ import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicBoolean;
+import com.ning.billing.catalog.api.Currency;
import com.ning.billing.payment.api.PaymentMethodPlugin;
import com.ning.billing.payment.plugin.api.NoOpPaymentPluginApi;
import com.ning.billing.payment.plugin.api.PaymentInfoPlugin;
@@ -89,7 +90,7 @@ public class DefaultNoOpPaymentProviderPlugin implements NoOpPaymentPluginApi {
}
@Override
- public PaymentInfoPlugin processPayment(final UUID kbPaymentId, final UUID kbPaymentMethodId, final BigDecimal amount, final CallContext context) throws PaymentPluginApiException {
+ public PaymentInfoPlugin processPayment(final UUID kbAccountId, final UUID kbPaymentId, final UUID kbPaymentMethodId, final BigDecimal amount, final Currency currency, final CallContext context) throws PaymentPluginApiException {
if (makeNextInvoiceFailWithException.getAndSet(false)) {
throw new PaymentPluginApiException("", "test error");
}
@@ -101,7 +102,7 @@ public class DefaultNoOpPaymentProviderPlugin implements NoOpPaymentPluginApi {
}
@Override
- public PaymentInfoPlugin getPaymentInfo(final UUID kbPaymentId, final TenantContext context) throws PaymentPluginApiException {
+ public PaymentInfoPlugin getPaymentInfo(final UUID kbAccountId, final UUID kbPaymentId, 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());
@@ -121,7 +122,7 @@ public class DefaultNoOpPaymentProviderPlugin implements NoOpPaymentPluginApi {
}
@Override
- public void deletePaymentMethod(final UUID kbPaymentMethodId, final CallContext context) throws PaymentPluginApiException {
+ public void deletePaymentMethod(final UUID kbAccountId, final UUID kbPaymentMethodId, final CallContext context) throws PaymentPluginApiException {
PaymentMethodPlugin toBeDeleted = null;
final List<PaymentMethodPlugin> pms = paymentMethods.get(kbPaymentMethodId.toString());
if (pms != null) {
@@ -149,7 +150,7 @@ public class DefaultNoOpPaymentProviderPlugin implements NoOpPaymentPluginApi {
}
@Override
- public void setDefaultPaymentMethod(final UUID kbPaymentMethodId, final CallContext context) throws PaymentPluginApiException {
+ public void setDefaultPaymentMethod(final UUID kbAccountId, final UUID kbPaymentMethodId, final CallContext context) throws PaymentPluginApiException {
}
@Override
@@ -158,12 +159,12 @@ public class DefaultNoOpPaymentProviderPlugin implements NoOpPaymentPluginApi {
}
@Override
- public void resetPaymentMethods(final List<PaymentMethodInfoPlugin> paymentMethods) {
+ public void resetPaymentMethods(final UUID kbAccountId, final List<PaymentMethodInfoPlugin> paymentMethods) {
}
@Override
- public RefundInfoPlugin processRefund(final UUID kbPaymentId, final BigDecimal refundAmount, final CallContext context) throws PaymentPluginApiException {
- final PaymentInfoPlugin paymentInfoPlugin = getPaymentInfo(kbPaymentId, context);
+ 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);
if (paymentInfoPlugin == null) {
throw new PaymentPluginApiException("", String.format("No payment found for payment id %s (plugin %s)", kbPaymentId.toString(), getName()));
}
diff --git a/payment/src/test/java/com/ning/billing/payment/core/TestPaymentMethodProcessorRefreshWithDB.java b/payment/src/test/java/com/ning/billing/payment/core/TestPaymentMethodProcessorRefreshWithDB.java
index 49bdcb2..20d95a4 100644
--- a/payment/src/test/java/com/ning/billing/payment/core/TestPaymentMethodProcessorRefreshWithDB.java
+++ b/payment/src/test/java/com/ning/billing/payment/core/TestPaymentMethodProcessorRefreshWithDB.java
@@ -40,7 +40,7 @@ public class TestPaymentMethodProcessorRefreshWithDB extends PaymentTestSuiteWit
@BeforeMethod(groups = "slow")
public void beforeMethod() throws Exception {
super.beforeMethod();
- getPluginApi().resetPaymentMethods(null);
+ getPluginApi().resetPaymentMethods(null, null);
}
@Test(groups = "slow")
@@ -74,7 +74,7 @@ public class TestPaymentMethodProcessorRefreshWithDB extends PaymentTestSuiteWit
Assert.assertEquals(paymentApi.getPaymentMethods(account, false, callContext).size(), 2);
// Remove second PM from plugin
- getPluginApi().deletePaymentMethod(secondPmId, callContext);
+ getPluginApi().deletePaymentMethod(account.getId(), secondPmId, callContext);
Assert.assertEquals(getPluginApi().getPaymentMethods(account.getId(), true, callContext).size(), 1);
Assert.assertEquals(paymentApi.getPaymentMethods(account, false, callContext).size(), 2);
diff --git a/payment/src/test/java/com/ning/billing/payment/provider/MockPaymentProviderPlugin.java b/payment/src/test/java/com/ning/billing/payment/provider/MockPaymentProviderPlugin.java
index e72c9b3..cb49626 100644
--- a/payment/src/test/java/com/ning/billing/payment/provider/MockPaymentProviderPlugin.java
+++ b/payment/src/test/java/com/ning/billing/payment/provider/MockPaymentProviderPlugin.java
@@ -23,6 +23,7 @@ import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicBoolean;
+import com.ning.billing.catalog.api.Currency;
import com.ning.billing.payment.api.DefaultPaymentMethodPlugin;
import com.ning.billing.payment.api.PaymentMethodPlugin;
import com.ning.billing.payment.plugin.api.NoOpPaymentPluginApi;
@@ -95,7 +96,7 @@ public class MockPaymentProviderPlugin implements NoOpPaymentPluginApi {
}
@Override
- public PaymentInfoPlugin processPayment(final UUID kbPaymentId, final UUID kbPaymentMethodId, final BigDecimal amount, final CallContext context) throws PaymentPluginApiException {
+ public PaymentInfoPlugin processPayment(final UUID kbAccountId, final UUID kbPaymentId, final UUID kbPaymentMethodId, final BigDecimal amount, final Currency currency, final CallContext context) throws PaymentPluginApiException {
if (makeNextInvoiceFailWithException.getAndSet(false)) {
throw new PaymentPluginApiException("", "test error");
}
@@ -107,7 +108,7 @@ public class MockPaymentProviderPlugin implements NoOpPaymentPluginApi {
}
@Override
- public PaymentInfoPlugin getPaymentInfo(final UUID kbPaymentId, final TenantContext context) throws PaymentPluginApiException {
+ public PaymentInfoPlugin getPaymentInfo(final UUID kbAccountId, final UUID kbPaymentId, 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());
@@ -127,7 +128,7 @@ public class MockPaymentProviderPlugin implements NoOpPaymentPluginApi {
}
@Override
- public void deletePaymentMethod(final UUID kbPaymentMethodId, final CallContext context) throws PaymentPluginApiException {
+ public void deletePaymentMethod(final UUID kbAccountId, final UUID kbPaymentMethodId, final CallContext context) throws PaymentPluginApiException {
paymentMethods.remove(kbPaymentMethodId.toString());
paymentMethodsInfo.remove(kbPaymentMethodId.toString());
}
@@ -138,7 +139,7 @@ public class MockPaymentProviderPlugin implements NoOpPaymentPluginApi {
}
@Override
- public void setDefaultPaymentMethod(final UUID kbPaymentMethodId, final CallContext context) throws PaymentPluginApiException {
+ public void setDefaultPaymentMethod(final UUID kbAccountId, final UUID kbPaymentMethodId, final CallContext context) throws PaymentPluginApiException {
}
@Override
@@ -147,7 +148,7 @@ public class MockPaymentProviderPlugin implements NoOpPaymentPluginApi {
}
@Override
- public void resetPaymentMethods(final List<PaymentMethodInfoPlugin> input) {
+ public void resetPaymentMethods(final UUID kbAccountId, final List<PaymentMethodInfoPlugin> input) {
paymentMethodsInfo.clear();
if (input != null) {
for (final PaymentMethodInfoPlugin cur : input) {
@@ -157,8 +158,8 @@ public class MockPaymentProviderPlugin implements NoOpPaymentPluginApi {
}
@Override
- public RefundInfoPlugin processRefund(final UUID kbPaymentId, final BigDecimal refundAmount, final CallContext context) throws PaymentPluginApiException {
- final PaymentInfoPlugin paymentInfoPlugin = getPaymentInfo(kbPaymentId, context);
+ 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);
if (paymentInfoPlugin == null) {
throw new PaymentPluginApiException("", String.format("No payment found for payment id %s (plugin %s)", kbPaymentId.toString(), getName()));
}
diff --git a/payment/src/test/java/com/ning/billing/payment/provider/TestExternalPaymentProviderPlugin.java b/payment/src/test/java/com/ning/billing/payment/provider/TestExternalPaymentProviderPlugin.java
index bd2bc91..b4c8a89 100644
--- a/payment/src/test/java/com/ning/billing/payment/provider/TestExternalPaymentProviderPlugin.java
+++ b/payment/src/test/java/com/ning/billing/payment/provider/TestExternalPaymentProviderPlugin.java
@@ -26,6 +26,7 @@ import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import com.ning.billing.account.api.Account;
+import com.ning.billing.catalog.api.Currency;
import com.ning.billing.payment.PaymentTestSuiteNoDB;
import com.ning.billing.payment.plugin.api.PaymentInfoPlugin;
import com.ning.billing.payment.plugin.api.PaymentInfoPlugin.PaymentPluginStatus;
@@ -33,6 +34,8 @@ import com.ning.billing.payment.plugin.api.PaymentPluginApiException;
import com.ning.billing.util.clock.Clock;
import com.ning.billing.util.clock.ClockMock;
+import sun.util.resources.CurrencyNames_el_CY;
+
public class TestExternalPaymentProviderPlugin extends PaymentTestSuiteNoDB {
private final Clock clock = new ClockMock();
@@ -52,10 +55,12 @@ public class TestExternalPaymentProviderPlugin extends PaymentTestSuiteNoDB {
@Test(groups = "fast")
public void testProcessPayment() throws Exception {
+
+ 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(paymentId, paymentMethodId, amount, callContext);
+ final PaymentInfoPlugin paymentInfoPlugin = plugin.processPayment(accountId, paymentId, paymentMethodId, amount, Currency.BRL, callContext);
Assert.assertEquals(paymentInfoPlugin.getAmount(), amount);
Assert.assertEquals(Seconds.secondsBetween(paymentInfoPlugin.getCreatedDate(), clock.getUTCNow()).getSeconds(), 0);
@@ -64,38 +69,42 @@ public class TestExternalPaymentProviderPlugin extends PaymentTestSuiteNoDB {
Assert.assertNull(paymentInfoPlugin.getGatewayErrorCode());
Assert.assertEquals(paymentInfoPlugin.getStatus(), PaymentPluginStatus.PROCESSED);
- final PaymentInfoPlugin retrievedPaymentInfoPlugin = plugin.getPaymentInfo(paymentId, callContext);
+ final PaymentInfoPlugin retrievedPaymentInfoPlugin = plugin.getPaymentInfo(accountId, paymentId, callContext);
Assert.assertEquals(retrievedPaymentInfoPlugin, paymentInfoPlugin);
}
@Test(groups = "fast", expectedExceptions = PaymentPluginApiException.class)
public void testRefundForNonExistingPayment() throws Exception {
- plugin.processRefund(UUID.randomUUID(), BigDecimal.ONE, callContext);
+ plugin.processRefund(UUID.randomUUID(), UUID.randomUUID(), BigDecimal.ONE, Currency.GBP, callContext);
}
@Test(groups = "fast", expectedExceptions = PaymentPluginApiException.class)
public void testRefundTooLarge() throws Exception {
+
+ final UUID accountId = UUID.randomUUID();
final UUID paymentId = UUID.randomUUID();
final UUID paymentMethodId = UUID.randomUUID();
- plugin.processPayment(paymentId, paymentMethodId, BigDecimal.ZERO, callContext);
- plugin.processRefund(paymentId, BigDecimal.ONE, callContext);
+ plugin.processPayment(accountId, paymentId, paymentMethodId, BigDecimal.ZERO, Currency.EUR, callContext);
+ plugin.processRefund(accountId, paymentId, BigDecimal.ONE, Currency.EUR, callContext);
}
@Test(groups = "fast")
public void testRefundTooLargeMultipleTimes() throws Exception {
+
+ final UUID accountId = UUID.randomUUID();
final UUID paymentId = UUID.randomUUID();
final UUID paymentMethodId = UUID.randomUUID();
- plugin.processPayment(paymentId, paymentMethodId, BigDecimal.TEN, callContext);
+ plugin.processPayment(accountId, paymentId, paymentMethodId, BigDecimal.TEN, Currency.EUR, callContext);
final Account account = Mockito.mock(Account.class);
for (int i = 0; i < 10; i++) {
- plugin.processRefund(paymentId, BigDecimal.ONE, callContext);
+ plugin.processRefund(accountId, paymentId, BigDecimal.ONE, Currency.EUR, callContext);
}
try {
- plugin.processRefund(paymentId, BigDecimal.ONE, callContext);
+ plugin.processRefund(accountId, paymentId, BigDecimal.ONE, Currency.EUR, callContext);
Assert.fail("Shouldn't have been able to refund");
} catch (PaymentPluginApiException e) {
Assert.assertTrue(true);