killbill-aplcache
Changes
analytics/src/main/java/com/ning/billing/analytics/model/BusinessInvoicePaymentModelDao.java 7(+4 -3)
analytics/src/test/java/com/ning/billing/analytics/dao/TestBusinessInvoicePaymentSqlDao.java 16(+5 -11)
osgi-bundles/jruby/src/main/java/com/ning/billing/osgi/bundles/jruby/JRubyPaymentPlugin.java 70(+17 -53)
payment/src/main/java/com/ning/billing/payment/provider/DefaultNoOpPaymentInfoPlugin.java 10(+0 -10)
payment/src/main/java/com/ning/billing/payment/provider/DefaultNoOpPaymentProviderPlugin.java 114(+26 -88)
payment/src/main/java/com/ning/billing/payment/provider/DefaultNoOpRefundInfoPlugin.java 124(+124 -0)
Details
diff --git a/analytics/src/main/java/com/ning/billing/analytics/AnalyticsListener.java b/analytics/src/main/java/com/ning/billing/analytics/AnalyticsListener.java
index c394e7f..858fcc6 100644
--- a/analytics/src/main/java/com/ning/billing/analytics/AnalyticsListener.java
+++ b/analytics/src/main/java/com/ning/billing/analytics/AnalyticsListener.java
@@ -183,8 +183,6 @@ public class AnalyticsListener {
public Void call() throws Exception {
bipDao.invoicePaymentPosted(paymentInfo.getAccountId(),
paymentInfo.getPaymentId(),
- paymentInfo.getExtFirstPaymentRefId(),
- paymentInfo.getExtSecondPaymentRefId(),
paymentInfo.getStatus().toString(),
createCallContext(paymentInfo));
return null;
@@ -199,8 +197,6 @@ public class AnalyticsListener {
public Void call() throws Exception {
bipDao.invoicePaymentPosted(paymentError.getAccountId(),
paymentError.getPaymentId(),
- null,
- null,
paymentError.getMessage(),
createCallContext(paymentError));
return null;
diff --git a/analytics/src/main/java/com/ning/billing/analytics/api/user/DefaultAnalyticsUserApi.java b/analytics/src/main/java/com/ning/billing/analytics/api/user/DefaultAnalyticsUserApi.java
index b5544ee..f177991 100644
--- a/analytics/src/main/java/com/ning/billing/analytics/api/user/DefaultAnalyticsUserApi.java
+++ b/analytics/src/main/java/com/ning/billing/analytics/api/user/DefaultAnalyticsUserApi.java
@@ -343,8 +343,6 @@ public class DefaultAnalyticsUserApi implements AnalyticsUserApi {
final Payment paymentInfo = payments.get(paymentId);
bipDao.invoicePaymentPosted(paymentInfo.getAccountId(),
paymentInfo.getId(),
- paymentInfo.getExtFirstPaymentIdRef(),
- paymentInfo.getExtSecondPaymentIdRef(),
paymentInfo.getPaymentStatus().toString(),
internalCallContext);
}
diff --git a/analytics/src/main/java/com/ning/billing/analytics/BusinessAccountDao.java b/analytics/src/main/java/com/ning/billing/analytics/BusinessAccountDao.java
index 7e2fce4..d6260e1 100644
--- a/analytics/src/main/java/com/ning/billing/analytics/BusinessAccountDao.java
+++ b/analytics/src/main/java/com/ning/billing/analytics/BusinessAccountDao.java
@@ -128,7 +128,7 @@ public class BusinessAccountDao {
}
// Retrieve payment methods
- for (final PaymentMethod paymentMethod : paymentApi.getPaymentMethods(account, true, context)) {
+ for (final PaymentMethod paymentMethod : paymentApi.getPaymentMethods(account, context)) {
if (paymentMethod.getId().equals(account.getPaymentMethodId()) && paymentMethod.getPluginDetail() != null) {
paymentMethodType = PaymentMethodUtils.getPaymentMethodType(paymentMethod.getPluginDetail());
creditCardType = PaymentMethodUtils.getCardType(paymentMethod.getPluginDetail());
diff --git a/analytics/src/main/java/com/ning/billing/analytics/BusinessInvoicePaymentDao.java b/analytics/src/main/java/com/ning/billing/analytics/BusinessInvoicePaymentDao.java
index 4de765d..def7d53 100644
--- a/analytics/src/main/java/com/ning/billing/analytics/BusinessInvoicePaymentDao.java
+++ b/analytics/src/main/java/com/ning/billing/analytics/BusinessInvoicePaymentDao.java
@@ -72,8 +72,7 @@ public class BusinessInvoicePaymentDao {
this.accountDao = accountDao;
}
- public void invoicePaymentPosted(final UUID accountId, @Nullable final UUID paymentId, @Nullable final String extFirstPaymentRefId,
- @Nullable final String extSecondPaymentRefId, final String message, final InternalCallContext context) {
+ public void invoicePaymentPosted(final UUID accountId, @Nullable final UUID paymentId, final String message, final InternalCallContext context) {
// Payment attempt with no default payment method. Ignore.
if (paymentId == null) {
return;
@@ -97,7 +96,7 @@ public class BusinessInvoicePaymentDao {
PaymentMethod paymentMethod = null;
try {
- paymentMethod = paymentApi.getPaymentMethod(account, payment.getPaymentMethodId(), true, context);
+ paymentMethod = paymentApi.getPaymentMethod(account, payment.getPaymentMethodId(), context);
} catch (PaymentApiException e) {
log.info("For payment {}: payment method {} does not exist", paymentId, payment.getPaymentMethodId());
}
@@ -114,11 +113,11 @@ public class BusinessInvoicePaymentDao {
invoicePayment != null ? invoicePayment.getInvoiceId() : "unknown", paymentId);
}
- createPayment(account, invoice, invoicePayment, payment, paymentMethod, extFirstPaymentRefId, extSecondPaymentRefId, message, context);
+ createPayment(account, invoice, invoicePayment, payment, paymentMethod, message, context);
}
private void createPayment(final Account account, @Nullable final Invoice invoice, @Nullable final InvoicePayment invoicePayment, final Payment payment,
- @Nullable final PaymentMethod paymentMethod, final String extFirstPaymentRefId, final String extSecondPaymentRefId,
+ @Nullable final PaymentMethod paymentMethod,
final String message, final InternalCallContext context) {
// paymentMethod may be null if the payment method has been deleted
final String cardCountry;
@@ -155,8 +154,6 @@ public class BusinessInvoicePaymentDao {
final BusinessInvoicePaymentModelDao businessInvoicePayment = new BusinessInvoicePaymentModelDao(
account.getExternalKey(),
payment.getAmount(),
- extFirstPaymentRefId,
- extSecondPaymentRefId,
cardCountry,
cardType,
createdDate,
diff --git a/analytics/src/main/java/com/ning/billing/analytics/dao/BusinessInvoicePaymentMapper.java b/analytics/src/main/java/com/ning/billing/analytics/dao/BusinessInvoicePaymentMapper.java
index 16c3d55..65361a6 100644
--- a/analytics/src/main/java/com/ning/billing/analytics/dao/BusinessInvoicePaymentMapper.java
+++ b/analytics/src/main/java/com/ning/billing/analytics/dao/BusinessInvoicePaymentMapper.java
@@ -61,7 +61,7 @@ public class BusinessInvoicePaymentMapper implements ResultSetMapper<BusinessInv
linkedInvoicePaymentId = null;
}
- return new BusinessInvoicePaymentModelDao(accountKey, amount, extFirstPaymentRefId, extSecondPaymentRefId, cardCountry, cardType, createdDate, currency,
+ return new BusinessInvoicePaymentModelDao(accountKey, amount, cardCountry, cardType, createdDate, currency,
effectiveDate, invoiceId, paymentError, paymentId, paymentMethod, paymentType,
pluginName, processingStatus, requestedAmount, updatedDate, invoicePaymentType,
linkedInvoicePaymentId);
diff --git a/analytics/src/main/java/com/ning/billing/analytics/model/BusinessInvoicePaymentModelDao.java b/analytics/src/main/java/com/ning/billing/analytics/model/BusinessInvoicePaymentModelDao.java
index 5f646d6..bf1ec7f 100644
--- a/analytics/src/main/java/com/ning/billing/analytics/model/BusinessInvoicePaymentModelDao.java
+++ b/analytics/src/main/java/com/ning/billing/analytics/model/BusinessInvoicePaymentModelDao.java
@@ -48,7 +48,7 @@ public class BusinessInvoicePaymentModelDao extends EntityBase {
private final String invoicePaymentType;
private final UUID linkedInvoicePaymentId;
- public BusinessInvoicePaymentModelDao(final String accountKey, final BigDecimal amount, final String extFirstPaymentRefId, final String extSecondPaymentRefId,
+ public BusinessInvoicePaymentModelDao(final String accountKey, final BigDecimal amount,
final String cardCountry, final String cardType, final DateTime createdDate,
final Currency currency, final DateTime effectiveDate, final UUID invoiceId,
final String paymentError, final UUID paymentId, final String paymentMethod,
@@ -58,8 +58,9 @@ public class BusinessInvoicePaymentModelDao extends EntityBase {
super(paymentId, createdDate, updatedDate);
this.accountKey = accountKey;
this.amount = amount;
- this.extFirstPaymentRefId = extFirstPaymentRefId;
- this.extSecondPaymentRefId = extSecondPaymentRefId;
+ // TODO For backward compatibility
+ this.extFirstPaymentRefId = null;
+ this.extSecondPaymentRefId = null;
this.cardCountry = cardCountry;
this.cardType = cardType;
this.currency = currency;
diff --git a/analytics/src/test/java/com/ning/billing/analytics/api/TestAnalyticsService.java b/analytics/src/test/java/com/ning/billing/analytics/api/TestAnalyticsService.java
index 71741b5..42700ae 100644
--- a/analytics/src/test/java/com/ning/billing/analytics/api/TestAnalyticsService.java
+++ b/analytics/src/test/java/com/ning/billing/analytics/api/TestAnalyticsService.java
@@ -265,7 +265,7 @@ public class TestAnalyticsService extends AnalyticsTestSuiteWithEmbeddedDB {
INVOICE_AMOUNT, ACCOUNT_CURRENCY, null, 1L, 1L);
paymentInfoNotification = new DefaultPaymentInfoEvent(account.getId(), invoices.get(0).getId(), null, InvoiceModelDaoHelper.getBalance(invoices.get(0)), -1,
- PaymentStatus.UNKNOWN, null, null, null, clock.getUTCNow(), 1L, 1L);
+ PaymentStatus.UNKNOWN, null, clock.getUTCNow(), 1L, 1L);
final PaymentModelDao paymentInfo = new PaymentModelDao(account.getId(), invoice.getId(), account.getPaymentMethodId(),
BigDecimal.ONE, Currency.USD, clock.getUTCNow(), PaymentStatus.SUCCESS);
diff --git a/analytics/src/test/java/com/ning/billing/analytics/dao/TestBusinessInvoicePaymentSqlDao.java b/analytics/src/test/java/com/ning/billing/analytics/dao/TestBusinessInvoicePaymentSqlDao.java
index 3811465..6204bbf 100644
--- a/analytics/src/test/java/com/ning/billing/analytics/dao/TestBusinessInvoicePaymentSqlDao.java
+++ b/analytics/src/test/java/com/ning/billing/analytics/dao/TestBusinessInvoicePaymentSqlDao.java
@@ -42,10 +42,8 @@ public class TestBusinessInvoicePaymentSqlDao extends AnalyticsTestSuiteWithEmbe
@Test(groups = "slow")
public void testCRUD() throws Exception {
- final String extFirstPaymentRefId = UUID.randomUUID().toString();
- final String extSecondPaymentRefId = UUID.randomUUID().toString();
final String accountKey = UUID.randomUUID().toString();
- final BusinessInvoicePaymentModelDao invoicePayment = createInvoicePayment(extFirstPaymentRefId, extSecondPaymentRefId, accountKey);
+ final BusinessInvoicePaymentModelDao invoicePayment = createInvoicePayment(accountKey);
// Verify initial state
Assert.assertNull(invoicePaymentSqlDao.getInvoicePayment(invoicePayment.getPaymentId().toString(), internalCallContext));
@@ -67,14 +65,10 @@ public class TestBusinessInvoicePaymentSqlDao extends AnalyticsTestSuiteWithEmbe
@Test(groups = "slow")
public void testSegmentation() throws Exception {
- final String extFirstPaymentRefId1 = UUID.randomUUID().toString();
- final String extSecondPaymentRefId1 = UUID.randomUUID().toString();
final String accountKey1 = UUID.randomUUID().toString();
- final BusinessInvoicePaymentModelDao invoicePayment1 = createInvoicePayment(extFirstPaymentRefId1, extSecondPaymentRefId1, accountKey1);
- final String extFirstPaymentRefId2 = UUID.randomUUID().toString();
- final String extSecondPaymentRefId2 = UUID.randomUUID().toString();
+ final BusinessInvoicePaymentModelDao invoicePayment1 = createInvoicePayment(accountKey1);
final String accountKey2 = UUID.randomUUID().toString();
- final BusinessInvoicePaymentModelDao invoicePayment2 = createInvoicePayment(extFirstPaymentRefId2, extSecondPaymentRefId2, accountKey2);
+ final BusinessInvoicePaymentModelDao invoicePayment2 = createInvoicePayment(accountKey2);
// Create both invoice payments
Assert.assertEquals(invoicePaymentSqlDao.createInvoicePayment(invoicePayment1, internalCallContext), 1);
@@ -104,7 +98,7 @@ public class TestBusinessInvoicePaymentSqlDao extends AnalyticsTestSuiteWithEmbe
}
}
- private BusinessInvoicePaymentModelDao createInvoicePayment(final String extFirstPaymentRefId, final String extSecondPaymentRefId, final String accountKey) {
+ private BusinessInvoicePaymentModelDao createInvoicePayment(final String accountKey) {
final BigDecimal amount = BigDecimal.ONE;
final String cardCountry = UUID.randomUUID().toString().substring(0, 20);
final String cardType = UUID.randomUUID().toString().substring(0, 20);
@@ -123,7 +117,7 @@ public class TestBusinessInvoicePaymentSqlDao extends AnalyticsTestSuiteWithEmbe
final String invoicePaymentType = UUID.randomUUID().toString().substring(0, 10);
final UUID linkedInvoicePaymentId = UUID.randomUUID();
- return new BusinessInvoicePaymentModelDao(accountKey, amount, extFirstPaymentRefId, extSecondPaymentRefId,
+ return new BusinessInvoicePaymentModelDao(accountKey, amount,
cardCountry, cardType, createdDate,
currency, effectiveDate, invoiceId,
paymentError, paymentId, paymentMethod,
diff --git a/analytics/src/test/java/com/ning/billing/analytics/model/TestBusinessInvoicePayment.java b/analytics/src/test/java/com/ning/billing/analytics/model/TestBusinessInvoicePayment.java
index 5292aac..25858cc 100644
--- a/analytics/src/test/java/com/ning/billing/analytics/model/TestBusinessInvoicePayment.java
+++ b/analytics/src/test/java/com/ning/billing/analytics/model/TestBusinessInvoicePayment.java
@@ -33,8 +33,6 @@ public class TestBusinessInvoicePayment extends AnalyticsTestSuite {
public void testEquals() throws Exception {
final String accountKey = UUID.randomUUID().toString();
final BigDecimal amount = BigDecimal.ONE;
- final String extFirstPaymentRefId = UUID.randomUUID().toString();
- final String extSecondPaymentRefId = UUID.randomUUID().toString();
final String cardCountry = UUID.randomUUID().toString();
final String cardType = UUID.randomUUID().toString();
final DateTime createdDate = new DateTime(DateTimeZone.UTC);
@@ -51,7 +49,7 @@ public class TestBusinessInvoicePayment extends AnalyticsTestSuite {
final DateTime updatedDate = new DateTime(DateTimeZone.UTC);
final String invoicePaymentType = UUID.randomUUID().toString();
final UUID linkedInvoicePaymentId = UUID.randomUUID();
- final BusinessInvoicePaymentModelDao invoicePayment = new BusinessInvoicePaymentModelDao(accountKey, amount, extFirstPaymentRefId, extSecondPaymentRefId,
+ final BusinessInvoicePaymentModelDao invoicePayment = new BusinessInvoicePaymentModelDao(accountKey, amount,
cardCountry, cardType, createdDate,
currency, effectiveDate, invoiceId,
paymentError, paymentId, paymentMethod,
@@ -63,8 +61,6 @@ public class TestBusinessInvoicePayment extends AnalyticsTestSuite {
Assert.assertTrue(invoicePayment.equals(invoicePayment));
Assert.assertEquals(invoicePayment.getAccountKey(), accountKey);
Assert.assertEquals(invoicePayment.getAmount(), amount);
- Assert.assertEquals(invoicePayment.getExtFirstPaymentRefId(), extFirstPaymentRefId);
- Assert.assertEquals(invoicePayment.getExtSecondPaymentRefId(), extSecondPaymentRefId);
Assert.assertEquals(invoicePayment.getCardCountry(), cardCountry);
Assert.assertEquals(invoicePayment.getCardType(), cardType);
Assert.assertEquals(invoicePayment.getCreatedDate(), createdDate);
@@ -82,7 +78,7 @@ public class TestBusinessInvoicePayment extends AnalyticsTestSuite {
Assert.assertEquals(invoicePayment.getInvoicePaymentType(), invoicePaymentType);
Assert.assertEquals(invoicePayment.getLinkedInvoicePaymentId(), linkedInvoicePaymentId);
- final BusinessInvoicePaymentModelDao otherInvoicePayment = new BusinessInvoicePaymentModelDao(null, null, extFirstPaymentRefId, extSecondPaymentRefId, null, null, createdDate,
+ final BusinessInvoicePaymentModelDao otherInvoicePayment = new BusinessInvoicePaymentModelDao(null, null, null, null, createdDate,
null, null, null, null, paymentId, null,
null, null, null, null, null, null, null);
Assert.assertFalse(invoicePayment.equals(otherInvoicePayment));
diff --git a/api/src/main/java/com/ning/billing/payment/api/PaymentApi.java b/api/src/main/java/com/ning/billing/payment/api/PaymentApi.java
index ca7febb..a79a99b 100644
--- a/api/src/main/java/com/ning/billing/payment/api/PaymentApi.java
+++ b/api/src/main/java/com/ning/billing/payment/api/PaymentApi.java
@@ -111,25 +111,16 @@ public interface PaymentApi {
*/
public Set<String> getAvailablePlugins();
- public String initializeAccountPlugin(String pluginName, Account account, CallContext context)
- throws PaymentApiException;
-
public UUID addPaymentMethod(String pluginName, Account account, boolean setDefault, PaymentMethodPlugin paymentMethodInfo, CallContext context)
throws PaymentApiException;
- public List<PaymentMethod> refreshPaymentMethods(String pluginName, Account account, CallContext context)
- throws PaymentApiException;
-
- public List<PaymentMethod> getPaymentMethods(Account account, boolean withPluginDetail, TenantContext context)
+ public List<PaymentMethod> getPaymentMethods(Account account, TenantContext context)
throws PaymentApiException;
public PaymentMethod getPaymentMethodById(UUID paymentMethodId, TenantContext context)
throws PaymentApiException;
- public PaymentMethod getPaymentMethod(Account account, UUID paymentMethodId, boolean withPluginDetail, TenantContext context)
- throws PaymentApiException;
-
- public void updatePaymentMethod(Account account, UUID paymentMethodId, PaymentMethodPlugin paymentMethodInfo, CallContext context)
+ public PaymentMethod getPaymentMethod(Account account, UUID paymentMethodId, TenantContext context)
throws PaymentApiException;
public void deletedPaymentMethod(Account account, UUID paymentMethodId, boolean deleteDefaultPaymentMethodWithAutoPayOff, CallContext context)
diff --git a/api/src/main/java/com/ning/billing/payment/plugin/api/PaymentInfoPlugin.java b/api/src/main/java/com/ning/billing/payment/plugin/api/PaymentInfoPlugin.java
index 826c304..50a2ac9 100644
--- a/api/src/main/java/com/ning/billing/payment/plugin/api/PaymentInfoPlugin.java
+++ b/api/src/main/java/com/ning/billing/payment/plugin/api/PaymentInfoPlugin.java
@@ -13,6 +13,7 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
+
package com.ning.billing.payment.plugin.api;
import java.math.BigDecimal;
@@ -27,19 +28,33 @@ public interface PaymentInfoPlugin {
ERROR
}
+ /**
+ * @return payment amount
+ */
public BigDecimal getAmount();
+ /**
+ * @return date when the payment was created
+ */
public DateTime getCreatedDate();
+ /**
+ * @return date when the payment is effective
+ */
public DateTime getEffectiveDate();
+ /**
+ * @return payment status in the gateway
+ */
public PaymentPluginStatus getStatus();
+ /**
+ * @return gateway error, if any
+ */
public String getGatewayError();
+ /**
+ * @return gateway error code, if any
+ */
public String getGatewayErrorCode();
-
- public String getExtFirstReferenceId();
-
- public String getExtSecondReferenceId();
}
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 4007d0b..d4541e7 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
@@ -17,48 +17,89 @@
package com.ning.billing.payment.plugin.api;
import java.math.BigDecimal;
-import java.util.List;
import java.util.UUID;
-import com.ning.billing.account.api.Account;
import com.ning.billing.payment.api.PaymentMethodPlugin;
import com.ning.billing.util.callcontext.CallContext;
import com.ning.billing.util.callcontext.TenantContext;
public interface PaymentPluginApi {
+ /**
+ * @return plugin name
+ */
public String getName();
- public PaymentInfoPlugin processPayment(String externalAccountKey, UUID paymentId, BigDecimal amount, CallContext context)
+ /**
+ * Charge a specific amount in the Gateway. Required.
+ *
+ * @param pluginPaymentMethodKey payment method key to charge
+ * @param kbPaymentId killbill payment id (for reference)
+ * @param amount amount to charge
+ * @param context call context
+ * @return information about the payment in the gateway
+ * @throws PaymentPluginApiException
+ */
+ public PaymentInfoPlugin processPayment(String pluginPaymentMethodKey, UUID kbPaymentId, BigDecimal amount, CallContext context)
throws PaymentPluginApiException;
- public PaymentInfoPlugin getPaymentInfo(UUID paymentId, TenantContext context)
+ /**
+ * Retrieve information about a given payment. Optional (not all gateways will support it).
+ *
+ *
+ * @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)
throws PaymentPluginApiException;
- public void processRefund(final Account account, final UUID paymentId, BigDecimal refundAmount, CallContext context)
+ /**
+ * Process a refund against a given payment. Required.
+ *
+ *
+ * @param kbPaymentId killbill payment id (for reference)
+ * @param refundAmount call context
+ * @param context call context
+ * @return information about the refund in the gateway
+ * @throws PaymentPluginApiException
+ */
+ public RefundInfoPlugin processRefund(UUID kbPaymentId, BigDecimal refundAmount, CallContext context)
throws PaymentPluginApiException;
- public int getNbRefundForPaymentAmount(final Account account, final UUID paymentId, final BigDecimal refundAmount, TenantContext context)
+ /**
+ * Add a payment method for a Killbill account in the gateway. Optional.
+ *
+ * @param paymentMethodProps payment method details
+ * @param kbAccountId killbill account id
+ * @param setDefault set it as the default payment method in the gateway
+ * @param context call context
+ * @return payment method key in the gateway
+ * @throws PaymentPluginApiException
+ */
+ public String addPaymentMethod(PaymentMethodPlugin paymentMethodProps, UUID kbAccountId, boolean setDefault, CallContext context)
throws PaymentPluginApiException;
- public String createPaymentProviderAccount(Account account, CallContext context)
+ /**
+ * Delete a payment method in the gateway. Optional.
+ *
+ * @param pluginPaymentMethodKey payment method key to delete
+ * @param kbAccountId killbill account id
+ * @param context call context
+ * @throws PaymentPluginApiException
+ */
+ public void deletePaymentMethod(String pluginPaymentMethodKey, UUID kbAccountId, CallContext context)
throws PaymentPluginApiException;
- public List<PaymentMethodPlugin> getPaymentMethodDetails(String accountKey, TenantContext context)
- throws PaymentPluginApiException;
-
- public PaymentMethodPlugin getPaymentMethodDetail(String accountKey, String externalPaymentMethodId, TenantContext context)
- throws PaymentPluginApiException;
-
- public String addPaymentMethod(String accountKey, PaymentMethodPlugin paymentMethodProps, boolean setDefault, CallContext context)
- throws PaymentPluginApiException;
-
- public void updatePaymentMethod(String accountKey, PaymentMethodPlugin paymentMethodProps, CallContext context)
- throws PaymentPluginApiException;
-
- public void deletePaymentMethod(String accountKey, String externalPaymentMethodId, CallContext context)
- throws PaymentPluginApiException;
-
- public void setDefaultPaymentMethod(String accountKey, String externalPaymentId, CallContext context)
+ /**
+ * Set a payment method as default in the gateway. Optional.
+ *
+ * @param pluginPaymentMethodKey payment method key to update
+ * @param kbAccountId killbill account id
+ * @param context call context
+ * @throws PaymentPluginApiException
+ */
+ public void setDefaultPaymentMethod(String pluginPaymentMethodKey, UUID kbAccountId, CallContext context)
throws PaymentPluginApiException;
}
diff --git a/api/src/main/java/com/ning/billing/payment/plugin/api/RefundInfoPlugin.java b/api/src/main/java/com/ning/billing/payment/plugin/api/RefundInfoPlugin.java
new file mode 100644
index 0000000..c0c6662
--- /dev/null
+++ b/api/src/main/java/com/ning/billing/payment/plugin/api/RefundInfoPlugin.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2010-2013 Ning, Inc.
+ *
+ * Ning 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:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.ning.billing.payment.plugin.api;
+
+import java.math.BigDecimal;
+
+import org.joda.time.DateTime;
+
+public interface RefundInfoPlugin {
+
+ public enum RefundPluginStatus {
+ UNDEFINED,
+ PROCESSED,
+ ERROR
+ }
+
+ /**
+ * @return refund amount
+ */
+ public BigDecimal getAmount();
+
+ /**
+ * @return date when the refund was created
+ */
+ public DateTime getCreatedDate();
+
+ /**
+ * @return date when the refund is effective
+ */
+ public DateTime getEffectiveDate();
+
+ /**
+ * @return refund status in the gateway
+ */
+ public RefundPluginStatus getStatus();
+
+ /**
+ * @return gateway error, if any
+ */
+ public String getGatewayError();
+
+ /**
+ * @return gateway error code, if any
+ */
+ public String getGatewayErrorCode();
+}
diff --git a/jaxrs/src/main/java/com/ning/billing/jaxrs/resources/AccountResource.java b/jaxrs/src/main/java/com/ning/billing/jaxrs/resources/AccountResource.java
index 6b5ae86..2064f03 100644
--- a/jaxrs/src/main/java/com/ning/billing/jaxrs/resources/AccountResource.java
+++ b/jaxrs/src/main/java/com/ning/billing/jaxrs/resources/AccountResource.java
@@ -361,8 +361,6 @@ public class AccountResource extends JaxRsResourceBase {
@Path("/{accountId:\\w+-\\w+-\\w+-\\w+-\\w+}/" + PAYMENTS)
@Produces(APPLICATION_JSON)
public Response getPayments(@PathParam("accountId") final String accountId,
- @QueryParam(QUERY_PAYMENT_LAST4_CC) final String last4CC,
- @QueryParam(QUERY_PAYMENT_NAME_ON_CC) final String nameOnCC,
@javax.ws.rs.core.Context final HttpServletRequest request) throws PaymentApiException {
final List<Payment> payments = paymentApi.getAccountPayments(UUID.fromString(accountId), context.createContext(request));
final List<PaymentJsonSimple> result = new ArrayList<PaymentJsonSimple>(payments.size());
@@ -396,14 +394,11 @@ public class AccountResource extends JaxRsResourceBase {
@Path("/{accountId:" + UUID_PATTERN + "}/" + PAYMENT_METHODS)
@Produces(APPLICATION_JSON)
public Response getPaymentMethods(@PathParam("accountId") final String accountId,
- @QueryParam(QUERY_PAYMENT_METHOD_PLUGIN_INFO) @DefaultValue("false") final Boolean withPluginInfo,
- @QueryParam(QUERY_PAYMENT_LAST4_CC) final String last4CC,
- @QueryParam(QUERY_PAYMENT_NAME_ON_CC) final String nameOnCC,
@javax.ws.rs.core.Context final HttpServletRequest request) throws AccountApiException, PaymentApiException {
final TenantContext tenantContext = context.createContext(request);
final Account account = accountApi.getAccountById(UUID.fromString(accountId), tenantContext);
- final List<PaymentMethod> methods = paymentApi.getPaymentMethods(account, withPluginInfo, tenantContext);
+ final List<PaymentMethod> methods = paymentApi.getPaymentMethods(account, tenantContext);
final List<PaymentMethodJson> json = new ArrayList<PaymentMethodJson>(Collections2.transform(methods, new Function<PaymentMethod, PaymentMethodJson>() {
@Override
public PaymentMethodJson apply(final PaymentMethod input) {
diff --git a/jaxrs/src/main/java/com/ning/billing/jaxrs/resources/JaxrsResource.java b/jaxrs/src/main/java/com/ning/billing/jaxrs/resources/JaxrsResource.java
index 6333cfd..08813a4 100644
--- a/jaxrs/src/main/java/com/ning/billing/jaxrs/resources/JaxrsResource.java
+++ b/jaxrs/src/main/java/com/ning/billing/jaxrs/resources/JaxrsResource.java
@@ -60,14 +60,11 @@ public interface JaxrsResource {
public static final String QUERY_INVOICE_WITH_ITEMS = "withItems";
public static final String QUERY_PAYMENT_EXTERNAL = "externalPayment";
- public static final String QUERY_PAYMENT_LAST4_CC = "last4CC";
- public static final String QUERY_PAYMENT_NAME_ON_CC = "nameOnCC";
public static final String QUERY_PAYMENT_WITH_REFUNDS_AND_CHARGEBACKS = "withRefundsAndChargebacks";
public static final String QUERY_TAGS = "tagList";
public static final String QUERY_CUSTOM_FIELDS = "customFieldList";
- public static final String QUERY_PAYMENT_METHOD_PLUGIN_INFO = "withPluginInfo";
public static final String QUERY_PAYMENT_METHOD_IS_DEFAULT = "isDefault";
public static final String QUERY_BUNDLE_TRANSFER_ADDON = "transferAddOn";
diff --git a/jaxrs/src/main/java/com/ning/billing/jaxrs/resources/PaymentMethodResource.java b/jaxrs/src/main/java/com/ning/billing/jaxrs/resources/PaymentMethodResource.java
index 3356185..dc28fed 100644
--- a/jaxrs/src/main/java/com/ning/billing/jaxrs/resources/PaymentMethodResource.java
+++ b/jaxrs/src/main/java/com/ning/billing/jaxrs/resources/PaymentMethodResource.java
@@ -77,15 +77,11 @@ public class PaymentMethodResource extends JaxRsResourceBase {
@Path("/{paymentMethodId:" + UUID_PATTERN + "}")
@Produces(APPLICATION_JSON)
public Response getPaymentMethod(@PathParam("paymentMethodId") final String paymentMethodId,
- @QueryParam(QUERY_PAYMENT_METHOD_PLUGIN_INFO) @DefaultValue("false") final Boolean withPluginInfo,
@javax.ws.rs.core.Context final HttpServletRequest request) throws AccountApiException, PaymentApiException {
final TenantContext tenantContext = context.createContext(request);
- PaymentMethod paymentMethod = paymentApi.getPaymentMethodById(UUID.fromString(paymentMethodId), tenantContext);
+ final PaymentMethod paymentMethod = paymentApi.getPaymentMethodById(UUID.fromString(paymentMethodId), tenantContext);
final Account account = accountApi.getAccountById(paymentMethod.getAccountId(), tenantContext);
- if (withPluginInfo) {
- paymentMethod = paymentApi.getPaymentMethod(account, paymentMethod.getId(), true, tenantContext);
- }
final PaymentMethodJson json = PaymentMethodJson.toPaymentMethodJson(account, paymentMethod);
return Response.status(Status.OK).entity(json).build();
@@ -103,13 +99,14 @@ public class PaymentMethodResource extends JaxRsResourceBase {
@javax.ws.rs.core.Context final HttpServletRequest request) throws PaymentApiException, AccountApiException {
final CallContext callContext = context.createContext(createdBy, reason, comment, request);
- final PaymentMethod input = json.toPaymentMethod();
final PaymentMethod paymentMethod = paymentApi.getPaymentMethodById(UUID.fromString(paymentMethodId), callContext);
final Account account = accountApi.getAccountById(paymentMethod.getAccountId(), callContext);
- paymentApi.updatePaymentMethod(account, paymentMethod.getId(), input.getPluginDetail(), callContext);
+ if (json.isDefault()) {
+ paymentApi.setDefaultPaymentMethod(account, paymentMethod.getId(), callContext);
+ }
- return getPaymentMethod(paymentMethod.getId().toString(), false, request);
+ return getPaymentMethod(paymentMethod.getId().toString(), request);
}
@DELETE
diff --git a/osgi-bundles/hello/src/main/java/com/ning/billing/osgi/bundles/hello/HelloActivator.java b/osgi-bundles/hello/src/main/java/com/ning/billing/osgi/bundles/hello/HelloActivator.java
index 3b83860..f815253 100644
--- a/osgi-bundles/hello/src/main/java/com/ning/billing/osgi/bundles/hello/HelloActivator.java
+++ b/osgi-bundles/hello/src/main/java/com/ning/billing/osgi/bundles/hello/HelloActivator.java
@@ -35,6 +35,7 @@ import com.ning.billing.payment.api.PaymentMethodPlugin;
import com.ning.billing.payment.plugin.api.PaymentInfoPlugin;
import com.ning.billing.payment.plugin.api.PaymentPluginApi;
import com.ning.billing.payment.plugin.api.PaymentPluginApiException;
+import com.ning.billing.payment.plugin.api.RefundInfoPlugin;
import com.ning.billing.util.callcontext.CallContext;
import com.ning.billing.util.callcontext.TenantContext;
@@ -118,58 +119,35 @@ public class HelloActivator implements BundleActivator {
this.paymentInfoPluginRegistration = context.registerService(PaymentPluginApi.class.getName(), new PaymentPluginApi() {
@Override
public String getName() {
- return "helloName";
- }
-
- @Override
- public PaymentInfoPlugin processPayment(final String externalAccountKey, final UUID paymentId, final BigDecimal amount, final CallContext context) throws PaymentPluginApiException {
- return null;
- }
-
- @Override
- public PaymentInfoPlugin getPaymentInfo(final UUID paymentId, final TenantContext context) throws PaymentPluginApiException {
return null;
}
@Override
- public void processRefund(final Account account, final UUID paymentId, final BigDecimal refundAmount, final CallContext context) throws PaymentPluginApiException {
- }
-
- @Override
- public int getNbRefundForPaymentAmount(final Account account, final UUID paymentId, final BigDecimal refundAmount, final TenantContext context) throws PaymentPluginApiException {
- return 0;
- }
-
- @Override
- public String createPaymentProviderAccount(final Account account, final CallContext context) throws PaymentPluginApiException {
+ public PaymentInfoPlugin processPayment(final String pluginPaymentMethodKey, final UUID kbPaymentId, final BigDecimal amount, final CallContext context) throws PaymentPluginApiException {
return null;
}
@Override
- public List<PaymentMethodPlugin> getPaymentMethodDetails(final String accountKey, final TenantContext context) throws PaymentPluginApiException {
+ public PaymentInfoPlugin getPaymentInfo(final UUID kbPaymentId, final TenantContext context) throws PaymentPluginApiException {
return null;
}
@Override
- public PaymentMethodPlugin getPaymentMethodDetail(final String accountKey, final String externalPaymentMethodId, final TenantContext context) throws PaymentPluginApiException {
+ public RefundInfoPlugin processRefund(final UUID kbPaymentId, final BigDecimal refundAmount, final CallContext context) throws PaymentPluginApiException {
return null;
}
@Override
- public String addPaymentMethod(final String accountKey, final PaymentMethodPlugin paymentMethodProps, final boolean setDefault, final CallContext context) throws PaymentPluginApiException {
+ public String addPaymentMethod(final PaymentMethodPlugin paymentMethodProps, final UUID kbAccountId, final boolean setDefault, final CallContext context) throws PaymentPluginApiException {
return null;
}
@Override
- public void updatePaymentMethod(final String accountKey, final PaymentMethodPlugin paymentMethodProps, final CallContext context) throws PaymentPluginApiException {
- }
-
- @Override
- public void deletePaymentMethod(final String accountKey, final String externalPaymentMethodId, final CallContext context) throws PaymentPluginApiException {
+ public void deletePaymentMethod(final String pluginPaymentMethodKey, final UUID kbAccountId, final CallContext context) throws PaymentPluginApiException {
}
@Override
- public void setDefaultPaymentMethod(final String accountKey, final String externalPaymentId, final CallContext context) throws PaymentPluginApiException {
+ public void setDefaultPaymentMethod(final String pluginPaymentMethodKey, final UUID kbAccountId, final CallContext context) throws PaymentPluginApiException {
}
}, props);
}
diff --git a/osgi-bundles/jruby/src/main/java/com/ning/billing/osgi/bundles/jruby/JRubyPaymentPlugin.java b/osgi-bundles/jruby/src/main/java/com/ning/billing/osgi/bundles/jruby/JRubyPaymentPlugin.java
index 9296655..6c25605 100644
--- a/osgi-bundles/jruby/src/main/java/com/ning/billing/osgi/bundles/jruby/JRubyPaymentPlugin.java
+++ b/osgi-bundles/jruby/src/main/java/com/ning/billing/osgi/bundles/jruby/JRubyPaymentPlugin.java
@@ -19,7 +19,6 @@ package com.ning.billing.osgi.bundles.jruby;
import java.math.BigDecimal;
import java.util.Dictionary;
import java.util.Hashtable;
-import java.util.List;
import java.util.UUID;
import javax.annotation.Nullable;
@@ -31,12 +30,12 @@ import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
import org.osgi.service.log.LogService;
-import com.ning.billing.account.api.Account;
import com.ning.billing.osgi.api.config.PluginRubyConfig;
import com.ning.billing.payment.api.PaymentMethodPlugin;
import com.ning.billing.payment.plugin.api.PaymentInfoPlugin;
import com.ning.billing.payment.plugin.api.PaymentPluginApi;
import com.ning.billing.payment.plugin.api.PaymentPluginApiException;
+import com.ning.billing.payment.plugin.api.RefundInfoPlugin;
import com.ning.billing.util.callcontext.CallContext;
import com.ning.billing.util.callcontext.TenantContext;
@@ -72,14 +71,14 @@ public class JRubyPaymentPlugin extends JRubyPlugin implements PaymentPluginApi
}
@Override
- public PaymentInfoPlugin processPayment(final String externalAccountKey, final UUID paymentId, final BigDecimal amount, final CallContext context) throws PaymentPluginApiException {
+ public PaymentInfoPlugin processPayment(final String pluginPaymentMethodKey, final UUID kbPaymentId, final BigDecimal amount, final CallContext context) throws PaymentPluginApiException {
checkValidPaymentPlugin();
checkPluginIsRunning();
final Ruby runtime = getRuntime();
pluginInstance.callMethod("charge",
- JavaEmbedUtils.javaToRuby(runtime, externalAccountKey),
- JavaEmbedUtils.javaToRuby(runtime, paymentId.toString()),
+ JavaEmbedUtils.javaToRuby(runtime, pluginPaymentMethodKey),
+ JavaEmbedUtils.javaToRuby(runtime, kbPaymentId.toString()),
JavaEmbedUtils.javaToRuby(runtime, amount.longValue() * 100));
// TODO
@@ -87,65 +86,41 @@ public class JRubyPaymentPlugin extends JRubyPlugin implements PaymentPluginApi
}
@Override
- public PaymentInfoPlugin getPaymentInfo(final UUID paymentId, final TenantContext context) throws PaymentPluginApiException {
+ public PaymentInfoPlugin getPaymentInfo(final UUID kbPaymentId, final TenantContext context) throws PaymentPluginApiException {
checkValidPaymentPlugin();
checkPluginIsRunning();
- pluginInstance.callMethod("get_payment_info", JavaEmbedUtils.javaToRuby(getRuntime(), paymentId.toString()));
+ pluginInstance.callMethod("get_payment_info", JavaEmbedUtils.javaToRuby(getRuntime(), kbPaymentId.toString()));
// TODO
return null;
}
@Override
- public void processRefund(final Account account, final UUID paymentId, final BigDecimal refundAmount, final CallContext context) throws PaymentPluginApiException {
+ public RefundInfoPlugin processRefund(final UUID kbPaymentId, final BigDecimal refundAmount, final CallContext context) throws PaymentPluginApiException {
checkValidPaymentPlugin();
checkPluginIsRunning();
final Ruby runtime = getRuntime();
pluginInstance.callMethod("refund",
- JavaEmbedUtils.javaToRuby(runtime, account.getExternalKey()),
- JavaEmbedUtils.javaToRuby(runtime, paymentId.toString()),
+ JavaEmbedUtils.javaToRuby(runtime, kbPaymentId.toString()),
JavaEmbedUtils.javaToRuby(runtime, refundAmount.longValue() * 100));
- }
-
- @Override
- public int getNbRefundForPaymentAmount(final Account account, final UUID paymentId, final BigDecimal refundAmount, final TenantContext context) throws PaymentPluginApiException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public String createPaymentProviderAccount(final Account account, final CallContext context) throws PaymentPluginApiException {
- checkValidPaymentPlugin();
- checkPluginIsRunning();
-
- pluginInstance.callMethod("create_account", JavaEmbedUtils.javaToRuby(getRuntime(), account));
// TODO
return null;
}
@Override
- public List<PaymentMethodPlugin> getPaymentMethodDetails(final String accountKey, final TenantContext context) throws PaymentPluginApiException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public PaymentMethodPlugin getPaymentMethodDetail(final String accountKey, final String externalPaymentMethodId, final TenantContext context) throws PaymentPluginApiException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public String addPaymentMethod(final String accountKey, final PaymentMethodPlugin paymentMethodProps, final boolean setDefault, final CallContext context) throws PaymentPluginApiException {
+ public String addPaymentMethod(final PaymentMethodPlugin paymentMethodProps, final UUID kbAccountId, final boolean setDefault, final CallContext context) throws PaymentPluginApiException {
checkValidPaymentPlugin();
checkPluginIsRunning();
final Ruby runtime = getRuntime();
pluginInstance.callMethod("add_payment_method",
- JavaEmbedUtils.javaToRuby(runtime, accountKey),
+ JavaEmbedUtils.javaToRuby(runtime, kbAccountId.toString()),
JavaEmbedUtils.javaToRuby(runtime, paymentMethodProps));
if (setDefault) {
- setDefaultPaymentMethod(accountKey, paymentMethodProps.getExternalPaymentMethodId(), context);
+ setDefaultPaymentMethod(paymentMethodProps.getExternalPaymentMethodId(), kbAccountId, context);
}
// TODO
@@ -153,35 +128,24 @@ public class JRubyPaymentPlugin extends JRubyPlugin implements PaymentPluginApi
}
@Override
- public void updatePaymentMethod(final String accountKey, final PaymentMethodPlugin paymentMethodProps, final CallContext context) throws PaymentPluginApiException {
- checkValidPaymentPlugin();
- checkPluginIsRunning();
-
- final Ruby runtime = getRuntime();
- pluginInstance.callMethod("update_payment_method",
- JavaEmbedUtils.javaToRuby(runtime, accountKey),
- JavaEmbedUtils.javaToRuby(runtime, paymentMethodProps));
- }
-
- @Override
- public void deletePaymentMethod(final String accountKey, final String externalPaymentMethodId, final CallContext context) throws PaymentPluginApiException {
+ public void deletePaymentMethod(final String pluginPaymentMethodKey, final UUID kbAccountId, final CallContext context) throws PaymentPluginApiException {
checkValidPaymentPlugin();
checkPluginIsRunning();
final Ruby runtime = getRuntime();
pluginInstance.callMethod("delete_payment_method",
- JavaEmbedUtils.javaToRuby(runtime, accountKey),
- JavaEmbedUtils.javaToRuby(runtime, externalPaymentMethodId));
+ JavaEmbedUtils.javaToRuby(runtime, pluginPaymentMethodKey),
+ JavaEmbedUtils.javaToRuby(runtime, kbAccountId.toString()));
}
@Override
- public void setDefaultPaymentMethod(final String accountKey, final String externalPaymentMethodId, final CallContext context) throws PaymentPluginApiException {
+ public void setDefaultPaymentMethod(final String pluginPaymentMethodKey, final UUID kbAccountId, final CallContext context) throws PaymentPluginApiException {
checkValidPaymentPlugin();
checkPluginIsRunning();
final Ruby runtime = getRuntime();
pluginInstance.callMethod("set_default_payment_method",
- JavaEmbedUtils.javaToRuby(runtime, accountKey),
- JavaEmbedUtils.javaToRuby(runtime, externalPaymentMethodId));
+ JavaEmbedUtils.javaToRuby(runtime, pluginPaymentMethodKey),
+ JavaEmbedUtils.javaToRuby(runtime, kbAccountId.toString()));
}
}
diff --git a/payment/src/main/java/com/ning/billing/payment/api/DefaultPaymentApi.java b/payment/src/main/java/com/ning/billing/payment/api/DefaultPaymentApi.java
index c6e86d2..0c2bf82 100644
--- a/payment/src/main/java/com/ning/billing/payment/api/DefaultPaymentApi.java
+++ b/payment/src/main/java/com/ning/billing/payment/api/DefaultPaymentApi.java
@@ -144,12 +144,6 @@ public class DefaultPaymentApi implements PaymentApi {
}
@Override
- public String initializeAccountPlugin(final String pluginName, final Account account, final CallContext context)
- throws PaymentApiException {
- return methodProcessor.initializeAccountPlugin(pluginName, account, internalCallContextFactory.createInternalCallContext(account.getId(), context));
- }
-
- @Override
public UUID addPaymentMethod(final String pluginName, final Account account,
final boolean setDefault, final PaymentMethodPlugin paymentMethodInfo, final CallContext context)
throws PaymentApiException {
@@ -158,16 +152,9 @@ public class DefaultPaymentApi implements PaymentApi {
}
@Override
- public List<PaymentMethod> refreshPaymentMethods(final String pluginName,
- final Account account, final CallContext context)
- throws PaymentApiException {
- return methodProcessor.refreshPaymentMethods(pluginName, account, internalCallContextFactory.createInternalCallContext(account.getId(), context));
- }
-
- @Override
- public List<PaymentMethod> getPaymentMethods(final Account account, final boolean withPluginDetail, final TenantContext context)
+ public List<PaymentMethod> getPaymentMethods(final Account account, final TenantContext context)
throws PaymentApiException {
- return methodProcessor.getPaymentMethods(account, withPluginDetail, internalCallContextFactory.createInternalTenantContext(context));
+ return methodProcessor.getPaymentMethods(account, internalCallContextFactory.createInternalTenantContext(context));
}
@Override
@@ -177,15 +164,9 @@ public class DefaultPaymentApi implements PaymentApi {
}
@Override
- public PaymentMethod getPaymentMethod(final Account account, final UUID paymentMethod, final boolean withPluginDetail, final TenantContext context)
- throws PaymentApiException {
- return methodProcessor.getPaymentMethod(account, paymentMethod, withPluginDetail, internalCallContextFactory.createInternalTenantContext(context));
- }
-
- @Override
- public void updatePaymentMethod(final Account account, final UUID paymentMethodId, final PaymentMethodPlugin paymentMethodInfo, final CallContext context)
+ public PaymentMethod getPaymentMethod(final Account account, final UUID paymentMethod, final TenantContext context)
throws PaymentApiException {
- methodProcessor.updatePaymentMethod(account, paymentMethodId, paymentMethodInfo, internalCallContextFactory.createInternalCallContext(account.getId(), context));
+ return methodProcessor.getPaymentMethod(account, paymentMethod, internalCallContextFactory.createInternalTenantContext(context));
}
@Override
diff --git a/payment/src/main/java/com/ning/billing/payment/api/DefaultPaymentInfoEvent.java b/payment/src/main/java/com/ning/billing/payment/api/DefaultPaymentInfoEvent.java
index ba3dfa9..f78eb2d 100644
--- a/payment/src/main/java/com/ning/billing/payment/api/DefaultPaymentInfoEvent.java
+++ b/payment/src/main/java/com/ning/billing/payment/api/DefaultPaymentInfoEvent.java
@@ -38,8 +38,6 @@ public class DefaultPaymentInfoEvent extends DefaultBusInternalEvent implements
private final PaymentStatus status;
private final UUID userToken;
private final DateTime effectiveDate;
- private final String extFirstPaymentRefId;
- private final String extSecondPaymentRefId;
@JsonCreator
public DefaultPaymentInfoEvent(@JsonProperty("id") final UUID id, /* not used */
@@ -49,8 +47,8 @@ public class DefaultPaymentInfoEvent extends DefaultBusInternalEvent implements
@JsonProperty("amount") final BigDecimal amount,
@JsonProperty("paymentNumber") final Integer paymentNumber,
@JsonProperty("status") final PaymentStatus status,
- @JsonProperty("extFirstPaymentRefId") final String extFirstPaymentRefId,
- @JsonProperty("extSecondPaymentRefId") final String extSecondPaymentRefId,
+ @JsonProperty("extFirstPaymentRefId") final String extFirstPaymentRefId /* TODO for backward compatibility only */,
+ @JsonProperty("extSecondPaymentRefId") final String extSecondPaymentRefId /* TODO for backward compatibility only */,
@JsonProperty("userToken") final UUID userToken,
@JsonProperty("effectiveDate") final DateTime effectiveDate,
@JsonProperty("accountRecordId") final Long accountRecordId,
@@ -62,19 +60,16 @@ public class DefaultPaymentInfoEvent extends DefaultBusInternalEvent implements
this.amount = amount;
this.paymentNumber = paymentNumber;
this.status = status;
- this.extFirstPaymentRefId = extFirstPaymentRefId;
- this.extSecondPaymentRefId = extSecondPaymentRefId;
this.userToken = userToken;
this.effectiveDate = effectiveDate;
}
-
public DefaultPaymentInfoEvent(final UUID accountId, final UUID invoiceId,
final UUID paymentId, final BigDecimal amount, final Integer paymentNumber,
- final PaymentStatus status, final String extFirstPaymentRefId, final String extSecondPaymentRefId, final UUID userToken,
- final DateTime effectiveDatefinal, Long accountRecordId, final Long tenantRecordId) {
- this(UUID.randomUUID(), accountId, invoiceId, paymentId, amount, paymentNumber, status, extFirstPaymentRefId, extSecondPaymentRefId, userToken,
- effectiveDatefinal, accountRecordId, tenantRecordId);
+ final PaymentStatus status, final UUID userToken,
+ final DateTime effectiveDatefinal, final Long accountRecordId, final Long tenantRecordId) {
+ this(UUID.randomUUID(), accountId, invoiceId, paymentId, amount, paymentNumber, status, null, null, userToken,
+ effectiveDatefinal, accountRecordId, tenantRecordId);
}
public DefaultPaymentInfoEvent(final DefaultPaymentInfoEvent src) {
@@ -85,15 +80,14 @@ public class DefaultPaymentInfoEvent extends DefaultBusInternalEvent implements
src.amount,
src.paymentNumber,
src.status,
- src.extFirstPaymentRefId,
- src.extSecondPaymentRefId,
+ null,
+ null,
src.userToken,
src.effectiveDate,
src.getAccountRecordId(),
src.getTenantRecordId());
}
-
@JsonIgnore
@Override
public BusInternalEventType getBusEventType() {
@@ -115,7 +109,6 @@ public class DefaultPaymentInfoEvent extends DefaultBusInternalEvent implements
return invoiceId;
}
-
@Override
public BigDecimal getAmount() {
return amount;
@@ -136,23 +129,12 @@ public class DefaultPaymentInfoEvent extends DefaultBusInternalEvent implements
return paymentNumber;
}
-
@Override
public PaymentStatus getStatus() {
return status;
}
@Override
- public String getExtFirstPaymentRefId() {
- return extFirstPaymentRefId;
- }
-
- @Override
- public String getExtSecondPaymentRefId() {
- return extSecondPaymentRefId;
- }
-
- @Override
public String toString() {
final StringBuilder sb = new StringBuilder();
sb.append("DefaultPaymentInfoEvent");
@@ -164,8 +146,6 @@ public class DefaultPaymentInfoEvent extends DefaultBusInternalEvent implements
sb.append(", status=").append(status);
sb.append(", userToken=").append(userToken);
sb.append(", effectiveDate=").append(effectiveDate);
- sb.append(", extFirstPaymentRefId='").append(extFirstPaymentRefId).append('\'');
- sb.append(", extSecondPaymentRefId='").append(extSecondPaymentRefId).append('\'');
sb.append('}');
return sb.toString();
}
@@ -175,23 +155,22 @@ public class DefaultPaymentInfoEvent extends DefaultBusInternalEvent implements
final int prime = 31;
int result = 1;
result = prime * result
- + ((accountId == null) ? 0 : accountId.hashCode());
+ + ((accountId == null) ? 0 : accountId.hashCode());
result = prime * result + ((amount == null) ? 0 : amount.hashCode());
result = prime * result
- + ((effectiveDate == null) ? 0 : effectiveDate.hashCode());
+ + ((effectiveDate == null) ? 0 : effectiveDate.hashCode());
result = prime * result
- + ((invoiceId == null) ? 0 : invoiceId.hashCode());
+ + ((invoiceId == null) ? 0 : invoiceId.hashCode());
result = prime * result
- + ((paymentId == null) ? 0 : paymentId.hashCode());
+ + ((paymentId == null) ? 0 : paymentId.hashCode());
result = prime * result
- + ((paymentNumber == null) ? 0 : paymentNumber.hashCode());
+ + ((paymentNumber == null) ? 0 : paymentNumber.hashCode());
result = prime * result + ((status == null) ? 0 : status.hashCode());
result = prime * result
- + ((userToken == null) ? 0 : userToken.hashCode());
+ + ((userToken == null) ? 0 : userToken.hashCode());
return result;
}
-
@Override
public boolean equals(final Object obj) {
if (this == obj) {
diff --git a/payment/src/main/java/com/ning/billing/payment/api/svcs/DefaultPaymentInternalApi.java b/payment/src/main/java/com/ning/billing/payment/api/svcs/DefaultPaymentInternalApi.java
index 72ee7dd..7aa99da 100644
--- a/payment/src/main/java/com/ning/billing/payment/api/svcs/DefaultPaymentInternalApi.java
+++ b/payment/src/main/java/com/ning/billing/payment/api/svcs/DefaultPaymentInternalApi.java
@@ -52,8 +52,8 @@ public class DefaultPaymentInternalApi implements PaymentInternalApi {
}
@Override
- public PaymentMethod getPaymentMethod(final Account account, final UUID paymentMethodId, final boolean withPluginDetail, final InternalTenantContext context) throws PaymentApiException {
- return methodProcessor.getPaymentMethod(account, paymentMethodId, withPluginDetail, context);
+ public PaymentMethod getPaymentMethod(final Account account, final UUID paymentMethodId, final InternalTenantContext context) throws PaymentApiException {
+ return methodProcessor.getPaymentMethod(account, paymentMethodId, context);
}
@Override
@@ -62,7 +62,7 @@ public class DefaultPaymentInternalApi implements PaymentInternalApi {
}
@Override
- public List<PaymentMethod> getPaymentMethods(final Account account, final boolean withPluginDetail, final InternalTenantContext context) throws PaymentApiException {
- return methodProcessor.getPaymentMethods(account, withPluginDetail, context);
+ public List<PaymentMethod> getPaymentMethods(final Account account, final InternalTenantContext context) throws PaymentApiException {
+ return methodProcessor.getPaymentMethods(account, context);
}
}
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 2252bdc..cc7e6c1 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
@@ -30,7 +30,6 @@ import com.ning.billing.ErrorCode;
import com.ning.billing.account.api.Account;
import com.ning.billing.account.api.AccountApiException;
import com.ning.billing.payment.api.DefaultPaymentMethod;
-import com.ning.billing.payment.api.DefaultPaymentMethodPlugin;
import com.ning.billing.payment.api.PaymentApiException;
import com.ning.billing.payment.api.PaymentMethod;
import com.ning.billing.payment.api.PaymentMethodPlugin;
@@ -49,8 +48,6 @@ import com.ning.billing.util.svcapi.account.AccountInternalApi;
import com.ning.billing.util.svcapi.tag.TagInternalApi;
import com.ning.billing.util.svcsapi.bus.InternalBus;
-import com.google.common.base.Function;
-import com.google.common.collect.Collections2;
import com.google.common.collect.ImmutableList;
import com.google.inject.Inject;
import com.google.inject.name.Named;
@@ -76,25 +73,6 @@ public class PaymentMethodProcessor extends ProcessorBase {
return pluginRegistry.getRegisteredPluginNames();
}
- public String initializeAccountPlugin(final String pluginName, final Account account, final InternalCallContext context) throws PaymentApiException {
-
- return new WithAccountLock<String>().processAccountWithLock(locker, account.getExternalKey(), new WithAccountLockCallback<String>() {
-
- @Override
- public String doOperation() throws PaymentApiException {
- PaymentPluginApi pluginApi = null;
- try {
- // STEPH do we want to really have a default or fail?? probably fail
- pluginApi = pluginRegistry.getPlugin(pluginName);
- return pluginApi.createPaymentProviderAccount(account, context.toCallContext());
- } catch (PaymentPluginApiException e) {
- throw new PaymentApiException(ErrorCode.PAYMENT_PLUGIN_ACCOUNT_INIT,
- account.getId(), pluginApi != null ? pluginApi.getName() : null, e.getErrorMessage());
- }
- }
- });
- }
-
public UUID addPaymentMethod(final String pluginName, final Account account,
final boolean setDefault, final PaymentMethodPlugin paymentMethodProps, final InternalCallContext context)
throws PaymentApiException {
@@ -108,7 +86,7 @@ public class PaymentMethodProcessor extends ProcessorBase {
try {
pluginApi = pluginRegistry.getPlugin(pluginName);
pm = new DefaultPaymentMethod(account.getId(), pluginName, paymentMethodProps);
- final String externalId = pluginApi.addPaymentMethod(account.getExternalKey(), paymentMethodProps, setDefault, context.toCallContext());
+ final String externalId = pluginApi.addPaymentMethod(paymentMethodProps, account.getId(), setDefault, context.toCallContext());
final PaymentMethodModelDao pmModel = new PaymentMethodModelDao(pm.getId(), pm.getCreatedDate(), pm.getUpdatedDate(),
pm.getAccountId(), pm.getPluginName(), pm.isActive(), externalId);
paymentDao.insertPaymentMethod(pmModel, context);
@@ -127,55 +105,13 @@ public class PaymentMethodProcessor extends ProcessorBase {
});
}
- public List<PaymentMethod> refreshPaymentMethods(final String pluginName, final Account account, final InternalCallContext context)
- throws PaymentApiException {
- // Don't hold the account lock while fetching the payment methods
- final PaymentPluginApi pluginApi = pluginRegistry.getPlugin(pluginName);
- final List<PaymentMethodPlugin> pluginPms;
- try {
- pluginPms = pluginApi.getPaymentMethodDetails(account.getExternalKey(), context.toCallContext());
- // The method should never return null by convention, but let's not trust the plugin...
- if (pluginPms == null) {
- return ImmutableList.<PaymentMethod>of();
- }
- } catch (PaymentPluginApiException e) {
- // STEPH all errors should also take a pluginName
- throw new PaymentApiException(ErrorCode.PAYMENT_REFRESH_PAYMENT_METHOD, account.getId(), e.getErrorMessage());
- }
-
- return new WithAccountLock<List<PaymentMethod>>().processAccountWithLock(locker, account.getExternalKey(), new WithAccountLockCallback<List<PaymentMethod>>() {
-
- @Override
- public List<PaymentMethod> doOperation() throws PaymentApiException {
- final List<PaymentMethodModelDao> finalPaymentMethods = new ArrayList<PaymentMethodModelDao>();
- for (final PaymentMethodPlugin cur : pluginPms) {
- final PaymentMethod input = new DefaultPaymentMethod(account.getId(), pluginName, cur);
- final PaymentMethodModelDao pmModel = new PaymentMethodModelDao(input.getId(), input.getCreatedDate(), input.getUpdatedDate(),
- input.getAccountId(), input.getPluginName(), input.isActive(),
- input.getPluginDetail().getExternalPaymentMethodId());
- finalPaymentMethods.add(pmModel);
- }
-
- final List<PaymentMethodModelDao> refreshedPaymentMethods = paymentDao.refreshPaymentMethods(account.getId(),
- finalPaymentMethods,
- context);
- return ImmutableList.<PaymentMethod>copyOf(Collections2.transform(refreshedPaymentMethods, new Function<PaymentMethodModelDao, PaymentMethod>() {
- @Override
- public PaymentMethod apply(final PaymentMethodModelDao input) {
- return new DefaultPaymentMethod(input, getPaymentMethodDetail(pluginPms, input.getExternalId()));
- }
- }));
- }
- });
- }
-
- public List<PaymentMethod> getPaymentMethods(final Account account, final boolean withPluginDetail, final InternalTenantContext context) throws PaymentApiException {
+ public List<PaymentMethod> getPaymentMethods(final Account account, final InternalTenantContext context) throws PaymentApiException {
final List<PaymentMethodModelDao> paymentMethodModels = paymentDao.getPaymentMethods(account.getId(), context);
if (paymentMethodModels.size() == 0) {
return Collections.emptyList();
}
- return getPaymentMethodInternal(paymentMethodModels, account.getId(), account.getExternalKey(), withPluginDetail, context);
+ return getPaymentMethodInternal(paymentMethodModels, account.getId(), account.getExternalKey(), context);
}
public PaymentMethod getPaymentMethodById(final UUID paymentMethodId, final InternalTenantContext context)
@@ -187,19 +123,19 @@ public class PaymentMethodProcessor extends ProcessorBase {
return new DefaultPaymentMethod(paymentMethodModel, null);
}
- public PaymentMethod getPaymentMethod(final Account account, final UUID paymentMethodId, final boolean withPluginDetail, final InternalTenantContext context)
+ public PaymentMethod getPaymentMethod(final Account account, final UUID paymentMethodId, final InternalTenantContext context)
throws PaymentApiException {
final PaymentMethodModelDao paymentMethodModel = paymentDao.getPaymentMethod(paymentMethodId, context);
if (paymentMethodModel == null) {
throw new PaymentApiException(ErrorCode.PAYMENT_NO_SUCH_PAYMENT_METHOD, paymentMethodId);
}
final List<PaymentMethod> result = getPaymentMethodInternal(Collections.singletonList(paymentMethodModel), account.getId(),
- account.getExternalKey(), withPluginDetail, context);
+ account.getExternalKey(), context);
return (result.size() == 0) ? null : result.get(0);
}
public PaymentMethod getExternalPaymentMethod(final Account account, final InternalTenantContext context) throws PaymentApiException {
- final List<PaymentMethod> paymentMethods = getPaymentMethods(account, false, context);
+ final List<PaymentMethod> paymentMethods = getPaymentMethods(account, context);
for (final PaymentMethod paymentMethod : paymentMethods) {
if (ExternalPaymentProviderPlugin.PLUGIN_NAME.equals(paymentMethod.getPluginName())) {
return paymentMethod;
@@ -221,66 +157,17 @@ public class PaymentMethodProcessor extends ProcessorBase {
}
private List<PaymentMethod> getPaymentMethodInternal(final List<PaymentMethodModelDao> paymentMethodModels, final UUID accountId,
- final String accountKey, final boolean withPluginDetail, final InternalTenantContext context)
+ final String accountKey, final InternalTenantContext context)
throws PaymentApiException {
final List<PaymentMethod> result = new ArrayList<PaymentMethod>(paymentMethodModels.size());
- PaymentPluginApi pluginApi = null;
- try {
- List<PaymentMethodPlugin> pluginDetails = null;
- for (final PaymentMethodModelDao cur : paymentMethodModels) {
-
- if (withPluginDetail) {
- pluginApi = pluginRegistry.getPlugin(cur.getPluginName());
- pluginDetails = pluginApi.getPaymentMethodDetails(accountKey, context.toTenantContext());
- }
-
- final PaymentMethod pm = new DefaultPaymentMethod(cur, getPaymentMethodDetail(pluginDetails, cur.getExternalId()));
- result.add(pm);
- }
- } catch (PaymentPluginApiException e) {
- throw new PaymentApiException(ErrorCode.PAYMENT_GET_PAYMENT_METHODS, accountId, e.getErrorMessage());
+ for (final PaymentMethodModelDao cur : paymentMethodModels) {
+ final PaymentMethod pm = new DefaultPaymentMethod(cur, null);
+ result.add(pm);
}
return result;
}
- private PaymentMethodPlugin getPaymentMethodDetail(final List<PaymentMethodPlugin> pluginDetails, final String externalId) {
- if (pluginDetails == null) {
- return null;
- }
- for (final PaymentMethodPlugin cur : pluginDetails) {
- if (cur.getExternalPaymentMethodId().equals(externalId)) {
- return cur;
- }
- }
- return null;
- }
-
- public void updatePaymentMethod(final Account account, final UUID paymentMethodId,
- final PaymentMethodPlugin paymentMethodProps, final InternalCallContext context)
- throws PaymentApiException {
-
- new WithAccountLock<Void>().processAccountWithLock(locker, account.getExternalKey(), new WithAccountLockCallback<Void>() {
-
- @Override
- public Void doOperation() throws PaymentApiException {
- final PaymentMethodModelDao paymentMethodModel = paymentDao.getPaymentMethod(paymentMethodId, context);
- if (paymentMethodModel == null) {
- throw new PaymentApiException(ErrorCode.PAYMENT_NO_SUCH_PAYMENT_METHOD, paymentMethodId);
- }
-
- try {
- final PaymentMethodPlugin inputWithId = new DefaultPaymentMethodPlugin(paymentMethodProps, paymentMethodModel.getExternalId());
- final PaymentPluginApi pluginApi = getPluginApi(paymentMethodId, account.getId(), context);
- pluginApi.updatePaymentMethod(account.getExternalKey(), inputWithId, context.toCallContext());
- return null;
- } catch (PaymentPluginApiException e) {
- throw new PaymentApiException(ErrorCode.PAYMENT_UPD_PAYMENT_METHOD, account.getId(), e.getErrorMessage());
- }
- }
- });
- }
-
public void deletedPaymentMethod(final Account account, final UUID paymentMethodId,
final boolean deleteDefaultPaymentMethodWithAutoPayOff, final InternalCallContext context)
throws PaymentApiException {
@@ -307,8 +194,8 @@ public class PaymentMethodProcessor extends ProcessorBase {
accountInternalApi.removePaymentMethod(account.getId(), context);
}
}
- final PaymentPluginApi pluginApi = getPluginApi(paymentMethodId, account.getId(), context);
- pluginApi.deletePaymentMethod(account.getExternalKey(), paymentMethodModel.getExternalId(), context.toCallContext());
+ final PaymentPluginApi pluginApi = getPluginApi(paymentMethodId, context);
+ pluginApi.deletePaymentMethod(paymentMethodModel.getExternalId(), account.getId(), context.toCallContext());
paymentDao.deletedPaymentMethod(paymentMethodId, context);
return null;
} catch (PaymentPluginApiException e) {
@@ -333,9 +220,9 @@ public class PaymentMethodProcessor extends ProcessorBase {
}
try {
- final PaymentPluginApi pluginApi = getPluginApi(paymentMethodId, account.getId(), context);
+ final PaymentPluginApi pluginApi = getPluginApi(paymentMethodId, context);
- pluginApi.setDefaultPaymentMethod(account.getExternalKey(), paymentMethodModel.getExternalId(), context.toCallContext());
+ pluginApi.setDefaultPaymentMethod(paymentMethodModel.getExternalId(), account.getId(), context.toCallContext());
accountInternalApi.updatePaymentMethod(account.getId(), paymentMethodId, context);
return null;
} catch (PaymentPluginApiException e) {
@@ -347,7 +234,7 @@ public class PaymentMethodProcessor extends ProcessorBase {
});
}
- private PaymentPluginApi getPluginApi(final UUID paymentMethodId, final UUID accountId, final InternalTenantContext context)
+ private PaymentPluginApi getPluginApi(final UUID paymentMethodId, final InternalTenantContext context)
throws PaymentApiException {
final PaymentMethodModelDao paymentMethod = paymentDao.getPaymentMethod(paymentMethodId, context);
if (paymentMethod == null) {
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 29158c8..47ffca1 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
@@ -15,8 +15,6 @@
*/
package com.ning.billing.payment.core;
-import static com.ning.billing.payment.glue.PaymentModule.PLUGIN_EXECUTOR_NAMED;
-
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Collection;
@@ -36,7 +34,6 @@ import org.slf4j.LoggerFactory;
import com.ning.billing.ErrorCode;
import com.ning.billing.account.api.Account;
import com.ning.billing.account.api.AccountApiException;
-import com.ning.billing.util.config.PaymentConfig;
import com.ning.billing.invoice.api.Invoice;
import com.ning.billing.invoice.api.InvoiceApiException;
import com.ning.billing.payment.api.DefaultPayment;
@@ -60,6 +57,7 @@ import com.ning.billing.payment.retry.PluginFailureRetryService.PluginFailureRet
import com.ning.billing.util.callcontext.InternalCallContext;
import com.ning.billing.util.callcontext.InternalTenantContext;
import com.ning.billing.util.clock.Clock;
+import com.ning.billing.util.config.PaymentConfig;
import com.ning.billing.util.events.BusInternalEvent;
import com.ning.billing.util.events.PaymentErrorInternalEvent;
import com.ning.billing.util.globallocker.GlobalLocker;
@@ -72,6 +70,8 @@ import com.google.common.base.Predicate;
import com.google.common.collect.Collections2;
import com.google.inject.name.Named;
+import static com.ning.billing.payment.glue.PaymentModule.PLUGIN_EXECUTOR_NAMED;
+
public class PaymentProcessor extends ProcessorBase {
private final PaymentMethodProcessor paymentMethodProcessor;
@@ -414,7 +414,7 @@ public class PaymentProcessor extends ProcessorBase {
List<PaymentAttemptModelDao> allAttempts = null;
if (paymentConfig.isPaymentOff()) {
- paymentDao.updateStatusForPaymentWithAttempt(paymentInput.getId(), PaymentStatus.PAYMENT_SYSTEM_OFF, null, null, null, null, attemptInput.getId(), context);
+ paymentDao.updateStatusForPaymentWithAttempt(paymentInput.getId(), PaymentStatus.PAYMENT_SYSTEM_OFF, null, null, attemptInput.getId(), context);
allAttempts = paymentDao.getAttemptsForPayment(paymentInput.getId(), context);
return new DefaultPayment(paymentInput, allAttempts, Collections.<RefundModelDao>emptyList());
}
@@ -429,7 +429,7 @@ public class PaymentProcessor extends ProcessorBase {
case PROCESSED:
// Update Payment/PaymentAttempt status
paymentStatus = PaymentStatus.SUCCESS;
- paymentDao.updateStatusForPaymentWithAttempt(paymentInput.getId(), paymentStatus, paymentPluginInfo.getGatewayErrorCode(), null, paymentPluginInfo.getExtFirstReferenceId(), paymentPluginInfo.getExtSecondReferenceId(), attemptInput.getId(), context);
+ paymentDao.updateStatusForPaymentWithAttempt(paymentInput.getId(), paymentStatus, paymentPluginInfo.getGatewayErrorCode(), null, attemptInput.getId(), context);
// Fetch latest objects
allAttempts = paymentDao.getAttemptsForPayment(paymentInput.getId(), context);
@@ -445,7 +445,7 @@ public class PaymentProcessor extends ProcessorBase {
// Create Bus event
event = new DefaultPaymentInfoEvent(account.getId(),
invoice.getId(), payment.getId(), payment.getAmount(), payment.getPaymentNumber(), paymentStatus,
- paymentPluginInfo.getExtFirstReferenceId(), paymentPluginInfo.getExtSecondReferenceId(), context.getUserToken(), payment.getEffectiveDate(),
+ context.getUserToken(), payment.getEffectiveDate(),
context.getAccountRecordId(), context.getTenantRecordId());
break;
@@ -458,7 +458,7 @@ public class PaymentProcessor extends ProcessorBase {
paymentStatus = PaymentStatus.PAYMENT_FAILURE_ABORTED;
}
- paymentDao.updateStatusForPaymentWithAttempt(paymentInput.getId(), paymentStatus, paymentPluginInfo.getGatewayErrorCode(), paymentPluginInfo.getGatewayError(),null, null, attemptInput.getId(), context);
+ paymentDao.updateStatusForPaymentWithAttempt(paymentInput.getId(), paymentStatus, paymentPluginInfo.getGatewayErrorCode(), paymentPluginInfo.getGatewayError(), attemptInput.getId(), context);
log.info(String.format("Could not process payment for account %s, invoice %s, error = %s",
account.getId(), invoice.getId(), paymentPluginInfo.getGatewayError()));
@@ -480,7 +480,7 @@ public class PaymentProcessor extends ProcessorBase {
paymentStatus = isInstantPayment ? PaymentStatus.PAYMENT_FAILURE_ABORTED : scheduleRetryOnPluginFailure(paymentInput.getId(), context);
// STEPH message might need truncation to fit??
- paymentDao.updateStatusForPaymentWithAttempt(paymentInput.getId(), paymentStatus, null, e.getMessage(), null, null, attemptInput.getId(), context);
+ paymentDao.updateStatusForPaymentWithAttempt(paymentInput.getId(), paymentStatus, null, e.getMessage(), attemptInput.getId(), context);
throw new PaymentApiException(ErrorCode.PAYMENT_CREATE_PAYMENT, account.getId(), e.toString());
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 c826777..121ccf4 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
@@ -113,58 +113,17 @@ public class RefundProcessor extends ProcessorBase {
final BigDecimal refundAmount = computeRefundAmount(paymentId, specifiedRefundAmount, invoiceItemIdsWithAmounts, context);
try {
-
final PaymentModelDao payment = paymentDao.getPayment(paymentId, context);
if (payment == null) {
throw new PaymentApiException(ErrorCode.PAYMENT_NO_SUCH_SUCCESS_PAYMENT, paymentId);
}
- //
- // We are looking for multiple things:
- // 1. Compute totalAmountRefunded based on all Refund entries that made it to the plugin.
- // 2. If we find a CREATED entry (that did not make it to the plugin) with the same amount, we reuse the entry
- // 3. Compute foundPluginCompletedRefunds, number of refund entries for that amount that made it to the plugin
- //
- int foundPluginCompletedRefunds = 0;
- RefundModelDao refundInfo = null;
- BigDecimal totalAmountRefunded = BigDecimal.ZERO;
- final List<RefundModelDao> existingRefunds = paymentDao.getRefundsForPayment(paymentId, context);
- for (final RefundModelDao cur : existingRefunds) {
-
- final BigDecimal existingPositiveAmount = cur.getAmount();
- if (existingPositiveAmount.compareTo(refundAmount) == 0) {
- if (cur.getRefundStatus() == RefundStatus.CREATED) {
- if (refundInfo == null) {
- refundInfo = cur;
- }
- } else {
- foundPluginCompletedRefunds++;
- }
- }
- if (cur.getRefundStatus() != RefundStatus.CREATED) {
- totalAmountRefunded = totalAmountRefunded.add(existingPositiveAmount);
- }
- }
-
- if (payment.getAmount().subtract(totalAmountRefunded).compareTo(refundAmount) < 0) {
- throw new PaymentApiException(ErrorCode.PAYMENT_REFUND_AMOUNT_TOO_LARGE);
- }
-
- if (refundInfo == null) {
- refundInfo = new RefundModelDao(account.getId(), paymentId, refundAmount, account.getCurrency(), isAdjusted);
- paymentDao.insertRefund(refundInfo, context);
- }
+ final RefundModelDao refundInfo = new RefundModelDao(account.getId(), paymentId, refundAmount, account.getCurrency(), isAdjusted);
+ paymentDao.insertRefund(refundInfo, context);
final PaymentPluginApi plugin = getPaymentProviderPlugin(payment.getPaymentMethodId(), context);
- final int nbExistingRefunds = plugin.getNbRefundForPaymentAmount(account, paymentId, refundAmount, context.toCallContext());
- log.debug(String.format("found %d pluginRefunds for paymentId %s and amount %s", nbExistingRefunds, paymentId, refundAmount));
-
- if (nbExistingRefunds > foundPluginCompletedRefunds) {
- log.info("Found existing plugin refund for paymentId {}, skip plugin", paymentId);
- } else {
- // If there is no such existing refund we create it
- plugin.processRefund(account, paymentId, refundAmount, context.toCallContext());
- }
+ plugin.processRefund(paymentId, refundAmount, context.toCallContext());
+
paymentDao.updateRefundStatus(refundInfo.getId(), RefundStatus.PLUGIN_COMPLETED, context);
invoiceApi.createRefund(paymentId, refundAmount, isAdjusted, invoiceItemIdsWithAmounts, refundInfo.getId(), context);
diff --git a/payment/src/main/java/com/ning/billing/payment/dao/DefaultPaymentDao.java b/payment/src/main/java/com/ning/billing/payment/dao/DefaultPaymentDao.java
index 4ed9c5f..271eab1 100644
--- a/payment/src/main/java/com/ning/billing/payment/dao/DefaultPaymentDao.java
+++ b/payment/src/main/java/com/ning/billing/payment/dao/DefaultPaymentDao.java
@@ -16,9 +16,7 @@
package com.ning.billing.payment.dao;
-import java.util.HashSet;
import java.util.List;
-import java.util.Set;
import java.util.UUID;
import javax.inject.Inject;
@@ -96,15 +94,13 @@ public class DefaultPaymentDao implements PaymentDao {
final PaymentStatus paymentStatus,
final String gatewayErrorCode,
final String gatewayErrorMsg,
- final String extFirstPaymentRefId,
- final String extSecondPaymentRefId,
final UUID attemptId,
final InternalCallContext context) {
transactionalSqlDao.execute(new EntitySqlDaoTransactionWrapper<Void>() {
@Override
public Void inTransaction(final EntitySqlDaoWrapperFactory<EntitySqlDao> entitySqlDaoWrapperFactory) throws Exception {
- entitySqlDaoWrapperFactory.become(PaymentSqlDao.class).updatePaymentStatusAndExtRef(paymentId.toString(), paymentStatus.toString(), extFirstPaymentRefId, extSecondPaymentRefId, context);
+ entitySqlDaoWrapperFactory.become(PaymentSqlDao.class).updatePaymentStatus(paymentId.toString(), paymentStatus.toString(), context);
entitySqlDaoWrapperFactory.become(PaymentAttemptSqlDao.class).updatePaymentAttemptStatus(attemptId.toString(), paymentStatus.toString(), gatewayErrorCode, gatewayErrorMsg, context);
return null;
}
@@ -130,52 +126,6 @@ public class DefaultPaymentDao implements PaymentDao {
}
@Override
- public List<PaymentMethodModelDao> refreshPaymentMethods(final UUID accountId, final List<PaymentMethodModelDao> paymentMethods, final InternalCallContext context) {
- return transactionalSqlDao.execute(new EntitySqlDaoTransactionWrapper<List<PaymentMethodModelDao>>() {
-
- @Override
- public List<PaymentMethodModelDao> inTransaction(final EntitySqlDaoWrapperFactory<EntitySqlDao> entitySqlDaoWrapperFactory) throws Exception {
- final PaymentMethodSqlDao transactional = entitySqlDaoWrapperFactory.become(PaymentMethodSqlDao.class);
- final List<PaymentMethodModelDao> existingPaymentMethods = transactional.getByAccountId(accountId.toString(), context);
-
- final Set<String> externalPaymentIdProcessed = new HashSet<String>();
- for (final PaymentMethodModelDao finalPaymentMethod : paymentMethods) {
- boolean isExistingPaymentMethod = false;
-
- for (final PaymentMethodModelDao existingPaymentMethod : existingPaymentMethods) {
- if (existingPaymentMethod.equals(finalPaymentMethod)) {
- // We already have it - nothing to do
- isExistingPaymentMethod = true;
- break;
- } else if (existingPaymentMethod.equalsButActive(finalPaymentMethod)) {
- // We already have it but its status has changed - update it accordingly
- // Note - in the remote system, the payment method will always be active
- undeletedPaymentMethodInTransaction(entitySqlDaoWrapperFactory, existingPaymentMethod.getId(), context);
- isExistingPaymentMethod = true;
- break;
- }
- // Otherwise, we don't have it
- }
-
- if (!isExistingPaymentMethod) {
- insertPaymentMethodInTransaction(entitySqlDaoWrapperFactory, finalPaymentMethod, context);
- }
-
- externalPaymentIdProcessed.add(finalPaymentMethod.getExternalId());
- }
-
- // Finally, mark as deleted the ones that don't exist in the specified list (remote system)
- for (final PaymentMethodModelDao existingPaymentMethod : existingPaymentMethods) {
- if (!externalPaymentIdProcessed.contains(existingPaymentMethod.getExternalId())) {
- deletedPaymentMethodInTransaction(entitySqlDaoWrapperFactory, existingPaymentMethod.getId(), context);
- }
- }
- return transactional.getByAccountId(accountId.toString(), context);
- }
- });
- }
-
- @Override
public RefundModelDao insertRefund(final RefundModelDao refundInfo, final InternalCallContext context) {
return transactionalSqlDao.execute(new EntitySqlDaoTransactionWrapper<RefundModelDao>() {
diff --git a/payment/src/main/java/com/ning/billing/payment/dao/PaymentDao.java b/payment/src/main/java/com/ning/billing/payment/dao/PaymentDao.java
index 983aae9..050c693 100644
--- a/payment/src/main/java/com/ning/billing/payment/dao/PaymentDao.java
+++ b/payment/src/main/java/com/ning/billing/payment/dao/PaymentDao.java
@@ -32,7 +32,7 @@ public interface PaymentDao {
public PaymentAttemptModelDao insertNewAttemptForPayment(UUID paymentId, PaymentAttemptModelDao attempt, InternalCallContext context);
public void updateStatusForPaymentWithAttempt(UUID paymentId, PaymentStatus paymentStatus, String gatewayErrorCode,
- String gatewayErrorMsg, String extFirstPaymentRefId, String extSecondPaymentRefId,
+ String gatewayErrorMsg,
UUID attemptId, InternalCallContext context);
public PaymentAttemptModelDao getPaymentAttempt(UUID attemptId, InternalTenantContext context);
@@ -59,8 +59,6 @@ public interface PaymentDao {
public PaymentMethodModelDao insertPaymentMethod(PaymentMethodModelDao paymentMethod, InternalCallContext context);
- public List<PaymentMethodModelDao> refreshPaymentMethods(UUID accountId, List<PaymentMethodModelDao> paymentMethods, InternalCallContext context);
-
public PaymentMethodModelDao getPaymentMethod(UUID paymentMethodId, InternalTenantContext context);
public PaymentMethodModelDao getPaymentMethodIncludedDeleted(UUID paymentMethodId, InternalTenantContext context);
diff --git a/payment/src/main/java/com/ning/billing/payment/dao/PaymentSqlDao.java b/payment/src/main/java/com/ning/billing/payment/dao/PaymentSqlDao.java
index 81189e7..5b289ea 100644
--- a/payment/src/main/java/com/ning/billing/payment/dao/PaymentSqlDao.java
+++ b/payment/src/main/java/com/ning/billing/payment/dao/PaymentSqlDao.java
@@ -37,11 +37,9 @@ public interface PaymentSqlDao extends EntitySqlDao<PaymentModelDao, Payment> {
@SqlUpdate
@Audited(ChangeType.UPDATE)
- void updatePaymentStatusAndExtRef(@Bind("id") final String paymentId,
- @Bind("paymentStatus") final String paymentStatus,
- @Bind("extFirstPaymentRefId") final String extFirstPaymentRefId,
- @Bind("extSecondPaymentRefId") final String extSecondPaymentRefId,
- @BindBean final InternalCallContext context);
+ void updatePaymentStatus(@Bind("id") final String paymentId,
+ @Bind("paymentStatus") final String paymentStatus,
+ @BindBean final InternalCallContext context);
@SqlUpdate
@Audited(ChangeType.UPDATE)
diff --git a/payment/src/main/java/com/ning/billing/payment/provider/DefaultNoOpPaymentInfoPlugin.java b/payment/src/main/java/com/ning/billing/payment/provider/DefaultNoOpPaymentInfoPlugin.java
index fd588b2..bf10051 100644
--- a/payment/src/main/java/com/ning/billing/payment/provider/DefaultNoOpPaymentInfoPlugin.java
+++ b/payment/src/main/java/com/ning/billing/payment/provider/DefaultNoOpPaymentInfoPlugin.java
@@ -70,16 +70,6 @@ public class DefaultNoOpPaymentInfoPlugin implements PaymentInfoPlugin {
}
@Override
- public String getExtFirstReferenceId() {
- return null;
- }
-
- @Override
- public String getExtSecondReferenceId() {
- return null;
- }
-
- @Override
public String toString() {
final StringBuilder sb = new StringBuilder();
sb.append("DefaultNoOpPaymentInfoPlugin");
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 75c082c..1ef781a 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,13 +24,13 @@ import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicBoolean;
-import com.ning.billing.account.api.Account;
import com.ning.billing.payment.api.PaymentMethodPlugin;
import com.ning.billing.payment.plugin.api.NoOpPaymentPluginApi;
import com.ning.billing.payment.plugin.api.PaymentInfoPlugin;
import com.ning.billing.payment.plugin.api.PaymentInfoPlugin.PaymentPluginStatus;
import com.ning.billing.payment.plugin.api.PaymentPluginApiException;
-import com.ning.billing.payment.plugin.api.PaymentProviderAccount;
+import com.ning.billing.payment.plugin.api.RefundInfoPlugin;
+import com.ning.billing.payment.plugin.api.RefundInfoPlugin.RefundPluginStatus;
import com.ning.billing.util.callcontext.CallContext;
import com.ning.billing.util.callcontext.TenantContext;
import com.ning.billing.util.clock.Clock;
@@ -47,11 +47,10 @@ public class DefaultNoOpPaymentProviderPlugin implements NoOpPaymentPluginApi {
private final AtomicBoolean makeNextInvoiceFailWithException = new AtomicBoolean(false);
private final AtomicBoolean makeAllInvoicesFailWithError = new AtomicBoolean(false);
- private final Map<UUID, PaymentInfoPlugin> payments = new ConcurrentHashMap<UUID, PaymentInfoPlugin>();
+ private final Map<String, PaymentInfoPlugin> payments = new ConcurrentHashMap<String, PaymentInfoPlugin>();
// Note: we can't use HashMultiMap as we care about storing duplicate key/value pairs
- private final Multimap<UUID, BigDecimal> refunds = LinkedListMultimap.<UUID, BigDecimal>create();
+ private final Multimap<String, RefundInfoPlugin> refunds = LinkedListMultimap.<String, RefundInfoPlugin>create();
private final Map<String, List<PaymentMethodPlugin>> paymentMethods = new ConcurrentHashMap<String, List<PaymentMethodPlugin>>();
- private final Map<String, PaymentProviderAccount> accounts = new ConcurrentHashMap<String, PaymentProviderAccount>();
private final Clock clock;
@@ -89,49 +88,33 @@ public class DefaultNoOpPaymentProviderPlugin implements NoOpPaymentPluginApi {
}
@Override
- public PaymentInfoPlugin processPayment(final String externalKey, final UUID paymentId, final BigDecimal amount, final CallContext context) throws PaymentPluginApiException {
+ public PaymentInfoPlugin processPayment(final String pluginPaymentMethodKey, final UUID kbPaymentId, final BigDecimal amount, final CallContext context) throws PaymentPluginApiException {
if (makeNextInvoiceFailWithException.getAndSet(false)) {
throw new PaymentPluginApiException("", "test error");
}
final PaymentPluginStatus status = (makeAllInvoicesFailWithError.get() || makeNextInvoiceFailWithError.getAndSet(false)) ? PaymentPluginStatus.ERROR : PaymentPluginStatus.PROCESSED;
final PaymentInfoPlugin result = new DefaultNoOpPaymentInfoPlugin(amount, clock.getUTCNow(), clock.getUTCNow(), status, null);
- payments.put(paymentId, result);
+ payments.put(kbPaymentId.toString(), result);
return result;
}
@Override
- public PaymentInfoPlugin getPaymentInfo(final UUID paymentId, final TenantContext context) throws PaymentPluginApiException {
- final PaymentInfoPlugin payment = payments.get(paymentId);
+ public PaymentInfoPlugin getPaymentInfo(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 id " + paymentId);
+ throw new PaymentPluginApiException("", "No payment found for payment id " + kbPaymentId.toString());
}
return payment;
}
@Override
- public String createPaymentProviderAccount(final Account account, final CallContext context) throws PaymentPluginApiException {
- if (account != null) {
- final String id = UUID.randomUUID().toString();
- final String paymentMethodId = UUID.randomUUID().toString();
- accounts.put(account.getExternalKey(),
- new PaymentProviderAccount.Builder().setAccountKey(account.getExternalKey())
- .setId(id)
- .setDefaultPaymentMethod(paymentMethodId)
- .build());
- return id;
- } else {
- throw new PaymentPluginApiException("", "Did not get account to create payment provider account");
- }
- }
-
- @Override
- public String addPaymentMethod(final String accountKey, final PaymentMethodPlugin paymentMethodProps, final boolean setDefault, final CallContext context) throws PaymentPluginApiException {
+ public String addPaymentMethod(final PaymentMethodPlugin paymentMethodProps, final UUID kbAccountId, final boolean setDefault, final CallContext context) throws PaymentPluginApiException {
final PaymentMethodPlugin realWithID = new DefaultNoOpPaymentMethodPlugin(paymentMethodProps);
- List<PaymentMethodPlugin> pms = paymentMethods.get(accountKey);
+ List<PaymentMethodPlugin> pms = paymentMethods.get(kbAccountId.toString());
if (pms == null) {
pms = new LinkedList<PaymentMethodPlugin>();
- paymentMethods.put(accountKey, pms);
+ paymentMethods.put(kbAccountId.toString(), pms);
}
pms.add(realWithID);
@@ -139,21 +122,12 @@ public class DefaultNoOpPaymentProviderPlugin implements NoOpPaymentPluginApi {
}
@Override
- public void updatePaymentMethod(final String accountKey, final PaymentMethodPlugin paymentMethodProps, final CallContext context)
- throws PaymentPluginApiException {
- final DefaultNoOpPaymentMethodPlugin e = getPaymentMethod(accountKey, paymentMethodProps.getExternalPaymentMethodId());
- if (e != null) {
- e.setProps(paymentMethodProps.getProperties());
- }
- }
-
- @Override
- public void deletePaymentMethod(final String accountKey, final String paymentMethodId, final CallContext context) throws PaymentPluginApiException {
+ public void deletePaymentMethod(final String pluginPaymentMethodKey, final UUID kbAccountId, final CallContext context) throws PaymentPluginApiException {
PaymentMethodPlugin toBeDeleted = null;
- final List<PaymentMethodPlugin> pms = paymentMethods.get(accountKey);
+ final List<PaymentMethodPlugin> pms = paymentMethods.get(kbAccountId.toString());
if (pms != null) {
for (final PaymentMethodPlugin cur : pms) {
- if (cur.getExternalPaymentMethodId().equals(paymentMethodId)) {
+ if (cur.getExternalPaymentMethodId().equals(kbAccountId.toString())) {
toBeDeleted = cur;
break;
}
@@ -166,64 +140,28 @@ public class DefaultNoOpPaymentProviderPlugin implements NoOpPaymentPluginApi {
}
@Override
- public List<PaymentMethodPlugin> getPaymentMethodDetails(final String accountKey, final TenantContext context)
- throws PaymentPluginApiException {
- return paymentMethods.get(accountKey);
- }
-
- @Override
- public PaymentMethodPlugin getPaymentMethodDetail(final String accountKey, final String externalPaymentId, final TenantContext context)
- throws PaymentPluginApiException {
- return getPaymentMethod(accountKey, externalPaymentId);
- }
-
- @Override
- public void setDefaultPaymentMethod(final String accountKey, final String externalPaymentId, final CallContext context) throws PaymentPluginApiException {
+ public void setDefaultPaymentMethod(final String pluginPaymentMethodKey, final UUID kbAccountId, final CallContext context) throws PaymentPluginApiException {
}
@Override
- public void processRefund(final Account account, final UUID paymentId, final BigDecimal refundAmount, final CallContext context) throws PaymentPluginApiException {
- final PaymentInfoPlugin paymentInfoPlugin = getPaymentInfo(paymentId, context);
+ public RefundInfoPlugin processRefund(final UUID kbPaymentId, final BigDecimal refundAmount, final CallContext context) throws PaymentPluginApiException {
+ final PaymentInfoPlugin paymentInfoPlugin = getPaymentInfo(kbPaymentId, context);
if (paymentInfoPlugin == null) {
- throw new PaymentPluginApiException("", String.format("No payment found for paymentId %s (plugin %s)", paymentId, getName()));
+ throw new PaymentPluginApiException("", String.format("No payment found for payment id %s (plugin %s)", kbPaymentId.toString(), getName()));
}
BigDecimal maxAmountRefundable = paymentInfoPlugin.getAmount();
- for (final BigDecimal refund : refunds.get(paymentId)) {
- maxAmountRefundable = maxAmountRefundable.add(refund.negate());
+ for (final RefundInfoPlugin refund : refunds.get(kbPaymentId.toString())) {
+ maxAmountRefundable = maxAmountRefundable.add(refund.getAmount().negate());
}
if (maxAmountRefundable.compareTo(refundAmount) < 0) {
- throw new PaymentPluginApiException("", String.format("Refund amount of %s for paymentId %s is bigger than the payment amount %s (plugin %s)",
- refundAmount, paymentId, paymentInfoPlugin.getAmount(), getName()));
+ throw new PaymentPluginApiException("", String.format("Refund amount of %s for payment id %s is bigger than the payment amount %s (plugin %s)",
+ refundAmount, kbPaymentId.toString(), paymentInfoPlugin.getAmount(), getName()));
}
- refunds.put(paymentId, refundAmount);
- }
-
- @Override
- public int getNbRefundForPaymentAmount(final Account account, final UUID paymentId, final BigDecimal refundAmount, final TenantContext context) throws PaymentPluginApiException {
- int nbRefunds = 0;
- for (final BigDecimal amount : refunds.get(paymentId)) {
- if (amount.compareTo(refundAmount) == 0) {
- nbRefunds++;
- }
- }
-
- return nbRefunds;
- }
-
- private DefaultNoOpPaymentMethodPlugin getPaymentMethod(final String accountKey, final String externalPaymentId) {
- final List<PaymentMethodPlugin> pms = paymentMethods.get(accountKey);
- if (pms == null) {
- return null;
- }
-
- for (final PaymentMethodPlugin cur : pms) {
- if (cur.getExternalPaymentMethodId().equals(externalPaymentId)) {
- return (DefaultNoOpPaymentMethodPlugin) cur;
- }
- }
+ final DefaultNoOpRefundInfoPlugin refundInfoPlugin = new DefaultNoOpRefundInfoPlugin(refundAmount, clock.getUTCNow(), clock.getUTCNow(), RefundPluginStatus.PROCESSED, null);
+ refunds.put(kbPaymentId.toString(), refundInfoPlugin);
- return null;
+ return refundInfoPlugin;
}
}
diff --git a/payment/src/main/java/com/ning/billing/payment/provider/DefaultNoOpRefundInfoPlugin.java b/payment/src/main/java/com/ning/billing/payment/provider/DefaultNoOpRefundInfoPlugin.java
new file mode 100644
index 0000000..d9b9805
--- /dev/null
+++ b/payment/src/main/java/com/ning/billing/payment/provider/DefaultNoOpRefundInfoPlugin.java
@@ -0,0 +1,124 @@
+/*
+ * Copyright 2010-2013 Ning, Inc.
+ *
+ * Ning 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:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.ning.billing.payment.provider;
+
+import java.math.BigDecimal;
+
+import org.joda.time.DateTime;
+
+import com.ning.billing.payment.plugin.api.RefundInfoPlugin;
+
+public class DefaultNoOpRefundInfoPlugin implements RefundInfoPlugin {
+
+ private final BigDecimal amount;
+ private final DateTime effectiveDate;
+ private final DateTime createdDate;
+ private final RefundPluginStatus status;
+ private final String error;
+
+ public DefaultNoOpRefundInfoPlugin(final BigDecimal amount, final DateTime effectiveDate,
+ final DateTime createdDate, final RefundPluginStatus status, final String error) {
+ this.amount = amount;
+ this.effectiveDate = effectiveDate;
+ this.createdDate = createdDate;
+ this.status = status;
+ this.error = error;
+ }
+
+ @Override
+ public BigDecimal getAmount() {
+ return amount;
+ }
+
+ @Override
+ public DateTime getEffectiveDate() {
+ return effectiveDate;
+ }
+
+ @Override
+ public RefundPluginStatus getStatus() {
+ return status;
+ }
+
+ @Override
+ public DateTime getCreatedDate() {
+ return createdDate;
+ }
+
+ @Override
+ public String getGatewayError() {
+ return error;
+ }
+
+ @Override
+ public String getGatewayErrorCode() {
+ return null;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder sb = new StringBuilder();
+ sb.append("DefaultNoOpRefundInfoPlugin");
+ sb.append("{amount=").append(amount);
+ sb.append(", effectiveDate=").append(effectiveDate);
+ sb.append(", createdDate=").append(createdDate);
+ sb.append(", status=").append(status);
+ sb.append(", error='").append(error).append('\'');
+ sb.append('}');
+ return sb.toString();
+ }
+
+ @Override
+ public boolean equals(final Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+
+ final DefaultNoOpRefundInfoPlugin that = (DefaultNoOpRefundInfoPlugin) o;
+
+ if (amount != null ? !amount.equals(that.amount) : that.amount != null) {
+ return false;
+ }
+ if (createdDate != null ? !createdDate.equals(that.createdDate) : that.createdDate != null) {
+ return false;
+ }
+ if (effectiveDate != null ? !effectiveDate.equals(that.effectiveDate) : that.effectiveDate != null) {
+ return false;
+ }
+ if (error != null ? !error.equals(that.error) : that.error != null) {
+ return false;
+ }
+ if (status != that.status) {
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = amount != null ? amount.hashCode() : 0;
+ result = 31 * result + (effectiveDate != null ? effectiveDate.hashCode() : 0);
+ result = 31 * result + (createdDate != null ? createdDate.hashCode() : 0);
+ result = 31 * result + (status != null ? status.hashCode() : 0);
+ result = 31 * result + (error != null ? error.hashCode() : 0);
+ return result;
+ }
+}
diff --git a/payment/src/main/resources/com/ning/billing/payment/dao/PaymentSqlDao.sql.stg b/payment/src/main/resources/com/ning/billing/payment/dao/PaymentSqlDao.sql.stg
index f04f02e..1c6ac86 100644
--- a/payment/src/main/resources/com/ning/billing/payment/dao/PaymentSqlDao.sql.stg
+++ b/payment/src/main/resources/com/ning/billing/payment/dao/PaymentSqlDao.sql.stg
@@ -13,8 +13,6 @@ tableFields(prefix) ::= <<
, <prefix>effective_date
, <prefix>currency
, <prefix>payment_status
-, <prefix>ext_first_payment_ref_id
-, <prefix>ext_second_payment_ref_id
, <prefix>created_by
, <prefix>created_date
, <prefix>updated_by
@@ -29,8 +27,6 @@ tableValues() ::= <<
, :effectiveDate
, :currency
, :paymentStatus
-, :extFirstPaymentRefId
-, :extSecondPaymentRefId
, :createdBy
, :createdDate
, :updatedBy
diff --git a/payment/src/main/resources/com/ning/billing/payment/ddl.sql b/payment/src/main/resources/com/ning/billing/payment/ddl.sql
index 155280b..7c13e26 100644
--- a/payment/src/main/resources/com/ning/billing/payment/ddl.sql
+++ b/payment/src/main/resources/com/ning/billing/payment/ddl.sql
@@ -11,8 +11,6 @@ CREATE TABLE payments (
currency char(3),
effective_date datetime,
payment_status varchar(50),
- ext_first_payment_ref_id varchar(128),
- ext_second_payment_ref_id varchar(128),
created_by varchar(50) NOT NULL,
created_date datetime NOT NULL,
updated_by varchar(50) NOT NULL,
diff --git a/payment/src/test/java/com/ning/billing/payment/api/TestEventJson.java b/payment/src/test/java/com/ning/billing/payment/api/TestEventJson.java
index a7be9cc..84253fd 100644
--- a/payment/src/test/java/com/ning/billing/payment/api/TestEventJson.java
+++ b/payment/src/test/java/com/ning/billing/payment/api/TestEventJson.java
@@ -43,7 +43,7 @@ public class TestEventJson extends PaymentTestSuiteNoDB {
@Test(groups = "fast")
public void testPaymentInfoEvent() throws Exception {
- final PaymentInfoInternalEvent e = new DefaultPaymentInfoEvent(UUID.randomUUID(), UUID.randomUUID(), UUID.randomUUID(), new BigDecimal(12.9), new Integer(13), PaymentStatus.SUCCESS, "ext-ref1-12345", "ext-ref2-12345",
+ final PaymentInfoInternalEvent e = new DefaultPaymentInfoEvent(UUID.randomUUID(), UUID.randomUUID(), UUID.randomUUID(), new BigDecimal(12.9), new Integer(13), PaymentStatus.SUCCESS,
UUID.randomUUID(), new DateTime(), 1L, 1L);
final String json = mapper.writeValueAsString(e);
diff --git a/payment/src/test/java/com/ning/billing/payment/api/TestPaymentApi.java b/payment/src/test/java/com/ning/billing/payment/api/TestPaymentApi.java
index c62bdda..17b82d4 100644
--- a/payment/src/test/java/com/ning/billing/payment/api/TestPaymentApi.java
+++ b/payment/src/test/java/com/ning/billing/payment/api/TestPaymentApi.java
@@ -144,7 +144,7 @@ public class TestPaymentApi extends PaymentTestSuiteNoDB {
@Test(groups = "fast")
public void testPaymentMethods() throws Exception {
- List<PaymentMethod> methods = paymentApi.getPaymentMethods(account, false, callContext);
+ List<PaymentMethod> methods = paymentApi.getPaymentMethods(account, callContext);
assertEquals(methods.size(), 1);
final PaymentMethod initDefaultMethod = methods.get(0);
@@ -154,7 +154,7 @@ public class TestPaymentApi extends PaymentTestSuiteNoDB {
final UUID newPaymentMethodId = paymentApi.addPaymentMethod(TestPaymentHelper.PLUGIN_TEST_NAME, account, true, newPaymenrMethod, callContext);
Mockito.when(account.getPaymentMethodId()).thenReturn(newPaymentMethodId);
- methods = paymentApi.getPaymentMethods(account, false, callContext);
+ methods = paymentApi.getPaymentMethods(account, callContext);
assertEquals(methods.size(), 2);
assertEquals(newPaymentMethodId, account.getPaymentMethodId());
@@ -168,13 +168,13 @@ public class TestPaymentApi extends PaymentTestSuiteNoDB {
assertTrue(failed);
paymentApi.deletedPaymentMethod(account, initDefaultMethod.getId(), true, callContext);
- methods = paymentApi.getPaymentMethods(account, false, callContext);
+ methods = paymentApi.getPaymentMethods(account, callContext);
assertEquals(methods.size(), 1);
// NOW retry with default payment method with special flag
paymentApi.deletedPaymentMethod(account, newPaymentMethodId, true, callContext);
- methods = paymentApi.getPaymentMethods(account, false, callContext);
+ methods = paymentApi.getPaymentMethods(account, callContext);
assertEquals(methods.size(), 0);
}
}
diff --git a/payment/src/test/java/com/ning/billing/payment/core/TestPaymentMethodProcessor.java b/payment/src/test/java/com/ning/billing/payment/core/TestPaymentMethodProcessor.java
index d8fecc5..5d14171 100644
--- a/payment/src/test/java/com/ning/billing/payment/core/TestPaymentMethodProcessor.java
+++ b/payment/src/test/java/com/ning/billing/payment/core/TestPaymentMethodProcessor.java
@@ -37,12 +37,12 @@ public class TestPaymentMethodProcessor extends PaymentTestSuiteNoDB {
Mockito.when(account.getId()).thenReturn(accountId);
Mockito.when(account.getExternalKey()).thenReturn(accountId.toString());
- Assert.assertEquals(paymentMethodProcessor.getPaymentMethods(account, false, internalCallContext).size(), 0);
+ Assert.assertEquals(paymentMethodProcessor.getPaymentMethods(account, internalCallContext).size(), 0);
// The first call should create the payment method
final ExternalPaymentProviderPlugin providerPlugin = paymentMethodProcessor.getExternalPaymentProviderPlugin(account, internalCallContext);
Assert.assertEquals(providerPlugin.getName(), ExternalPaymentProviderPlugin.PLUGIN_NAME);
- final List<PaymentMethod> paymentMethods = paymentMethodProcessor.getPaymentMethods(account, false, internalCallContext);
+ final List<PaymentMethod> paymentMethods = paymentMethodProcessor.getPaymentMethods(account, internalCallContext);
Assert.assertEquals(paymentMethods.size(), 1);
Assert.assertEquals(paymentMethods.get(0).getPluginName(), ExternalPaymentProviderPlugin.PLUGIN_NAME);
Assert.assertEquals(paymentMethods.get(0).getAccountId(), account.getId());
@@ -53,7 +53,7 @@ public class TestPaymentMethodProcessor extends PaymentTestSuiteNoDB {
final ExternalPaymentProviderPlugin foundProviderPlugin = paymentMethodProcessor.getExternalPaymentProviderPlugin(account, internalCallContext);
Assert.assertEquals(foundProviderPlugin.getName(), ExternalPaymentProviderPlugin.PLUGIN_NAME);
- final List<PaymentMethod> foundPaymentMethods = paymentMethodProcessor.getPaymentMethods(account, false, internalCallContext);
+ final List<PaymentMethod> foundPaymentMethods = paymentMethodProcessor.getPaymentMethods(account, internalCallContext);
Assert.assertEquals(foundPaymentMethods.size(), 1);
Assert.assertEquals(foundPaymentMethods.get(0).getPluginName(), ExternalPaymentProviderPlugin.PLUGIN_NAME);
Assert.assertEquals(foundPaymentMethods.get(0).getAccountId(), account.getId());
diff --git a/payment/src/test/java/com/ning/billing/payment/dao/MockPaymentDao.java b/payment/src/test/java/com/ning/billing/payment/dao/MockPaymentDao.java
index a32aed6..d79598d 100644
--- a/payment/src/test/java/com/ning/billing/payment/dao/MockPaymentDao.java
+++ b/payment/src/test/java/com/ning/billing/payment/dao/MockPaymentDao.java
@@ -55,7 +55,7 @@ public class MockPaymentDao implements PaymentDao {
@Override
public void updateStatusForPaymentWithAttempt(final UUID paymentId, final PaymentStatus paymentStatus, final String gatewayErrorCode,
- final String gatewayErrorMsg, final String extFirstPaymentRefId, final String extSecondPaymentRefId,
+ final String gatewayErrorMsg,
final UUID attemptId, final InternalCallContext context) {
synchronized (this) {
final PaymentModelDao entry = payments.remove(paymentId);
@@ -127,11 +127,6 @@ public class MockPaymentDao implements PaymentDao {
}
@Override
- public List<PaymentMethodModelDao> refreshPaymentMethods(final UUID accountId, final List<PaymentMethodModelDao> newPaymentMethods, final InternalCallContext context) {
- throw new UnsupportedOperationException();
- }
-
- @Override
public PaymentMethodModelDao getPaymentMethod(final UUID paymentMethodId, final InternalTenantContext context) {
for (final PaymentMethodModelDao cur : paymentMethods) {
if (cur.getId().equals(paymentMethodId)) {
diff --git a/payment/src/test/java/com/ning/billing/payment/dao/TestPaymentDao.java b/payment/src/test/java/com/ning/billing/payment/dao/TestPaymentDao.java
index 61baab5..23d5bda 100644
--- a/payment/src/test/java/com/ning/billing/payment/dao/TestPaymentDao.java
+++ b/payment/src/test/java/com/ning/billing/payment/dao/TestPaymentDao.java
@@ -16,30 +16,18 @@
package com.ning.billing.payment.dao;
-import java.io.IOException;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.List;
import java.util.UUID;
import org.joda.time.DateTime;
-import org.skife.config.ConfigurationObjectFactory;
-import org.skife.jdbi.v2.IDBI;
-import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Test;
-import com.ning.billing.KillbillTestSuiteWithEmbeddedDB;
import com.ning.billing.catalog.api.Currency;
-import com.ning.billing.dbi.DBIProvider;
-import com.ning.billing.dbi.DBTestingHelper;
-import com.ning.billing.dbi.DbiConfig;
import com.ning.billing.payment.PaymentTestSuiteWithEmbeddedDB;
import com.ning.billing.payment.api.PaymentStatus;
import com.ning.billing.payment.dao.RefundModelDao.RefundStatus;
-import com.ning.billing.util.cache.CacheControllerDispatcher;
-import com.ning.billing.util.clock.Clock;
-import com.ning.billing.util.clock.DefaultClock;
-import com.ning.billing.util.dao.DefaultNonEntityDao;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
@@ -111,7 +99,7 @@ public class TestPaymentDao extends PaymentTestSuiteWithEmbeddedDB {
final PaymentStatus paymentStatus = PaymentStatus.SUCCESS;
final String gatewayErrorCode = "OK";
- paymentDao.updateStatusForPaymentWithAttempt(payment.getId(), paymentStatus, gatewayErrorCode, null, null, null, attempt.getId(), internalCallContext);
+ paymentDao.updateStatusForPaymentWithAttempt(payment.getId(), paymentStatus, gatewayErrorCode, null, attempt.getId(), internalCallContext);
final List<PaymentModelDao> payments = paymentDao.getPaymentsForInvoice(invoiceId, internalCallContext);
assertEquals(payments.size(), 1);
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 5bc8eea..390b84c 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
@@ -50,16 +50,14 @@ public class TestExternalPaymentProviderPlugin extends PaymentTestSuiteNoDB {
@Test(groups = "fast")
public void testProcessPayment() throws Exception {
- final String externalKey = UUID.randomUUID().toString();
+ final String pluginPaymentMethodKey = UUID.randomUUID().toString();
final UUID paymentId = UUID.randomUUID();
final BigDecimal amount = BigDecimal.TEN;
- final PaymentInfoPlugin paymentInfoPlugin = plugin.processPayment(externalKey, paymentId, amount, callContext);
+ final PaymentInfoPlugin paymentInfoPlugin = plugin.processPayment(pluginPaymentMethodKey, paymentId, amount, callContext);
Assert.assertEquals(paymentInfoPlugin.getAmount(), amount);
Assert.assertEquals(Seconds.secondsBetween(paymentInfoPlugin.getCreatedDate(), clock.getUTCNow()).getSeconds(), 0);
Assert.assertEquals(Seconds.secondsBetween(paymentInfoPlugin.getEffectiveDate(), clock.getUTCNow()).getSeconds(), 0);
- Assert.assertNull(paymentInfoPlugin.getExtFirstReferenceId());
- Assert.assertNull(paymentInfoPlugin.getExtSecondReferenceId());
Assert.assertNull(paymentInfoPlugin.getGatewayError());
Assert.assertNull(paymentInfoPlugin.getGatewayErrorCode());
Assert.assertEquals(paymentInfoPlugin.getStatus(), PaymentPluginStatus.PROCESSED);
@@ -70,7 +68,7 @@ public class TestExternalPaymentProviderPlugin extends PaymentTestSuiteNoDB {
@Test(groups = "fast", expectedExceptions = PaymentPluginApiException.class)
public void testRefundForNonExistingPayment() throws Exception {
- plugin.processRefund(Mockito.mock(Account.class), UUID.randomUUID(), BigDecimal.ONE, callContext);
+ plugin.processRefund(UUID.randomUUID(), BigDecimal.ONE, callContext);
}
@Test(groups = "fast", expectedExceptions = PaymentPluginApiException.class)
@@ -78,59 +76,25 @@ public class TestExternalPaymentProviderPlugin extends PaymentTestSuiteNoDB {
final UUID paymentId = UUID.randomUUID();
plugin.processPayment(UUID.randomUUID().toString(), paymentId, BigDecimal.ZERO, callContext);
- plugin.processRefund(Mockito.mock(Account.class), paymentId, BigDecimal.ONE, callContext);
+ plugin.processRefund(paymentId, BigDecimal.ONE, callContext);
}
@Test(groups = "fast")
public void testRefundTooLargeMultipleTimes() throws Exception {
+ final String pluginPaymentKey = UUID.randomUUID().toString();
final UUID paymentId = UUID.randomUUID();
plugin.processPayment(UUID.randomUUID().toString(), paymentId, BigDecimal.TEN, callContext);
final Account account = Mockito.mock(Account.class);
for (int i = 0; i < 10; i++) {
- plugin.processRefund(account, paymentId, BigDecimal.ONE, callContext);
+ plugin.processRefund(paymentId, BigDecimal.ONE, callContext);
}
try {
- plugin.processRefund(account, paymentId, BigDecimal.ONE, callContext);
+ plugin.processRefund(paymentId, BigDecimal.ONE, callContext);
Assert.fail("Shouldn't have been able to refund");
} catch (PaymentPluginApiException e) {
Assert.assertTrue(true);
}
}
-
- @Test(groups = "fast")
- public void testRefund() throws Exception {
- // An external payment refund would be e.g. a check that we trash
- final String externalKey = UUID.randomUUID().toString();
- final UUID paymentId = UUID.randomUUID();
- final BigDecimal amount = BigDecimal.TEN;
- plugin.processPayment(externalKey, paymentId, amount, callContext);
-
- plugin.processRefund(Mockito.mock(Account.class), paymentId, BigDecimal.ONE, callContext);
- Assert.assertEquals(plugin.getNbRefundForPaymentAmount(Mockito.mock(Account.class), UUID.randomUUID(), BigDecimal.ONE, callContext), 0);
- Assert.assertEquals(plugin.getNbRefundForPaymentAmount(Mockito.mock(Account.class), paymentId, BigDecimal.TEN, callContext), 0);
- Assert.assertEquals(plugin.getNbRefundForPaymentAmount(Mockito.mock(Account.class), paymentId, BigDecimal.ONE, callContext), 1);
- Assert.assertEquals(plugin.getNbRefundForPaymentAmount(Mockito.mock(Account.class), paymentId, new BigDecimal("5"), callContext), 0);
-
- // Try multiple refunds
-
- plugin.processRefund(Mockito.mock(Account.class), paymentId, BigDecimal.ONE, callContext);
- Assert.assertEquals(plugin.getNbRefundForPaymentAmount(Mockito.mock(Account.class), UUID.randomUUID(), BigDecimal.ONE, callContext), 0);
- Assert.assertEquals(plugin.getNbRefundForPaymentAmount(Mockito.mock(Account.class), paymentId, BigDecimal.TEN, callContext), 0);
- Assert.assertEquals(plugin.getNbRefundForPaymentAmount(Mockito.mock(Account.class), paymentId, BigDecimal.ONE, callContext), 2);
- Assert.assertEquals(plugin.getNbRefundForPaymentAmount(Mockito.mock(Account.class), paymentId, new BigDecimal("5"), callContext), 0);
-
- plugin.processRefund(Mockito.mock(Account.class), paymentId, BigDecimal.ONE, callContext);
- Assert.assertEquals(plugin.getNbRefundForPaymentAmount(Mockito.mock(Account.class), UUID.randomUUID(), BigDecimal.ONE, callContext), 0);
- Assert.assertEquals(plugin.getNbRefundForPaymentAmount(Mockito.mock(Account.class), paymentId, BigDecimal.TEN, callContext), 0);
- Assert.assertEquals(plugin.getNbRefundForPaymentAmount(Mockito.mock(Account.class), paymentId, BigDecimal.ONE, callContext), 3);
- Assert.assertEquals(plugin.getNbRefundForPaymentAmount(Mockito.mock(Account.class), paymentId, new BigDecimal("5"), callContext), 0);
-
- plugin.processRefund(Mockito.mock(Account.class), paymentId, new BigDecimal("5"), callContext);
- Assert.assertEquals(plugin.getNbRefundForPaymentAmount(Mockito.mock(Account.class), UUID.randomUUID(), BigDecimal.ONE, callContext), 0);
- Assert.assertEquals(plugin.getNbRefundForPaymentAmount(Mockito.mock(Account.class), paymentId, BigDecimal.TEN, callContext), 0);
- Assert.assertEquals(plugin.getNbRefundForPaymentAmount(Mockito.mock(Account.class), paymentId, BigDecimal.ONE, callContext), 3);
- Assert.assertEquals(plugin.getNbRefundForPaymentAmount(Mockito.mock(Account.class), paymentId, new BigDecimal("5"), callContext), 1);
- }
}
diff --git a/server/src/test/java/com/ning/billing/jaxrs/KillbillClient.java b/server/src/test/java/com/ning/billing/jaxrs/KillbillClient.java
index 65563d7..e4ee470 100644
--- a/server/src/test/java/com/ning/billing/jaxrs/KillbillClient.java
+++ b/server/src/test/java/com/ning/billing/jaxrs/KillbillClient.java
@@ -79,7 +79,6 @@ import com.google.common.collect.ImmutableMap;
import static com.ning.billing.jaxrs.resources.JaxrsResource.ACCOUNTS;
import static com.ning.billing.jaxrs.resources.JaxrsResource.BUNDLES;
import static com.ning.billing.jaxrs.resources.JaxrsResource.QUERY_DELETE_DEFAULT_PM_WITH_AUTO_PAY_OFF;
-import static com.ning.billing.jaxrs.resources.JaxrsResource.QUERY_PAYMENT_METHOD_PLUGIN_INFO;
import static com.ning.billing.jaxrs.resources.JaxrsResource.SUBSCRIPTIONS;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
@@ -571,7 +570,6 @@ public abstract class KillbillClient extends ServerTestSuiteWithEmbeddedDB {
final String paymentMethodURI = JaxrsResource.PAYMENT_METHODS_PATH + "/" + paymentMethodId;
final Map<String, String> queryPaymentMethods = new HashMap<String, String>();
- queryPaymentMethods.put(QUERY_PAYMENT_METHOD_PLUGIN_INFO, "true");
final Response paymentMethodResponse = doGet(paymentMethodURI, queryPaymentMethods, DEFAULT_HTTP_TIMEOUT_SEC);
assertEquals(paymentMethodResponse.getStatusCode(), Status.OK.getStatusCode());
diff --git a/server/src/test/java/com/ning/billing/jaxrs/TestAccount.java b/server/src/test/java/com/ning/billing/jaxrs/TestAccount.java
index b55604c..8f051cf 100644
--- a/server/src/test/java/com/ning/billing/jaxrs/TestAccount.java
+++ b/server/src/test/java/com/ning/billing/jaxrs/TestAccount.java
@@ -25,16 +25,13 @@ import java.util.UUID;
import javax.ws.rs.core.Response.Status;
-import org.joda.time.DateTime;
import org.testng.Assert;
import org.testng.annotations.Test;
import com.ning.billing.jaxrs.json.AccountJson;
import com.ning.billing.jaxrs.json.AccountJsonWithBalance;
-import com.ning.billing.jaxrs.json.AccountTimelineJson;
import com.ning.billing.jaxrs.json.BillCycleDayJson;
import com.ning.billing.jaxrs.json.CustomFieldJson;
-import com.ning.billing.jaxrs.json.InvoiceJsonSimple;
import com.ning.billing.jaxrs.json.PaymentJsonSimple;
import com.ning.billing.jaxrs.json.PaymentMethodJson;
import com.ning.billing.jaxrs.json.RefundJson;
@@ -155,7 +152,6 @@ public class TestAccount extends TestJaxrsBase {
// FETCH ALL PAYMENT METHODS
//
queryParams = new HashMap<String, String>();
- queryParams.put(JaxrsResource.QUERY_PAYMENT_METHOD_PLUGIN_INFO, "true");
response = doGet(uri, DEFAULT_EMPTY_QUERY, DEFAULT_HTTP_TIMEOUT_SEC);
Assert.assertEquals(response.getStatusCode(), Status.OK.getStatusCode());
baseJson = response.getResponseBody();
@@ -187,7 +183,6 @@ public class TestAccount extends TestJaxrsBase {
//
uri = JaxrsResource.ACCOUNTS_PATH + "/" + accountJson.getAccountId() + "/" + JaxrsResource.PAYMENT_METHODS;
queryParams = new HashMap<String, String>();
- queryParams.put(JaxrsResource.QUERY_PAYMENT_METHOD_PLUGIN_INFO, "true");
response = doGet(uri, DEFAULT_EMPTY_QUERY, DEFAULT_HTTP_TIMEOUT_SEC);
Assert.assertEquals(response.getStatusCode(), Status.OK.getStatusCode());
baseJson = response.getResponseBody();
diff --git a/util/src/main/java/com/ning/billing/util/events/PaymentInfoInternalEvent.java b/util/src/main/java/com/ning/billing/util/events/PaymentInfoInternalEvent.java
index 33f4f6f..956718c 100644
--- a/util/src/main/java/com/ning/billing/util/events/PaymentInfoInternalEvent.java
+++ b/util/src/main/java/com/ning/billing/util/events/PaymentInfoInternalEvent.java
@@ -13,6 +13,7 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
+
package com.ning.billing.util.events;
import java.math.BigDecimal;
@@ -37,8 +38,4 @@ public interface PaymentInfoInternalEvent extends BusInternalEvent {
public Integer getPaymentNumber();
public PaymentStatus getStatus();
-
- public String getExtFirstPaymentRefId();
-
- public String getExtSecondPaymentRefId();
}
diff --git a/util/src/main/java/com/ning/billing/util/svcapi/payment/PaymentInternalApi.java b/util/src/main/java/com/ning/billing/util/svcapi/payment/PaymentInternalApi.java
index f0d144a..7cb5116 100644
--- a/util/src/main/java/com/ning/billing/util/svcapi/payment/PaymentInternalApi.java
+++ b/util/src/main/java/com/ning/billing/util/svcapi/payment/PaymentInternalApi.java
@@ -16,7 +16,6 @@
package com.ning.billing.util.svcapi.payment;
-
import java.util.List;
import java.util.UUID;
@@ -31,12 +30,12 @@ public interface PaymentInternalApi {
public Payment getPayment(UUID paymentId, InternalTenantContext context)
throws PaymentApiException;
- public PaymentMethod getPaymentMethod(Account account, UUID paymentMethodId, boolean withPluginDetail, InternalTenantContext context)
+ public PaymentMethod getPaymentMethod(Account account, UUID paymentMethodId, InternalTenantContext context)
throws PaymentApiException;
public List<Payment> getAccountPayments(UUID accountId, InternalTenantContext context)
throws PaymentApiException;
- public List<PaymentMethod> getPaymentMethods(Account account, boolean withPluginDetail, InternalTenantContext context)
+ public List<PaymentMethod> getPaymentMethods(Account account, InternalTenantContext context)
throws PaymentApiException;
}