killbill-uncached
Changes
osgi-bundles/bundles/jruby/src/main/java/org/killbill/billing/osgi/bundles/jruby/JRubyPaymentPlugin.java 4(+2 -2)
osgi-bundles/tests/beatrix/src/test/java/org/killbill/billing/osgi/bundles/test/TestPaymentPluginApi.java 2(+1 -1)
osgi-bundles/tests/payment/src/test/java/org/killbill/billing/osgi/bundles/test/TestPaymentPluginApi.java 2(+1 -1)
payment/src/main/java/org/killbill/billing/payment/provider/DefaultNoOpPaymentProviderPlugin.java 2(+1 -1)
payment/src/main/java/org/killbill/billing/payment/provider/ExternalPaymentProviderPlugin.java 2(+1 -1)
payment/src/test/java/org/killbill/billing/payment/core/TestPaymentMethodProcessorNoDB.java 4(+2 -2)
payment/src/test/java/org/killbill/billing/payment/core/TestPaymentMethodProcessorRefreshWithDB.java 6(+3 -3)
pom.xml 2(+1 -1)
Details
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 8443126..2434a95 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
@@ -225,11 +225,11 @@ public class JRubyPaymentPlugin extends JRubyPlugin implements PaymentPluginApi
}
@Override
- public void resetPaymentMethods(final UUID kbAccountId, final List<PaymentMethodInfoPlugin> paymentMethods, final Iterable<PluginProperty> properties) throws PaymentPluginApiException {
+ public void resetPaymentMethods(final UUID kbAccountId, final List<PaymentMethodInfoPlugin> paymentMethods, 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).resetPaymentMethods(kbAccountId, paymentMethods, properties);
+ ((PaymentPluginApi) pluginInstance).resetPaymentMethods(kbAccountId, paymentMethods, properties, context);
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 3c04998..f4872a2 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
@@ -256,7 +256,7 @@ public class TestPaymentPluginApi implements PaymentPluginApi {
}
@Override
- public void resetPaymentMethods(final UUID kbAccountId, final List<PaymentMethodInfoPlugin> paymentMethods, final Iterable<PluginProperty> properties) throws PaymentPluginApiException {
+ public void resetPaymentMethods(final UUID kbAccountId, final List<PaymentMethodInfoPlugin> paymentMethods, final Iterable<PluginProperty> properties, final CallContext callContext) throws PaymentPluginApiException {
}
@Override
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 94cff65..0fbc150 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
@@ -323,7 +323,7 @@ public class TestPaymentPluginApi implements PaymentPluginApiWithTestControl {
}
@Override
- public void resetPaymentMethods(final UUID accountId, final List<PaymentMethodInfoPlugin> paymentMethods, final Iterable<PluginProperty> properties) throws PaymentPluginApiException {
+ public void resetPaymentMethods(final UUID accountId, final List<PaymentMethodInfoPlugin> paymentMethods, final Iterable<PluginProperty> properties, final CallContext callContext) throws PaymentPluginApiException {
}
@Override
diff --git a/payment/src/main/java/org/killbill/billing/payment/api/DefaultPaymentApi.java b/payment/src/main/java/org/killbill/billing/payment/api/DefaultPaymentApi.java
index f589788..425326d 100644
--- a/payment/src/main/java/org/killbill/billing/payment/api/DefaultPaymentApi.java
+++ b/payment/src/main/java/org/killbill/billing/payment/api/DefaultPaymentApi.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:
*
@@ -65,15 +67,15 @@ public class DefaultPaymentApi implements PaymentApi {
public Payment createPayment(final Account account, final UUID invoiceId,
final BigDecimal amount, final Iterable<PluginProperty> properties, final CallContext context) throws PaymentApiException {
return paymentProcessor.createPayment(account, invoiceId, amount,
- internalCallContextFactory.createInternalCallContext(account.getId(), context),
- true, false, properties);
+ true, false, properties, context, internalCallContextFactory.createInternalCallContext(account.getId(), context)
+ );
}
@Override
public Payment createExternalPayment(final Account account, final UUID invoiceId, final BigDecimal amount, final CallContext context) throws PaymentApiException {
return paymentProcessor.createPayment(account, invoiceId, amount,
- internalCallContextFactory.createInternalCallContext(account.getId(), context),
- true, true, ImmutableList.<PluginProperty>of());
+ true, true, ImmutableList.<PluginProperty>of(), context, internalCallContextFactory.createInternalCallContext(account.getId(), context)
+ );
}
@Override
@@ -85,7 +87,7 @@ public class DefaultPaymentApi implements PaymentApi {
@Override
public Payment retryPayment(final Account account, final UUID paymentId, final Iterable<PluginProperty> properties, final CallContext context) throws PaymentApiException {
final InternalCallContext internalCallContext = internalCallContextFactory.createInternalCallContext(account.getId(), context);
- paymentProcessor.retryPaymentFromApi(paymentId, properties, internalCallContext);
+ paymentProcessor.retryPaymentFromApi(paymentId, properties, context, internalCallContext);
return getPayment(paymentId, false, properties, context);
}
@@ -101,7 +103,7 @@ public class DefaultPaymentApi implements PaymentApi {
@Override
public Payment getPayment(final UUID paymentId, final boolean withPluginInfo, final Iterable<PluginProperty> properties, final TenantContext context) throws PaymentApiException {
- final Payment payment = paymentProcessor.getPayment(paymentId, withPluginInfo, properties, internalCallContextFactory.createInternalTenantContext(context));
+ final Payment payment = paymentProcessor.getPayment(paymentId, withPluginInfo, properties, context, internalCallContextFactory.createInternalTenantContext(context));
if (payment == null) {
throw new PaymentApiException(ErrorCode.PAYMENT_NO_SUCH_PAYMENT, paymentId);
}
@@ -110,12 +112,12 @@ public class DefaultPaymentApi implements PaymentApi {
@Override
public Pagination<Payment> searchPayments(final String searchKey, final Long offset, final Long limit, final Iterable<PluginProperty> properties, final TenantContext context) {
- return paymentProcessor.searchPayments(searchKey, offset, limit, properties, internalCallContextFactory.createInternalTenantContext(context));
+ return paymentProcessor.searchPayments(searchKey, offset, limit, properties, context, internalCallContextFactory.createInternalTenantContext(context));
}
@Override
public Pagination<Payment> searchPayments(final String searchKey, final Long offset, final Long limit, final String pluginName, final Iterable<PluginProperty> properties, final TenantContext context) throws PaymentApiException {
- return paymentProcessor.searchPayments(searchKey, offset, limit, pluginName, properties, internalCallContextFactory.createInternalTenantContext(context));
+ return paymentProcessor.searchPayments(searchKey, offset, limit, pluginName, properties, context, internalCallContextFactory.createInternalTenantContext(context));
}
@Override
@@ -130,12 +132,12 @@ public class DefaultPaymentApi implements PaymentApi {
@Override
public Pagination<Refund> searchRefunds(final String searchKey, final Long offset, final Long limit, final Iterable<PluginProperty> properties, final TenantContext context) {
- return refundProcessor.searchRefunds(searchKey, offset, limit, properties, internalCallContextFactory.createInternalTenantContext(context));
+ return refundProcessor.searchRefunds(searchKey, offset, limit, properties, context, internalCallContextFactory.createInternalTenantContext(context));
}
@Override
public Pagination<Refund> searchRefunds(final String searchKey, final Long offset, final Long limit, final String pluginName, final Iterable<PluginProperty> properties, final TenantContext context) throws PaymentApiException {
- return refundProcessor.searchRefunds(searchKey, offset, limit, pluginName, properties, internalCallContextFactory.createInternalTenantContext(context));
+ return refundProcessor.searchRefunds(searchKey, offset, limit, pluginName, properties, context, internalCallContextFactory.createInternalTenantContext(context));
}
@Override
@@ -151,7 +153,7 @@ public class DefaultPaymentApi implements PaymentApi {
@Override
public Refund getRefund(final UUID refundId, final boolean withPluginInfo, final Iterable<PluginProperty> properties, final TenantContext context) throws PaymentApiException {
- return refundProcessor.getRefund(refundId, withPluginInfo, properties, internalCallContextFactory.createInternalTenantContext(context));
+ return refundProcessor.getRefund(refundId, withPluginInfo, properties, context, internalCallContextFactory.createInternalTenantContext(context));
}
@Override
@@ -160,7 +162,7 @@ public class DefaultPaymentApi implements PaymentApi {
throw new PaymentApiException(ErrorCode.PAYMENT_REFUND_AMOUNT_NEGATIVE_OR_NULL);
}
return refundProcessor.createRefund(account, paymentId, refundAmount, false, ImmutableMap.<UUID, BigDecimal>of(), properties,
- internalCallContextFactory.createInternalCallContext(account.getId(), context));
+ context, internalCallContextFactory.createInternalCallContext(account.getId(), context));
}
@Override
@@ -175,7 +177,7 @@ public class DefaultPaymentApi implements PaymentApi {
throw new PaymentApiException(ErrorCode.PAYMENT_REFUND_AMOUNT_NEGATIVE_OR_NULL);
}
return refundProcessor.createRefund(account, paymentId, refundAmount, true, ImmutableMap.<UUID, BigDecimal>of(), properties,
- internalCallContextFactory.createInternalCallContext(account.getId(), context));
+ context, internalCallContextFactory.createInternalCallContext(account.getId(), context));
}
@Override
@@ -186,13 +188,13 @@ public class DefaultPaymentApi implements PaymentApi {
}
return refundProcessor.createRefund(account, paymentId, null, true, invoiceItemIdsWithAmounts, properties,
- internalCallContextFactory.createInternalCallContext(account.getId(), context));
+ context, internalCallContextFactory.createInternalCallContext(account.getId(), context));
}
@Override
public Refund createRefundWithItemsAdjustments(final Account account, final UUID paymentId, final Map<UUID, BigDecimal> invoiceItemIdsWithAmounts, final Iterable<PluginProperty> properties, final CallContext context) throws PaymentApiException {
return refundProcessor.createRefund(account, paymentId, null, true, invoiceItemIdsWithAmounts, properties,
- internalCallContextFactory.createInternalCallContext(account.getId(), context));
+ context, internalCallContextFactory.createInternalCallContext(account.getId(), context));
}
@Override
@@ -218,19 +220,19 @@ public class DefaultPaymentApi implements PaymentApi {
final Iterable<PluginProperty> properties, final CallContext context)
throws PaymentApiException {
return methodProcessor.addPaymentMethod(pluginName, account, setDefault, paymentMethodInfo, properties,
- internalCallContextFactory.createInternalCallContext(account.getId(), context));
+ context, internalCallContextFactory.createInternalCallContext(account.getId(), context));
}
@Override
public List<PaymentMethod> getPaymentMethods(final Account account, final boolean withPluginInfo, final Iterable<PluginProperty> properties, final TenantContext context)
throws PaymentApiException {
- return methodProcessor.getPaymentMethods(account, withPluginInfo, properties, internalCallContextFactory.createInternalTenantContext(context));
+ return methodProcessor.getPaymentMethods(account, withPluginInfo, properties, context, internalCallContextFactory.createInternalTenantContext(context));
}
@Override
public PaymentMethod getPaymentMethodById(final UUID paymentMethodId, final boolean includedDeleted, final boolean withPluginInfo, final Iterable<PluginProperty> properties, final TenantContext context)
throws PaymentApiException {
- return methodProcessor.getPaymentMethodById(paymentMethodId, includedDeleted, withPluginInfo, properties, internalCallContextFactory.createInternalTenantContext(context));
+ return methodProcessor.getPaymentMethodById(paymentMethodId, includedDeleted, withPluginInfo, properties, context, internalCallContextFactory.createInternalTenantContext(context));
}
@Override
@@ -245,30 +247,30 @@ public class DefaultPaymentApi implements PaymentApi {
@Override
public Pagination<PaymentMethod> searchPaymentMethods(final String searchKey, final Long offset, final Long limit, final Iterable<PluginProperty> properties, final TenantContext context) {
- return methodProcessor.searchPaymentMethods(searchKey, offset, limit, properties, internalCallContextFactory.createInternalTenantContext(context));
+ return methodProcessor.searchPaymentMethods(searchKey, offset, limit, properties, context, internalCallContextFactory.createInternalTenantContext(context));
}
@Override
public Pagination<PaymentMethod> searchPaymentMethods(final String searchKey, final Long offset, final Long limit, final String pluginName, final Iterable<PluginProperty> properties, final TenantContext context) throws PaymentApiException {
- return methodProcessor.searchPaymentMethods(searchKey, offset, limit, pluginName, properties, internalCallContextFactory.createInternalTenantContext(context));
+ return methodProcessor.searchPaymentMethods(searchKey, offset, limit, pluginName, properties, context, internalCallContextFactory.createInternalTenantContext(context));
}
@Override
public void deletedPaymentMethod(final Account account, final UUID paymentMethodId, final boolean deleteDefaultPaymentMethodWithAutoPayOff, final Iterable<PluginProperty> properties, final CallContext context)
throws PaymentApiException {
- methodProcessor.deletedPaymentMethod(account, paymentMethodId, deleteDefaultPaymentMethodWithAutoPayOff, properties, internalCallContextFactory.createInternalCallContext(account.getId(), context));
+ methodProcessor.deletedPaymentMethod(account, paymentMethodId, deleteDefaultPaymentMethodWithAutoPayOff, properties, context, internalCallContextFactory.createInternalCallContext(account.getId(), context));
}
@Override
public void setDefaultPaymentMethod(final Account account, final UUID paymentMethodId, final Iterable<PluginProperty> properties, final CallContext context)
throws PaymentApiException {
- methodProcessor.setDefaultPaymentMethod(account, paymentMethodId, properties, internalCallContextFactory.createInternalCallContext(account.getId(), context));
+ methodProcessor.setDefaultPaymentMethod(account, paymentMethodId, properties, context, internalCallContextFactory.createInternalCallContext(account.getId(), context));
}
@Override
public List<PaymentMethod> refreshPaymentMethods(final String pluginName, final Account account, final Iterable<PluginProperty> properties, final CallContext context)
throws PaymentApiException {
- return methodProcessor.refreshPaymentMethods(pluginName, account, properties, internalCallContextFactory.createInternalCallContext(account.getId(), context));
+ return methodProcessor.refreshPaymentMethods(pluginName, account, properties, context, internalCallContextFactory.createInternalCallContext(account.getId(), context));
}
@Override
@@ -278,7 +280,7 @@ public class DefaultPaymentApi implements PaymentApi {
final List<PaymentMethod> paymentMethods = new LinkedList<PaymentMethod>();
for (final String pluginName : methodProcessor.getAvailablePlugins()) {
- paymentMethods.addAll(methodProcessor.refreshPaymentMethods(pluginName, account, properties, callContext));
+ paymentMethods.addAll(methodProcessor.refreshPaymentMethods(pluginName, account, properties, context, callContext));
}
return paymentMethods;
diff --git a/payment/src/main/java/org/killbill/billing/payment/api/svcs/DefaultDirectPaymentApi.java b/payment/src/main/java/org/killbill/billing/payment/api/svcs/DefaultDirectPaymentApi.java
index 2d60830..56e64bb 100644
--- a/payment/src/main/java/org/killbill/billing/payment/api/svcs/DefaultDirectPaymentApi.java
+++ b/payment/src/main/java/org/killbill/billing/payment/api/svcs/DefaultDirectPaymentApi.java
@@ -49,27 +49,27 @@ public class DefaultDirectPaymentApi implements DirectPaymentApi {
@Override
public DirectPayment createAuthorization(final Account account, final UUID directPaymentId, final BigDecimal amount, final Currency currency, final String externalKey, final Iterable<PluginProperty> properties, final CallContext callContext) throws PaymentApiException {
- return directPaymentProcessor.createAuthorization(account, directPaymentId, amount, currency, externalKey, properties, internalCallContextFactory.createInternalCallContext(account.getId(), callContext));
+ return directPaymentProcessor.createAuthorization(account, directPaymentId, amount, currency, externalKey, properties, callContext, internalCallContextFactory.createInternalCallContext(account.getId(), callContext));
}
@Override
public DirectPayment createCapture(final Account account, final UUID directPaymentId, final BigDecimal amount, final Currency currency, final Iterable<PluginProperty> properties, final CallContext callContext) throws PaymentApiException {
- return directPaymentProcessor.createCapture(account, directPaymentId, amount, currency, properties, internalCallContextFactory.createInternalCallContext(account.getId(), callContext));
+ return directPaymentProcessor.createCapture(account, directPaymentId, amount, currency, properties, callContext, internalCallContextFactory.createInternalCallContext(account.getId(), callContext));
}
@Override
public DirectPayment createPurchase(final Account account, final UUID directPaymentId, final BigDecimal amount, final Currency currency, final String externalKey, final Iterable<PluginProperty> properties, final CallContext callContext) throws PaymentApiException {
- return directPaymentProcessor.createPurchase(account, directPaymentId, amount, currency, externalKey, properties, internalCallContextFactory.createInternalCallContext(account.getId(), callContext));
+ return directPaymentProcessor.createPurchase(account, directPaymentId, amount, currency, externalKey, properties, callContext, internalCallContextFactory.createInternalCallContext(account.getId(), callContext));
}
@Override
public DirectPayment createVoid(final Account account, final UUID directPaymentId, final Iterable<PluginProperty> properties, final CallContext callContext) throws PaymentApiException {
- return directPaymentProcessor.createVoid(account, directPaymentId, properties, internalCallContextFactory.createInternalCallContext(account.getId(), callContext));
+ return directPaymentProcessor.createVoid(account, directPaymentId, properties, callContext, internalCallContextFactory.createInternalCallContext(account.getId(), callContext));
}
@Override
public DirectPayment createCredit(final Account account, final UUID directPaymentId, final BigDecimal amount, final Currency currency, final Iterable<PluginProperty> properties, final CallContext callContext) throws PaymentApiException {
- return directPaymentProcessor.createCredit(account, directPaymentId, amount, currency, properties, internalCallContextFactory.createInternalCallContext(account.getId(), callContext));
+ return directPaymentProcessor.createCredit(account, directPaymentId, amount, currency, properties, callContext, internalCallContextFactory.createInternalCallContext(account.getId(), callContext));
}
@Override
@@ -89,7 +89,7 @@ public class DefaultDirectPaymentApi implements DirectPaymentApi {
@Override
public DirectPayment getPayment(final UUID paymentId, final boolean withPluginInfo, final Iterable<PluginProperty> properties, final TenantContext context) throws PaymentApiException {
- final DirectPayment payment = directPaymentProcessor.getPayment(paymentId, withPluginInfo, properties, internalCallContextFactory.createInternalTenantContext(context));
+ final DirectPayment payment = directPaymentProcessor.getPayment(paymentId, withPluginInfo, properties, context, internalCallContextFactory.createInternalTenantContext(context));
if (payment == null) {
throw new PaymentApiException(ErrorCode.PAYMENT_NO_SUCH_PAYMENT, paymentId);
}
@@ -98,11 +98,11 @@ public class DefaultDirectPaymentApi implements DirectPaymentApi {
@Override
public Pagination<DirectPayment> searchPayments(final String searchKey, final Long offset, final Long limit, final Iterable<PluginProperty> properties, final TenantContext context) {
- return directPaymentProcessor.searchPayments(searchKey, offset, limit, properties, internalCallContextFactory.createInternalTenantContext(context));
+ return directPaymentProcessor.searchPayments(searchKey, offset, limit, properties, context, internalCallContextFactory.createInternalTenantContext(context));
}
@Override
public Pagination<DirectPayment> searchPayments(final String searchKey, final Long offset, final Long limit, final String pluginName, final Iterable<PluginProperty> properties, final TenantContext context) throws PaymentApiException {
- return directPaymentProcessor.searchPayments(searchKey, offset, limit, pluginName, properties, internalCallContextFactory.createInternalTenantContext(context));
+ return directPaymentProcessor.searchPayments(searchKey, offset, limit, pluginName, properties, context, internalCallContextFactory.createInternalTenantContext(context));
}
}
diff --git a/payment/src/main/java/org/killbill/billing/payment/api/svcs/DefaultPaymentGatewayApi.java b/payment/src/main/java/org/killbill/billing/payment/api/svcs/DefaultPaymentGatewayApi.java
index b27a38c..31e2bd8 100644
--- a/payment/src/main/java/org/killbill/billing/payment/api/svcs/DefaultPaymentGatewayApi.java
+++ b/payment/src/main/java/org/killbill/billing/payment/api/svcs/DefaultPaymentGatewayApi.java
@@ -42,7 +42,7 @@ public class DefaultPaymentGatewayApi implements PaymentGatewayApi {
@Override
public HostedPaymentPageFormDescriptor buildFormDescriptor(final Account account, final Iterable<PluginProperty> customFields, final Iterable<PluginProperty> properties, final CallContext callContext) throws PaymentApiException {
- return paymentGatewayProcessor.buildFormDescriptor(account, customFields, properties, internalCallContextFactory.createInternalCallContext(account.getId(), callContext), callContext);
+ return paymentGatewayProcessor.buildFormDescriptor(account, customFields, properties, callContext, internalCallContextFactory.createInternalCallContext(account.getId(), callContext));
}
@Override
diff --git a/payment/src/main/java/org/killbill/billing/payment/bus/InvoiceHandler.java b/payment/src/main/java/org/killbill/billing/payment/bus/InvoiceHandler.java
index a4d0fe0..4687914 100644
--- a/payment/src/main/java/org/killbill/billing/payment/bus/InvoiceHandler.java
+++ b/payment/src/main/java/org/killbill/billing/payment/bus/InvoiceHandler.java
@@ -64,7 +64,7 @@ public class InvoiceHandler {
try {
final InternalCallContext internalContext = internalCallContextFactory.createInternalCallContext(event.getSearchKey2(), event.getSearchKey1(), "PaymentRequestProcessor", CallOrigin.INTERNAL, UserType.SYSTEM, event.getUserToken());
account = accountApi.getAccountById(event.getAccountId(), internalContext);
- paymentProcessor.createPayment(account, event.getInvoiceId(), null, internalContext, false, false, ImmutableList.<PluginProperty>of());
+ paymentProcessor.createPayment(account, event.getInvoiceId(), null, false, false, ImmutableList.<PluginProperty>of(), internalContext);
} catch (final AccountApiException e) {
log.error("Failed to process invoice payment", e);
} catch (final PaymentApiException e) {
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 e2b6283..150d7d8 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
@@ -31,7 +31,6 @@ import javax.inject.Inject;
import org.joda.time.DateTime;
import org.killbill.billing.ErrorCode;
-import org.killbill.billing.ObjectType;
import org.killbill.billing.account.api.Account;
import org.killbill.billing.account.api.AccountInternalApi;
import org.killbill.billing.callcontext.InternalCallContext;
@@ -110,7 +109,7 @@ public class DirectPaymentProcessor extends ProcessorBase {
this.paymentPluginDispatcher = new PluginDispatcher<DirectPayment>(paymentPluginTimeoutSec, executor);
}
- public DirectPayment createAuthorization(final Account account, @Nullable final UUID directPaymentId, final BigDecimal amount, final Currency currency, final String externalKey, final Iterable<PluginProperty> properties, final InternalCallContext callContext) throws PaymentApiException {
+ public DirectPayment createAuthorization(final Account account, @Nullable final UUID directPaymentId, final BigDecimal amount, final Currency currency, final String externalKey, final Iterable<PluginProperty> properties, final CallContext context, final InternalCallContext callContext) throws PaymentApiException {
return initiateDirectPayment(TransactionType.AUTHORIZE,
new PluginWrapper() {
@Override
@@ -124,11 +123,12 @@ public class DirectPaymentProcessor extends ProcessorBase {
amount,
currency,
properties,
+ context,
callContext
);
}
- public DirectPayment createCapture(final Account account, final UUID directPaymentId, final BigDecimal amount, final Currency currency, final Iterable<PluginProperty> properties, final InternalCallContext callContext) throws PaymentApiException {
+ public DirectPayment createCapture(final Account account, final UUID directPaymentId, final BigDecimal amount, final Currency currency, final Iterable<PluginProperty> properties, final CallContext context, final InternalCallContext callContext) throws PaymentApiException {
return createDirectPayment(TransactionType.CAPTURE,
new PluginWrapper() {
@Override
@@ -141,11 +141,12 @@ public class DirectPaymentProcessor extends ProcessorBase {
amount,
currency,
properties,
+ context,
callContext
);
}
- public DirectPayment createPurchase(final Account account, @Nullable final UUID directPaymentId, final BigDecimal amount, final Currency currency, final String externalKey, final Iterable<PluginProperty> properties, final InternalCallContext callContext) throws PaymentApiException {
+ public DirectPayment createPurchase(final Account account, @Nullable final UUID directPaymentId, final BigDecimal amount, final Currency currency, final String externalKey, final Iterable<PluginProperty> properties, final CallContext context, final InternalCallContext callContext) throws PaymentApiException {
return initiateDirectPayment(TransactionType.PURCHASE,
new PluginWrapper() {
@Override
@@ -159,11 +160,12 @@ public class DirectPaymentProcessor extends ProcessorBase {
amount,
currency,
properties,
+ context,
callContext
);
}
- public DirectPayment createVoid(final Account account, final UUID directPaymentId, final Iterable<PluginProperty> properties, final InternalCallContext callContext) throws PaymentApiException {
+ public DirectPayment createVoid(final Account account, final UUID directPaymentId, final Iterable<PluginProperty> properties, final CallContext context, final InternalCallContext callContext) throws PaymentApiException {
return createDirectPayment(TransactionType.VOID,
new PluginWrapper() {
@Override
@@ -176,11 +178,12 @@ public class DirectPaymentProcessor extends ProcessorBase {
null,
null,
properties,
+ context,
callContext
);
}
- public DirectPayment createCredit(final Account account, final UUID directPaymentId, final BigDecimal amount, final Currency currency, final Iterable<PluginProperty> properties, final InternalCallContext callContext) throws PaymentApiException {
+ public DirectPayment createCredit(final Account account, final UUID directPaymentId, final BigDecimal amount, final Currency currency, final Iterable<PluginProperty> properties, final CallContext context, final InternalCallContext callContext) throws PaymentApiException {
return createDirectPayment(TransactionType.CREDIT,
new PluginWrapper() {
@Override
@@ -193,6 +196,7 @@ public class DirectPaymentProcessor extends ProcessorBase {
amount,
currency,
properties,
+ context,
callContext
);
}
@@ -210,7 +214,7 @@ public class DirectPaymentProcessor extends ProcessorBase {
});
}
- public DirectPayment getPayment(final UUID directPaymentId, final boolean withPluginInfo, final Iterable<PluginProperty> properties, final InternalTenantContext tenantContext) throws PaymentApiException {
+ public DirectPayment getPayment(final UUID directPaymentId, final boolean withPluginInfo, final Iterable<PluginProperty> properties, final TenantContext context, final InternalTenantContext tenantContext) throws PaymentApiException {
final DirectPaymentModelDao paymentModelDao = paymentDao.getDirectPayment(directPaymentId, tenantContext);
if (paymentModelDao == null) {
return null;
@@ -223,7 +227,7 @@ public class DirectPaymentProcessor extends ProcessorBase {
PaymentInfoPlugin pluginInfo = null;
if (plugin != null) {
try {
- pluginInfo = plugin.getPaymentInfo(paymentModelDao.getAccountId(), directPaymentId, properties, buildTenantContext(tenantContext));
+ pluginInfo = plugin.getPaymentInfo(paymentModelDao.getAccountId(), directPaymentId, properties, context);
} catch (final PaymentPluginApiException e) {
throw new PaymentApiException(ErrorCode.PAYMENT_PLUGIN_GET_PAYMENT_INFO, directPaymentId, e.toString());
}
@@ -273,20 +277,20 @@ public class DirectPaymentProcessor extends ProcessorBase {
);
}
- public Pagination<DirectPayment> searchPayments(final String searchKey, final Long offset, final Long limit, final Iterable<PluginProperty> properties, final InternalTenantContext internalTenantContext) {
+ public Pagination<DirectPayment> searchPayments(final String searchKey, final Long offset, final Long limit, final Iterable<PluginProperty> properties, final TenantContext tenantContext, final InternalTenantContext internalTenantContext) {
return getEntityPaginationFromPlugins(getAvailablePlugins(),
offset,
limit,
new EntityPaginationBuilder<DirectPayment, PaymentApiException>() {
@Override
public Pagination<DirectPayment> build(final Long offset, final Long limit, final String pluginName) throws PaymentApiException {
- return searchPayments(searchKey, offset, limit, pluginName, properties, internalTenantContext);
+ return searchPayments(searchKey, offset, limit, pluginName, properties, tenantContext, internalTenantContext);
}
}
);
}
- public Pagination<DirectPayment> searchPayments(final String searchKey, final Long offset, final Long limit, final String pluginName, final Iterable<PluginProperty> properties, final InternalTenantContext internalTenantContext) throws PaymentApiException {
+ public Pagination<DirectPayment> searchPayments(final String searchKey, final Long offset, final Long limit, final String pluginName, final Iterable<PluginProperty> properties, final TenantContext tenantContext, final InternalTenantContext internalTenantContext) throws PaymentApiException {
final PaymentPluginApi pluginApi = getPaymentPluginApi(pluginName);
return getEntityPagination(limit,
@@ -294,7 +298,7 @@ public class DirectPaymentProcessor extends ProcessorBase {
@Override
public Pagination<PaymentInfoPlugin> build() throws PaymentApiException {
try {
- return pluginApi.searchPayments(searchKey, offset, limit, properties, buildTenantContext(internalTenantContext));
+ return pluginApi.searchPayments(searchKey, offset, limit, properties, tenantContext);
} catch (final PaymentPluginApiException e) {
throw new PaymentApiException(e, ErrorCode.PAYMENT_PLUGIN_SEARCH_PAYMENTS, pluginName, searchKey);
}
@@ -363,7 +367,7 @@ public class DirectPaymentProcessor extends ProcessorBase {
}
private DirectPayment initiateDirectPayment(final TransactionType transactionType, final PluginWrapper pluginWrapper, @Nullable final UUID directPaymentId, final String externalKey, final Account account,
- final BigDecimal amount, final Currency currency, final Iterable<PluginProperty> properties, final InternalCallContext callContext) throws PaymentApiException {
+ final BigDecimal amount, final Currency currency, final Iterable<PluginProperty> properties, final CallContext context, final InternalCallContext callContext) throws PaymentApiException {
Preconditions.checkArgument(account.getCurrency().equals(currency), String.format("Currency %s doesn't match the one on the account (%s)", currency, currency));
try {
@@ -396,7 +400,7 @@ public class DirectPaymentProcessor extends ProcessorBase {
paymentTransactionModelDao = paymentDao.updateDirectPaymentWithNewTransaction(directPaymentId, ptmd, callContext);
}
- return getDirectPayment(pluginWrapper, account, amount, currency, paymentModelDao.getId(), paymentTransactionModelDao.getId(), properties, callContext);
+ return getDirectPayment(pluginWrapper, account, amount, currency, paymentModelDao.getId(), paymentTransactionModelDao.getId(), properties, context, callContext);
}
}
));
@@ -410,7 +414,7 @@ public class DirectPaymentProcessor extends ProcessorBase {
private DirectPayment createDirectPayment(final TransactionType transactionType, final PluginWrapper pluginWrapper, final UUID directPaymentId,
final Account account, @Nullable final BigDecimal amount, @Nullable final Currency currency,
- final Iterable<PluginProperty> properties, final InternalCallContext callContext) throws PaymentApiException {
+ final Iterable<PluginProperty> properties, final CallContext context, final InternalCallContext callContext) throws PaymentApiException {
Preconditions.checkArgument((amount == null && currency == null) || account.getCurrency().equals(currency), String.format("Currency %s doesn't match the one on the account (%s)", currency, currency));
try {
@@ -426,7 +430,7 @@ public class DirectPaymentProcessor extends ProcessorBase {
amount, currency, null, null);
final DirectPaymentTransactionModelDao inserted = paymentDao.updateDirectPaymentWithNewTransaction(directPaymentId, ptmd, callContext);
- return getDirectPayment(pluginWrapper, account, amount, currency, directPaymentId, inserted.getId(), properties, callContext);
+ return getDirectPayment(pluginWrapper, account, amount, currency, directPaymentId, inserted.getId(), properties, context, callContext);
}
}
));
@@ -440,14 +444,13 @@ public class DirectPaymentProcessor extends ProcessorBase {
private DirectPayment getDirectPayment(final PluginWrapper pluginWrapper, final Account account, @Nullable final BigDecimal amount, @Nullable final Currency currency,
final UUID directPaymentId, final UUID directPaymentTransactionId, final Iterable<PluginProperty> properties,
- final InternalCallContext callContext) throws PaymentApiException {
- final UUID tenantId = nonEntityDao.retrieveIdFromObject(callContext.getTenantRecordId(), ObjectType.TENANT);
+ final CallContext context, final InternalCallContext callContext) throws PaymentApiException {
final PaymentPluginApi plugin = getPaymentProviderPlugin(account, callContext);
try {
final PaymentInfoPlugin infoPlugin;
try {
- infoPlugin = pluginWrapper.doPluginOperation(plugin, account, amount, directPaymentId, properties, callContext.toCallContext(tenantId));
+ infoPlugin = pluginWrapper.doPluginOperation(plugin, account, amount, directPaymentId, properties, context);
} 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 direct payment %s", directPaymentId);
@@ -459,7 +462,7 @@ public class DirectPaymentProcessor extends ProcessorBase {
paymentDao.updateDirectPaymentAndTransactionOnCompletion(directPaymentId, PaymentStatus.PAYMENT_FAILURE_ABORTED, amount, currency, directPaymentTransactionId, null, e.getMessage(), callContext);
}
- return getPayment(directPaymentId, false, properties, callContext);
+ return getPayment(directPaymentId, false, properties, context, callContext);
}
private PaymentStatus processPaymentInfoPlugin(final PaymentInfoPlugin infoPlugin, final Account account, @Nullable final BigDecimal amount, @Nullable final Currency currency,
diff --git a/payment/src/main/java/org/killbill/billing/payment/core/PaymentGatewayProcessor.java b/payment/src/main/java/org/killbill/billing/payment/core/PaymentGatewayProcessor.java
index 695c7ca..abf7d54 100644
--- a/payment/src/main/java/org/killbill/billing/payment/core/PaymentGatewayProcessor.java
+++ b/payment/src/main/java/org/killbill/billing/payment/core/PaymentGatewayProcessor.java
@@ -75,7 +75,7 @@ public class PaymentGatewayProcessor extends ProcessorBase {
this.paymentPluginNotificationDispatcher = new PluginDispatcher<GatewayNotification>(paymentPluginTimeoutSec, executor);
}
- public HostedPaymentPageFormDescriptor buildFormDescriptor(final Account account, final Iterable<PluginProperty> customFields, final Iterable<PluginProperty> properties, final InternalCallContext internalCallContext, final CallContext callContext) throws PaymentApiException {
+ public HostedPaymentPageFormDescriptor buildFormDescriptor(final Account account, final Iterable<PluginProperty> customFields, final Iterable<PluginProperty> properties, final CallContext callContext, final InternalCallContext internalCallContext) throws PaymentApiException {
try {
return paymentPluginFormDispatcher.dispatchWithTimeout(new CallableWithAccountLock<HostedPaymentPageFormDescriptor>(locker,
account.getExternalKey(),
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 705af4a..8c87be2 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
@@ -27,7 +27,6 @@ import java.util.concurrent.ExecutorService;
import javax.annotation.Nullable;
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;
@@ -49,6 +48,7 @@ import org.killbill.billing.payment.provider.DefaultNoOpPaymentMethodPlugin;
import org.killbill.billing.payment.provider.DefaultPaymentMethodInfoPlugin;
import org.killbill.billing.payment.provider.ExternalPaymentProviderPlugin;
import org.killbill.billing.tag.TagInternalApi;
+import org.killbill.billing.util.callcontext.CallContext;
import org.killbill.billing.util.callcontext.TenantContext;
import org.killbill.billing.util.dao.NonEntityDao;
import org.killbill.billing.util.entity.Pagination;
@@ -88,20 +88,18 @@ public class PaymentMethodProcessor extends ProcessorBase {
public UUID addPaymentMethod(final String paymentPluginServiceName, final Account account,
final boolean setDefault, final PaymentMethodPlugin paymentMethodProps,
- final Iterable<PluginProperty> properties, final InternalCallContext context)
+ final Iterable<PluginProperty> properties, final CallContext callContext, final InternalCallContext context)
throws PaymentApiException {
- final UUID tenantId = nonEntityDao.retrieveIdFromObject(context.getTenantRecordId(), ObjectType.TENANT);
-
return new WithAccountLock<UUID>().processAccountWithLock(locker, account.getExternalKey(), new WithAccountLockCallback<UUID>() {
@Override
public UUID doOperation() throws PaymentApiException {
PaymentMethod pm = null;
- PaymentPluginApi pluginApi = null;
+ PaymentPluginApi pluginApi;
try {
pluginApi = getPaymentPluginApi(paymentPluginServiceName);
pm = new DefaultPaymentMethod(account.getId(), paymentPluginServiceName, paymentMethodProps);
- pluginApi.addPaymentMethod(account.getId(), pm.getId(), paymentMethodProps, setDefault, properties, context.toCallContext(tenantId));
+ pluginApi.addPaymentMethod(account.getId(), pm.getId(), paymentMethodProps, setDefault, properties, callContext);
final PaymentMethodModelDao pmModel = new PaymentMethodModelDao(pm.getId(), pm.getCreatedDate(), pm.getUpdatedDate(),
pm.getAccountId(), pm.getPluginName(), pm.isActive());
paymentDao.insertPaymentMethod(pmModel, context);
@@ -122,30 +120,38 @@ public class PaymentMethodProcessor extends ProcessorBase {
}
public List<PaymentMethod> getPaymentMethods(final Account account, final boolean withPluginInfo, final Iterable<PluginProperty> properties, final InternalTenantContext context) throws PaymentApiException {
+ return getPaymentMethods(account, withPluginInfo, properties, buildTenantContext(context), context);
+ }
+ public List<PaymentMethod> getPaymentMethods(final Account account, final boolean withPluginInfo, final Iterable<PluginProperty> properties, final TenantContext tenantContext, final InternalTenantContext context) throws PaymentApiException {
final List<PaymentMethodModelDao> paymentMethodModels = paymentDao.getPaymentMethods(account.getId(), context);
if (paymentMethodModels.size() == 0) {
return Collections.emptyList();
}
- return getPaymentMethodInternal(paymentMethodModels, withPluginInfo, properties, context);
+ return getPaymentMethodInternal(paymentMethodModels, withPluginInfo, properties, tenantContext, context);
}
public PaymentMethod getPaymentMethodById(final UUID paymentMethodId, final boolean includedDeleted, final boolean withPluginInfo, final Iterable<PluginProperty> properties, final InternalTenantContext context)
throws PaymentApiException {
+ return getPaymentMethodById(paymentMethodId, includedDeleted, withPluginInfo, properties, buildTenantContext(context), context);
+ }
+
+ public PaymentMethod getPaymentMethodById(final UUID paymentMethodId, final boolean includedDeleted, final boolean withPluginInfo, final Iterable<PluginProperty> properties, final TenantContext tenantContext, final InternalTenantContext context)
+ throws PaymentApiException {
final PaymentMethodModelDao paymentMethodModel = includedDeleted ? paymentDao.getPaymentMethodIncludedDeleted(paymentMethodId, context) : paymentDao.getPaymentMethod(paymentMethodId, context);
if (paymentMethodModel == null) {
throw new PaymentApiException(ErrorCode.PAYMENT_NO_SUCH_PAYMENT_METHOD, paymentMethodId);
}
- return buildDefaultPaymentMethod(paymentMethodModel, withPluginInfo, properties, context);
+ return buildDefaultPaymentMethod(paymentMethodModel, withPluginInfo, properties, tenantContext, context);
}
- private PaymentMethod buildDefaultPaymentMethod(final PaymentMethodModelDao paymentMethodModelDao, final boolean withPluginInfo, final Iterable<PluginProperty> properties, final InternalTenantContext context) throws PaymentApiException {
+ private PaymentMethod buildDefaultPaymentMethod(final PaymentMethodModelDao paymentMethodModelDao, final boolean withPluginInfo, final Iterable<PluginProperty> properties, final TenantContext tenantContext, final InternalTenantContext context) throws PaymentApiException {
final PaymentMethodPlugin paymentMethodPlugin;
if (withPluginInfo) {
try {
final PaymentPluginApi pluginApi = getPaymentPluginApi(paymentMethodModelDao.getPluginName());
- paymentMethodPlugin = pluginApi.getPaymentMethodDetail(paymentMethodModelDao.getAccountId(), paymentMethodModelDao.getId(), properties, buildTenantContext(context));
+ paymentMethodPlugin = pluginApi.getPaymentMethodDetail(paymentMethodModelDao.getAccountId(), paymentMethodModelDao.getId(), properties, tenantContext);
} 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());
@@ -198,21 +204,21 @@ public class PaymentMethodProcessor extends ProcessorBase {
);
}
- public Pagination<PaymentMethod> searchPaymentMethods(final String searchKey, final Long offset, final Long limit, final Iterable<PluginProperty> properties, final InternalTenantContext internalTenantContext) {
+ public Pagination<PaymentMethod> searchPaymentMethods(final String searchKey, final Long offset, final Long limit, final Iterable<PluginProperty> properties, final TenantContext tenantContext, final InternalTenantContext internalTenantContext) {
return getEntityPaginationFromPlugins(getAvailablePlugins(),
offset,
limit,
new EntityPaginationBuilder<PaymentMethod, PaymentApiException>() {
@Override
public Pagination<PaymentMethod> build(final Long offset, final Long limit, final String pluginName) throws PaymentApiException {
- return searchPaymentMethods(searchKey, offset, limit, pluginName, properties, internalTenantContext);
+ return searchPaymentMethods(searchKey, offset, limit, pluginName, properties, tenantContext, internalTenantContext);
}
}
);
}
public Pagination<PaymentMethod> searchPaymentMethods(final String searchKey, final Long offset, final Long limit, final String pluginName,
- final Iterable<PluginProperty> properties, final InternalTenantContext internalTenantContext) throws PaymentApiException {
+ final Iterable<PluginProperty> properties, final TenantContext tenantContext, final InternalTenantContext internalTenantContext) throws PaymentApiException {
final PaymentPluginApi pluginApi = getPaymentPluginApi(pluginName);
return getEntityPagination(limit,
@@ -220,7 +226,7 @@ public class PaymentMethodProcessor extends ProcessorBase {
@Override
public Pagination<PaymentMethodPlugin> build() throws PaymentApiException {
try {
- return pluginApi.searchPaymentMethods(searchKey, offset, limit, properties, buildTenantContext(internalTenantContext));
+ return pluginApi.searchPaymentMethods(searchKey, offset, limit, properties, tenantContext);
} catch (final PaymentPluginApiException e) {
throw new PaymentApiException(e, ErrorCode.PAYMENT_PLUGIN_SEARCH_PAYMENT_METHODS, pluginName, searchKey);
}
@@ -247,8 +253,8 @@ public class PaymentMethodProcessor extends ProcessorBase {
);
}
- public PaymentMethod getExternalPaymentMethod(final Account account, final Iterable<PluginProperty> properties, final InternalTenantContext context) throws PaymentApiException {
- final List<PaymentMethod> paymentMethods = getPaymentMethods(account, false, properties, context);
+ public PaymentMethod getExternalPaymentMethod(final Account account, final Iterable<PluginProperty> properties, final TenantContext tenantContext, final InternalTenantContext context) throws PaymentApiException {
+ final List<PaymentMethod> paymentMethods = getPaymentMethods(account, false, properties, tenantContext, context);
for (final PaymentMethod paymentMethod : paymentMethods) {
if (ExternalPaymentProviderPlugin.PLUGIN_NAME.equals(paymentMethod.getPluginName())) {
return paymentMethod;
@@ -258,23 +264,23 @@ public class PaymentMethodProcessor extends ProcessorBase {
return null;
}
- public ExternalPaymentProviderPlugin getExternalPaymentProviderPlugin(final Account account, final Iterable<PluginProperty> properties, final InternalCallContext context) throws PaymentApiException {
+ public ExternalPaymentProviderPlugin getExternalPaymentProviderPlugin(final Account account, final Iterable<PluginProperty> properties, final CallContext callContext, final InternalCallContext context) throws PaymentApiException {
// 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, properties, context) == null) {
+ if (getExternalPaymentMethod(account, properties, callContext, context) == null) {
final DefaultNoOpPaymentMethodPlugin props = new DefaultNoOpPaymentMethodPlugin(UUID.randomUUID().toString(), false, properties);
- addPaymentMethod(ExternalPaymentProviderPlugin.PLUGIN_NAME, account, false, props, properties, context);
+ addPaymentMethod(ExternalPaymentProviderPlugin.PLUGIN_NAME, account, false, props, properties, callContext, context);
}
return (ExternalPaymentProviderPlugin) getPaymentPluginApi(ExternalPaymentProviderPlugin.PLUGIN_NAME);
}
- private List<PaymentMethod> getPaymentMethodInternal(final List<PaymentMethodModelDao> paymentMethodModels, final boolean withPluginInfo, final Iterable<PluginProperty> properties, final InternalTenantContext context)
+ private List<PaymentMethod> getPaymentMethodInternal(final List<PaymentMethodModelDao> paymentMethodModels, final boolean withPluginInfo, final Iterable<PluginProperty> properties, final TenantContext tenantContext, final InternalTenantContext context)
throws PaymentApiException {
final List<PaymentMethod> result = new ArrayList<PaymentMethod>(paymentMethodModels.size());
for (final PaymentMethodModelDao paymentMethodModel : paymentMethodModels) {
- final PaymentMethod pm = buildDefaultPaymentMethod(paymentMethodModel, withPluginInfo, properties, context);
+ final PaymentMethod pm = buildDefaultPaymentMethod(paymentMethodModel, withPluginInfo, properties, tenantContext, context);
result.add(pm);
}
return result;
@@ -282,10 +288,8 @@ public class PaymentMethodProcessor extends ProcessorBase {
public void deletedPaymentMethod(final Account account, final UUID paymentMethodId,
final boolean deleteDefaultPaymentMethodWithAutoPayOff,
- final Iterable<PluginProperty> properties, final InternalCallContext context)
+ final Iterable<PluginProperty> properties, final CallContext callContext, final InternalCallContext context)
throws PaymentApiException {
- final UUID tenantId = nonEntityDao.retrieveIdFromObject(context.getTenantRecordId(), ObjectType.TENANT);
-
new WithAccountLock<Void>().processAccountWithLock(locker, account.getExternalKey(), new WithAccountLockCallback<Void>() {
@Override
@@ -310,7 +314,7 @@ public class PaymentMethodProcessor extends ProcessorBase {
}
}
final PaymentPluginApi pluginApi = getPluginApi(paymentMethodId, context);
- pluginApi.deletePaymentMethod(account.getId(), paymentMethodId, properties, context.toCallContext(tenantId));
+ pluginApi.deletePaymentMethod(account.getId(), paymentMethodId, properties, callContext);
paymentDao.deletedPaymentMethod(paymentMethodId, context);
return null;
} catch (final PaymentPluginApiException e) {
@@ -323,10 +327,8 @@ public class PaymentMethodProcessor extends ProcessorBase {
});
}
- public void setDefaultPaymentMethod(final Account account, final UUID paymentMethodId, final Iterable<PluginProperty> properties, final InternalCallContext context)
+ public void setDefaultPaymentMethod(final Account account, final UUID paymentMethodId, final Iterable<PluginProperty> properties, final CallContext callContext, final InternalCallContext context)
throws PaymentApiException {
- final UUID tenantId = nonEntityDao.retrieveIdFromObject(context.getTenantRecordId(), ObjectType.TENANT);
-
new WithAccountLock<Void>().processAccountWithLock(locker, account.getExternalKey(), new WithAccountLockCallback<Void>() {
@Override
@@ -339,7 +341,7 @@ public class PaymentMethodProcessor extends ProcessorBase {
try {
final PaymentPluginApi pluginApi = getPluginApi(paymentMethodId, context);
- pluginApi.setDefaultPaymentMethod(account.getId(), paymentMethodId, properties, context.toCallContext(tenantId));
+ pluginApi.setDefaultPaymentMethod(account.getId(), paymentMethodId, properties, callContext);
accountInternalApi.updatePaymentMethod(account.getId(), paymentMethodId, context);
return null;
} catch (final PaymentPluginApiException e) {
@@ -371,14 +373,12 @@ public class PaymentMethodProcessor extends ProcessorBase {
* @return the list of payment methods -- should be identical between KB, the plugin view-- if it keeps a state-- and the gateway.
* @throws PaymentApiException
*/
- public List<PaymentMethod> refreshPaymentMethods(final String pluginName, final Account account, final Iterable<PluginProperty> properties, final InternalCallContext context) throws PaymentApiException {
- final UUID tenantId = nonEntityDao.retrieveIdFromObject(context.getTenantRecordId(), ObjectType.TENANT);
-
+ public List<PaymentMethod> refreshPaymentMethods(final String pluginName, final Account account, final Iterable<PluginProperty> properties, final CallContext callContext, final InternalCallContext context) throws PaymentApiException {
// Don't hold the account lock while fetching the payment methods from the gateway as those could change anyway
final PaymentPluginApi pluginApi = getPaymentPluginApi(pluginName);
final List<PaymentMethodInfoPlugin> pluginPms;
try {
- pluginPms = pluginApi.getPaymentMethods(account.getId(), true, properties, context.toCallContext(tenantId));
+ pluginPms = pluginApi.getPaymentMethods(account.getId(), true, properties, callContext);
// 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);
@@ -421,7 +421,7 @@ public class PaymentMethodProcessor extends ProcessorBase {
finalPaymentMethods,
context);
try {
- pluginApi.resetPaymentMethods(account.getId(), pluginPmsWithId, properties);
+ pluginApi.resetPaymentMethods(account.getId(), pluginPmsWithId, properties, callContext);
} 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());
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 b0fc1d1..118c202 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
@@ -32,7 +32,6 @@ import javax.annotation.Nullable;
import javax.inject.Inject;
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;
@@ -65,6 +64,7 @@ import org.killbill.billing.payment.retry.AutoPayRetryService.AutoPayRetryServic
import org.killbill.billing.payment.retry.FailedPaymentRetryService.FailedPaymentRetryServiceScheduler;
import org.killbill.billing.payment.retry.PluginFailureRetryService.PluginFailureRetryServiceScheduler;
import org.killbill.billing.tag.TagInternalApi;
+import org.killbill.billing.util.callcontext.CallContext;
import org.killbill.billing.util.callcontext.TenantContext;
import org.killbill.billing.util.config.PaymentConfig;
import org.killbill.billing.util.dao.NonEntityDao;
@@ -133,6 +133,10 @@ public class PaymentProcessor extends ProcessorBase {
}
public Payment getPayment(final UUID paymentId, final boolean withPluginInfo, final Iterable<PluginProperty> properties, final InternalTenantContext context) throws PaymentApiException {
+ return getPayment(paymentId, withPluginInfo, properties, buildTenantContext(context), context);
+ }
+
+ public Payment getPayment(final UUID paymentId, final boolean withPluginInfo, final Iterable<PluginProperty> properties, final TenantContext tenantContext, final InternalTenantContext context) throws PaymentApiException {
final PaymentModelDao model = paymentDao.getPayment(paymentId, context);
if (model == null) {
return null;
@@ -141,7 +145,7 @@ public class PaymentProcessor extends ProcessorBase {
PaymentInfoPlugin pluginInfo = null;
if (plugin != null) {
try {
- pluginInfo = plugin.getPaymentInfo(model.getAccountId(), paymentId, properties, buildTenantContext(context));
+ pluginInfo = plugin.getPaymentInfo(model.getAccountId(), paymentId, properties, tenantContext);
} catch (final PaymentPluginApiException e) {
throw new PaymentApiException(ErrorCode.PAYMENT_PLUGIN_GET_PAYMENT_INFO, paymentId, e.toString());
}
@@ -191,20 +195,20 @@ public class PaymentProcessor extends ProcessorBase {
);
}
- public Pagination<Payment> searchPayments(final String searchKey, final Long offset, final Long limit, final Iterable<PluginProperty> properties, final InternalTenantContext internalTenantContext) {
+ public Pagination<Payment> searchPayments(final String searchKey, final Long offset, final Long limit, final Iterable<PluginProperty> properties, final TenantContext tenantContext, final InternalTenantContext internalTenantContext) {
return getEntityPaginationFromPlugins(getAvailablePlugins(),
offset,
limit,
new EntityPaginationBuilder<Payment, PaymentApiException>() {
@Override
public Pagination<Payment> build(final Long offset, final Long limit, final String pluginName) throws PaymentApiException {
- return searchPayments(searchKey, offset, limit, pluginName, properties, internalTenantContext);
+ return searchPayments(searchKey, offset, limit, pluginName, properties, tenantContext, internalTenantContext);
}
}
);
}
- public Pagination<Payment> searchPayments(final String searchKey, final Long offset, final Long limit, final String pluginName, final Iterable<PluginProperty> properties, final InternalTenantContext internalTenantContext) throws PaymentApiException {
+ public Pagination<Payment> searchPayments(final String searchKey, final Long offset, final Long limit, final String pluginName, final Iterable<PluginProperty> properties, final TenantContext tenantContext, final InternalTenantContext internalTenantContext) throws PaymentApiException {
final PaymentPluginApi pluginApi = getPaymentPluginApi(pluginName);
return getEntityPagination(limit,
@@ -212,7 +216,7 @@ public class PaymentProcessor extends ProcessorBase {
@Override
public Pagination<PaymentInfoPlugin> build() throws PaymentApiException {
try {
- return pluginApi.searchPayments(searchKey, offset, limit, properties, buildTenantContext(internalTenantContext));
+ return pluginApi.searchPayments(searchKey, offset, limit, properties, tenantContext);
} catch (final PaymentPluginApiException e) {
throw new PaymentApiException(e, ErrorCode.PAYMENT_PLUGIN_SEARCH_PAYMENTS, pluginName, searchKey);
}
@@ -316,8 +320,13 @@ public class PaymentProcessor extends ProcessorBase {
}
public Payment createPayment(final Account account, final UUID invoiceId, @Nullable final BigDecimal inputAmount,
- final InternalCallContext context, final boolean isInstantPayment,
- final boolean isExternalPayment, final Iterable<PluginProperty> properties)
+ final boolean isInstantPayment, final boolean isExternalPayment, final Iterable<PluginProperty> properties, final InternalCallContext context)
+ throws PaymentApiException {
+ return createPayment(account, invoiceId, inputAmount, isInstantPayment, isExternalPayment, properties, buildCallContext(context), context);
+ }
+
+ public Payment createPayment(final Account account, final UUID invoiceId, @Nullable final BigDecimal inputAmount,
+ final boolean isInstantPayment, final boolean isExternalPayment, final Iterable<PluginProperty> properties, final CallContext callContext, final InternalCallContext context)
throws PaymentApiException {
// If this is an external payment, retrieve the external payment method first.
// We need to do this without the lock, because getExternalPaymentProviderPlugin will acquire the lock
@@ -326,7 +335,7 @@ public class PaymentProcessor extends ProcessorBase {
// (to avoid throwing an exception if there is nothing to pay).
final PaymentPluginApi externalPaymentPlugin;
if (isExternalPayment) {
- externalPaymentPlugin = paymentMethodProcessor.getExternalPaymentProviderPlugin(account, properties, context);
+ externalPaymentPlugin = paymentMethodProcessor.getExternalPaymentProviderPlugin(account, properties, callContext, context);
} else {
externalPaymentPlugin = null;
}
@@ -357,7 +366,7 @@ public class PaymentProcessor extends ProcessorBase {
// Use the special external payment plugin to handle external payments
if (isExternalPayment) {
plugin = externalPaymentPlugin;
- paymentMethodId = paymentMethodProcessor.getExternalPaymentMethod(account, properties, context).getId();
+ paymentMethodId = paymentMethodProcessor.getExternalPaymentMethod(account, properties, callContext, context).getId();
} else {
plugin = getPaymentProviderPlugin(account, context);
paymentMethodId = account.getPaymentMethodId();
@@ -384,7 +393,7 @@ public class PaymentProcessor extends ProcessorBase {
if (!isInstantPayment && isAccountAutoPayOff) {
return processNewPaymentForAutoPayOffWithAccountLocked(paymentMethodId, account, invoice, requestedAmount, context);
} else {
- return processNewPaymentWithAccountLocked(paymentMethodId, plugin, account, invoice, requestedAmount, isInstantPayment, properties, context);
+ return processNewPaymentWithAccountLocked(paymentMethodId, plugin, account, invoice, requestedAmount, isInstantPayment, properties, callContext, context);
}
} catch (final InvoiceApiException e) {
throw new PaymentApiException(e);
@@ -474,7 +483,6 @@ public class PaymentProcessor extends ProcessorBase {
}
public void retryPluginFailure(final UUID paymentId, final Iterable<PluginProperty> properties, final InternalCallContext context) {
-
retryFailedPaymentInternal(paymentId, properties, context, PaymentStatus.PLUGIN_FAILURE);
}
@@ -483,9 +491,9 @@ public class PaymentProcessor extends ProcessorBase {
retryFailedPaymentInternal(paymentId, properties, context, PaymentStatus.PAYMENT_FAILURE);
}
- public void retryPaymentFromApi(final UUID paymentId, final Iterable<PluginProperty> properties, final InternalCallContext context) {
+ public void retryPaymentFromApi(final UUID paymentId, final Iterable<PluginProperty> properties, final CallContext callContext, final InternalCallContext context) {
log.info("Retrying payment " + paymentId + " time = " + clock.getUTCNow());
- retryFailedPaymentInternal(paymentId, properties, context,
+ retryFailedPaymentInternal(paymentId, properties, callContext, context,
PaymentStatus.UNKNOWN,
PaymentStatus.AUTO_PAY_OFF,
PaymentStatus.PAYMENT_FAILURE,
@@ -493,7 +501,10 @@ public class PaymentProcessor extends ProcessorBase {
}
private void retryFailedPaymentInternal(final UUID paymentId, final Iterable<PluginProperty> properties, final InternalCallContext context, final PaymentStatus... expectedPaymentStates) {
+ retryFailedPaymentInternal(paymentId, properties, buildCallContext(context), context, expectedPaymentStates);
+ }
+ private void retryFailedPaymentInternal(final UUID paymentId, final Iterable<PluginProperty> properties, final CallContext callContext, final InternalCallContext context, final PaymentStatus... expectedPaymentStates) {
try {
final PaymentModelDao payment = paymentDao.getPayment(paymentId, context);
@@ -540,7 +551,7 @@ public class PaymentProcessor extends ProcessorBase {
setTerminalStateOnRetryWithAccountLocked(account, invoice, payment, invoice.getBalance(), "Paid invoice", context);
return null;
}
- processRetryPaymentWithAccountLocked(plugin, account, invoice, payment, invoice.getBalance(), properties, context);
+ processRetryPaymentWithAccountLocked(plugin, account, invoice, payment, invoice.getBalance(), properties, callContext, context);
return null;
} catch (final InvoiceApiException e) {
throw new PaymentApiException(e);
@@ -585,13 +596,14 @@ public class PaymentProcessor extends ProcessorBase {
}
private Payment processNewPaymentWithAccountLocked(final UUID paymentMethodId, final PaymentPluginApi plugin, final Account account, final Invoice invoice,
- final BigDecimal requestedAmount, final boolean isInstantPayment, final Iterable<PluginProperty> properties, final InternalCallContext context) throws PaymentApiException {
+ final BigDecimal requestedAmount, final boolean isInstantPayment, final Iterable<PluginProperty> properties,
+ final CallContext callContext, final InternalCallContext context) throws PaymentApiException {
final PaymentModelDao payment = new PaymentModelDao(account.getId(), invoice.getId(), paymentMethodId, requestedAmount, invoice.getCurrency(), clock.getUTCNow());
final PaymentAttemptModelDao attempt = new PaymentAttemptModelDao(account.getId(), invoice.getId(), payment.getId(), paymentMethodId, clock.getUTCNow(),
requestedAmount, invoice.getCurrency());
final PaymentModelDao savedPayment = paymentDao.insertPaymentWithFirstAttempt(payment, attempt, context);
- return processPaymentWithAccountLocked(plugin, account, invoice, savedPayment, attempt, isInstantPayment, properties, context);
+ return processPaymentWithAccountLocked(plugin, account, invoice, savedPayment, attempt, isInstantPayment, properties, callContext, context);
}
private Payment setTerminalStateOnRetryWithAccountLocked(final Account account, final Invoice invoice, final PaymentModelDao payment, final BigDecimal requestedAmount, final String terminalStateReason, final InternalCallContext context) {
@@ -622,19 +634,19 @@ public class PaymentProcessor extends ProcessorBase {
}
private Payment processRetryPaymentWithAccountLocked(final PaymentPluginApi plugin, final Account account, final Invoice invoice, final PaymentModelDao payment,
- final BigDecimal requestedAmount, final Iterable<PluginProperty> properties, final InternalCallContext context) throws PaymentApiException {
+ final BigDecimal requestedAmount, final Iterable<PluginProperty> properties,
+ final CallContext callContext, final InternalCallContext context) throws PaymentApiException {
final PaymentAttemptModelDao attempt = new PaymentAttemptModelDao(account.getId(), invoice.getId(), payment.getId(), account.getPaymentMethodId(), clock.getUTCNow(),
requestedAmount, invoice.getCurrency());
paymentDao.updatePaymentWithNewAttempt(payment.getId(), attempt, context);
- return processPaymentWithAccountLocked(plugin, account, invoice, payment, attempt, false, properties, context);
+ return processPaymentWithAccountLocked(plugin, account, invoice, payment, attempt, false, properties, callContext, context);
}
private Payment processPaymentWithAccountLocked(final PaymentPluginApi plugin, final Account account, final Invoice invoice,
final PaymentModelDao paymentInput, final PaymentAttemptModelDao attemptInput,
- final boolean isInstantPayment, final Iterable<PluginProperty> properties, final InternalCallContext context)
+ final boolean isInstantPayment, final Iterable<PluginProperty> properties,
+ final CallContext callContext, final InternalCallContext context)
throws PaymentApiException {
- final UUID tenantId = nonEntityDao.retrieveIdFromObject(context.getTenantRecordId(), ObjectType.TENANT);
-
List<PaymentAttemptModelDao> allAttempts = null;
if (paymentConfig.isPaymentOff()) {
paymentDao.updatePaymentAndAttemptOnCompletion(paymentInput.getId(), PaymentStatus.PAYMENT_SYSTEM_OFF,
@@ -650,7 +662,7 @@ public class PaymentProcessor extends ProcessorBase {
try {
try {
paymentPluginInfo = plugin.processPayment(account.getId(), paymentInput.getId(), attemptInput.getPaymentMethodId(),
- attemptInput.getRequestedAmount(), account.getCurrency(), properties, context.toCallContext(tenantId));
+ attemptInput.getRequestedAmount(), account.getCurrency(), properties, callContext);
} 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());
diff --git a/payment/src/main/java/org/killbill/billing/payment/core/ProcessorBase.java b/payment/src/main/java/org/killbill/billing/payment/core/ProcessorBase.java
index 53ad47e..978cc3d 100644
--- a/payment/src/main/java/org/killbill/billing/payment/core/ProcessorBase.java
+++ b/payment/src/main/java/org/killbill/billing/payment/core/ProcessorBase.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,20 +26,12 @@ 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.AccountInternalApi;
-import org.killbill.bus.api.PersistentBus;
-import org.killbill.bus.api.PersistentBus.EventBusException;
import org.killbill.billing.callcontext.InternalCallContext;
import org.killbill.billing.callcontext.InternalTenantContext;
-import org.killbill.commons.locker.GlobalLock;
-import org.killbill.commons.locker.GlobalLocker;
-import org.killbill.commons.locker.LockFailedException;
import org.killbill.billing.events.BusInternalEvent;
import org.killbill.billing.invoice.api.Invoice;
import org.killbill.billing.invoice.api.InvoiceApiException;
@@ -49,11 +43,19 @@ import org.killbill.billing.payment.dao.PaymentMethodModelDao;
import org.killbill.billing.payment.plugin.api.PaymentPluginApi;
import org.killbill.billing.tag.TagInternalApi;
import org.killbill.billing.util.api.TagApiException;
+import org.killbill.billing.util.callcontext.CallContext;
import org.killbill.billing.util.callcontext.TenantContext;
import org.killbill.billing.util.dao.NonEntityDao;
import org.killbill.billing.util.globallocker.LockerType;
import org.killbill.billing.util.tag.ControlTagType;
import org.killbill.billing.util.tag.Tag;
+import org.killbill.bus.api.PersistentBus;
+import org.killbill.bus.api.PersistentBus.EventBusException;
+import org.killbill.commons.locker.GlobalLock;
+import org.killbill.commons.locker.GlobalLocker;
+import org.killbill.commons.locker.LockFailedException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import com.google.common.base.Function;
import com.google.common.collect.Collections2;
@@ -164,6 +166,10 @@ public abstract class ProcessorBase {
return context.toTenantContext(nonEntityDao.retrieveIdFromObject(context.getTenantRecordId(), ObjectType.TENANT));
}
+ protected CallContext buildCallContext(final InternalCallContext context) {
+ return context.toCallContext(nonEntityDao.retrieveIdFromObject(context.getTenantRecordId(), ObjectType.TENANT));
+ }
+
public interface WithAccountLockCallback<T> {
public T doOperation() throws PaymentApiException;
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 5bb884c..f6d5898 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
@@ -56,6 +56,7 @@ import org.killbill.billing.payment.plugin.api.PaymentPluginApiException;
import org.killbill.billing.payment.plugin.api.RefundInfoPlugin;
import org.killbill.billing.payment.plugin.api.RefundPluginStatus;
import org.killbill.billing.tag.TagInternalApi;
+import org.killbill.billing.util.callcontext.CallContext;
import org.killbill.billing.util.callcontext.CallOrigin;
import org.killbill.billing.util.callcontext.InternalCallContextFactory;
import org.killbill.billing.util.callcontext.TenantContext;
@@ -111,16 +112,15 @@ public class RefundProcessor extends ProcessorBase {
* @param specifiedRefundAmount amount to refund. If null, the amount will be the sum of adjusted invoice items
* @param isAdjusted whether the refund should trigger an invoice or invoice item adjustment
* @param invoiceItemIdsWithAmounts invoice item ids and associated amounts to adjust
- * @param context the call callcontext
+ * @param callContext the call context
+ * @param context the internal call context
* @return the created callcontext
* @throws PaymentApiException
*/
public Refund createRefund(final Account account, final UUID paymentId, @Nullable final BigDecimal specifiedRefundAmount,
final boolean isAdjusted, final Map<UUID, BigDecimal> invoiceItemIdsWithAmounts,
- final Iterable<PluginProperty> properties, final InternalCallContext context)
+ final Iterable<PluginProperty> properties, final CallContext callContext, final InternalCallContext context)
throws PaymentApiException {
- final UUID tenantId = nonEntityDao.retrieveIdFromObject(context.getTenantRecordId(), ObjectType.TENANT);
-
return new WithAccountLock<Refund>().processAccountWithLock(locker, account.getExternalKey(), new WithAccountLockCallback<Refund>() {
@Override
@@ -138,7 +138,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(), properties, context.toCallContext(tenantId));
+ final RefundInfoPlugin refundInfoPlugin = plugin.processRefund(account.getId(), paymentId, refundAmount, account.getCurrency(), properties, callContext);
switch (refundInfoPlugin.getStatus()) {
case PROCESSED:
@@ -245,7 +245,7 @@ public class RefundProcessor extends ProcessorBase {
throw new IllegalArgumentException("Unable to find invoice item for id " + itemId);
}
- public Refund getRefund(final UUID refundId, final boolean withPluginInfo, final Iterable<PluginProperty> properties, final InternalTenantContext context) throws PaymentApiException {
+ public Refund getRefund(final UUID refundId, final boolean withPluginInfo, final Iterable<PluginProperty> properties, final TenantContext tenantContext, final InternalTenantContext context) throws PaymentApiException {
RefundModelDao result = paymentDao.getRefund(refundId, context);
if (result == null) {
throw new PaymentApiException(ErrorCode.PAYMENT_NO_SUCH_REFUND, refundId);
@@ -269,7 +269,7 @@ public class RefundProcessor extends ProcessorBase {
List<RefundInfoPlugin> refundInfoPlugins = ImmutableList.<RefundInfoPlugin>of();
if (plugin != null) {
try {
- refundInfoPlugins = plugin.getRefundInfo(result.getAccountId(), result.getPaymentId(), properties, buildTenantContext(context));
+ refundInfoPlugins = plugin.getRefundInfo(result.getAccountId(), result.getPaymentId(), properties, tenantContext);
} catch (final PaymentPluginApiException e) {
throw new PaymentApiException(ErrorCode.PAYMENT_PLUGIN_GET_REFUND_INFO, refundId, e.toString());
}
@@ -346,21 +346,21 @@ public class RefundProcessor extends ProcessorBase {
);
}
- public Pagination<Refund> searchRefunds(final String searchKey, final Long offset, final Long limit, final Iterable<PluginProperty> properties, final InternalTenantContext internalTenantContext) {
+ public Pagination<Refund> searchRefunds(final String searchKey, final Long offset, final Long limit, final Iterable<PluginProperty> properties, final TenantContext tenantContext, final InternalTenantContext internalTenantContext) {
return getEntityPaginationFromPlugins(getAvailablePlugins(),
offset,
limit,
new EntityPaginationBuilder<Refund, PaymentApiException>() {
@Override
public Pagination<Refund> build(final Long offset, final Long limit, final String pluginName) throws PaymentApiException {
- return searchRefunds(searchKey, offset, limit, pluginName, properties, internalTenantContext);
+ return searchRefunds(searchKey, offset, limit, pluginName, properties, tenantContext, internalTenantContext);
}
}
);
}
public Pagination<Refund> searchRefunds(final String searchKey, final Long offset, final Long limit, final String pluginName,
- final Iterable<PluginProperty> properties, final InternalTenantContext internalTenantContext) throws PaymentApiException {
+ final Iterable<PluginProperty> properties, final TenantContext tenantContext, final InternalTenantContext internalTenantContext) throws PaymentApiException {
final PaymentPluginApi pluginApi = getPaymentPluginApi(pluginName);
final Map<UUID, List<RefundInfoPlugin>> refundsByPaymentId = new HashMap<UUID, List<RefundInfoPlugin>>();
@@ -372,7 +372,7 @@ public class RefundProcessor extends ProcessorBase {
public Pagination<RefundInfoPlugin> build() throws PaymentApiException {
final Pagination<RefundInfoPlugin> refunds;
try {
- refunds = pluginApi.searchRefunds(searchKey, offset, limit, properties, buildTenantContext(internalTenantContext));
+ refunds = pluginApi.searchRefunds(searchKey, offset, limit, properties, tenantContext);
} catch (final PaymentPluginApiException e) {
throw new PaymentApiException(e, ErrorCode.PAYMENT_PLUGIN_SEARCH_REFUNDS, pluginName, searchKey);
}
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 44d894f..ce3e044 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
@@ -225,7 +225,7 @@ public class DefaultNoOpPaymentProviderPlugin implements NoOpPaymentPluginApi {
}
@Override
- public void resetPaymentMethods(final UUID kbAccountId, final List<PaymentMethodInfoPlugin> paymentMethods, final Iterable<PluginProperty> properties) {
+ public void resetPaymentMethods(final UUID kbAccountId, final List<PaymentMethodInfoPlugin> paymentMethods, final Iterable<PluginProperty> properties, final CallContext callContext) {
}
@Override
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 3e03551..3d6ca7a 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
@@ -135,7 +135,7 @@ public class ExternalPaymentProviderPlugin implements PaymentPluginApi {
}
@Override
- public void resetPaymentMethods(final UUID kbAccountId, final List<PaymentMethodInfoPlugin> paymentMethods, final Iterable<PluginProperty> properties) throws PaymentPluginApiException {
+ public void resetPaymentMethods(final UUID kbAccountId, final List<PaymentMethodInfoPlugin> paymentMethods, final Iterable<PluginProperty> properties, final CallContext callContext) throws PaymentPluginApiException {
}
@Override
diff --git a/payment/src/test/java/org/killbill/billing/payment/core/TestPaymentMethodProcessorNoDB.java b/payment/src/test/java/org/killbill/billing/payment/core/TestPaymentMethodProcessorNoDB.java
index acef033..66a68a4 100644
--- a/payment/src/test/java/org/killbill/billing/payment/core/TestPaymentMethodProcessorNoDB.java
+++ b/payment/src/test/java/org/killbill/billing/payment/core/TestPaymentMethodProcessorNoDB.java
@@ -45,7 +45,7 @@ public class TestPaymentMethodProcessorNoDB extends PaymentTestSuiteNoDB {
Assert.assertEquals(paymentMethodProcessor.getPaymentMethods(account, false, properties, internalCallContext).size(), 0);
// The first call should create the payment method
- final ExternalPaymentProviderPlugin providerPlugin = paymentMethodProcessor.getExternalPaymentProviderPlugin(account, properties, internalCallContext);
+ final ExternalPaymentProviderPlugin providerPlugin = paymentMethodProcessor.getExternalPaymentProviderPlugin(account, properties, callContext, internalCallContext);
final List<PaymentMethod> paymentMethods = paymentMethodProcessor.getPaymentMethods(account, false, properties, internalCallContext);
Assert.assertEquals(paymentMethods.size(), 1);
Assert.assertEquals(paymentMethods.get(0).getPluginName(), ExternalPaymentProviderPlugin.PLUGIN_NAME);
@@ -54,7 +54,7 @@ public class TestPaymentMethodProcessorNoDB extends PaymentTestSuiteNoDB {
// The succeeding calls should not create any other payment method
final UUID externalPaymentMethodId = paymentMethods.get(0).getId();
for (int i = 0; i < 50; i++) {
- final ExternalPaymentProviderPlugin foundProviderPlugin = paymentMethodProcessor.getExternalPaymentProviderPlugin(account, properties, internalCallContext);
+ final ExternalPaymentProviderPlugin foundProviderPlugin = paymentMethodProcessor.getExternalPaymentProviderPlugin(account, properties, callContext, internalCallContext);
Assert.assertNotNull(foundProviderPlugin);
final List<PaymentMethod> foundPaymentMethods = paymentMethodProcessor.getPaymentMethods(account, false, properties, internalCallContext);
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 f85cd60..771f29c 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
@@ -42,7 +42,7 @@ public class TestPaymentMethodProcessorRefreshWithDB extends PaymentTestSuiteWit
@BeforeMethod(groups = "slow")
public void beforeMethod() throws Exception {
super.beforeMethod();
- getPluginApi().resetPaymentMethods(null, null, PLUGIN_PROPERTIES);
+ getPluginApi().resetPaymentMethods(null, null, PLUGIN_PROPERTIES, callContext);
}
@Test(groups = "slow")
@@ -56,7 +56,7 @@ public class TestPaymentMethodProcessorRefreshWithDB extends PaymentTestSuiteWit
getPluginApi().addPaymentMethod(account.getId(), newPmId, new DefaultNoOpPaymentMethodPlugin(UUID.randomUUID().toString(), false, ImmutableList.<PluginProperty>of()), false, PLUGIN_PROPERTIES, callContext);
// Verify that the refresh does indeed show 2 PMs
- final List<PaymentMethod> methods = paymentMethodProcessor.refreshPaymentMethods(MockPaymentProviderPlugin.PLUGIN_NAME, account, PLUGIN_PROPERTIES, internalCallContext);
+ final List<PaymentMethod> methods = paymentMethodProcessor.refreshPaymentMethods(MockPaymentProviderPlugin.PLUGIN_NAME, account, PLUGIN_PROPERTIES, callContext, internalCallContext);
Assert.assertEquals(methods.size(), 2);
checkPaymentMethodExistsWithStatus(methods, existingPMId, true);
checkPaymentMethodExistsWithStatus(methods, newPmId, true);
@@ -78,7 +78,7 @@ public class TestPaymentMethodProcessorRefreshWithDB extends PaymentTestSuiteWit
Assert.assertEquals(paymentApi.getPaymentMethods(account, false, PLUGIN_PROPERTIES, callContext).size(), 2);
// Verify that the refresh sees that PM as being deleted now
- final List<PaymentMethod> methods = paymentMethodProcessor.refreshPaymentMethods(MockPaymentProviderPlugin.PLUGIN_NAME, account, PLUGIN_PROPERTIES, internalCallContext);
+ final List<PaymentMethod> methods = paymentMethodProcessor.refreshPaymentMethods(MockPaymentProviderPlugin.PLUGIN_NAME, account, PLUGIN_PROPERTIES, callContext, internalCallContext);
Assert.assertEquals(methods.size(), 1);
checkPaymentMethodExistsWithStatus(methods, firstPmId, true);
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 41dad0e..08d749b 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
@@ -193,7 +193,7 @@ public class MockPaymentProviderPlugin implements NoOpPaymentPluginApi {
}
@Override
- public void resetPaymentMethods(final UUID kbAccountId, final List<PaymentMethodInfoPlugin> input, final Iterable<PluginProperty> properties) {
+ public void resetPaymentMethods(final UUID kbAccountId, final List<PaymentMethodInfoPlugin> input, final Iterable<PluginProperty> properties, final CallContext callContext) {
paymentMethodsInfo.clear();
if (input != null) {
for (final PaymentMethodInfoPlugin cur : input) {
diff --git a/payment/src/test/java/org/killbill/billing/payment/TestRetryService.java b/payment/src/test/java/org/killbill/billing/payment/TestRetryService.java
index 4c9b676..67ac69b 100644
--- a/payment/src/test/java/org/killbill/billing/payment/TestRetryService.java
+++ b/payment/src/test/java/org/killbill/billing/payment/TestRetryService.java
@@ -134,7 +134,7 @@ public class TestRetryService extends PaymentTestSuiteNoDB {
setPaymentFailure(failureType);
boolean failed = false;
try {
- paymentProcessor.createPayment(account, invoice.getId(), amount, internalCallContext, false, false, ImmutableList.<PluginProperty>of());
+ paymentProcessor.createPayment(account, invoice.getId(), amount, false, false, ImmutableList.<PluginProperty>of(), internalCallContext);
} catch (final PaymentApiException e) {
failed = true;
}
pom.xml 2(+1 -1)
diff --git a/pom.xml b/pom.xml
index ef91d0f..a80f533 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.8</version>
+ <version>0.7.9</version>
</parent>
<artifactId>killbill</artifactId>
<version>0.11.3-SNAPSHOT</version>