killbill-aplcache

Details

diff --git a/account/src/main/java/com/ning/billing/account/dao/DefaultAccountDao.java b/account/src/main/java/com/ning/billing/account/dao/DefaultAccountDao.java
index 7bc323d..1f70152 100644
--- a/account/src/main/java/com/ning/billing/account/dao/DefaultAccountDao.java
+++ b/account/src/main/java/com/ning/billing/account/dao/DefaultAccountDao.java
@@ -18,6 +18,7 @@ package com.ning.billing.account.dao;
 
 import java.util.List;
 import java.util.UUID;
+
 import org.skife.jdbi.v2.IDBI;
 import org.skife.jdbi.v2.Transaction;
 import org.skife.jdbi.v2.TransactionStatus;
@@ -151,7 +152,7 @@ public class DefaultAccountDao implements AccountDao {
             }
         }
     }
-    
+
     @Override
 	public void deleteByKey(final String externalKey) throws AccountApiException {
     	try {
@@ -198,7 +199,7 @@ public class DefaultAccountDao implements AccountDao {
         }
     }
 
-    private void saveCustomFieldsFromWithinTransaction(final Account account, final AccountSqlDao transactionalDao, final boolean isCreation) {
+    private void saveTagsFromWithinTransaction(final Account account, final AccountSqlDao transactionalDao, final boolean isCreation) {
         String accountId = account.getId().toString();
         String objectType = account.getObjectName();
 
@@ -213,7 +214,7 @@ public class DefaultAccountDao implements AccountDao {
         }
     }
 
-    private void saveTagsFromWithinTransaction(final Account account, final AccountSqlDao transactionalDao, final boolean isCreation) {
+    private void saveCustomFieldsFromWithinTransaction(final Account account, final AccountSqlDao transactionalDao, final boolean isCreation) {
         String accountId = account.getId().toString();
         String objectType = account.getObjectName();
 
@@ -228,5 +229,5 @@ public class DefaultAccountDao implements AccountDao {
         }
     }
 
-	
+
 }
diff --git a/api/src/main/java/com/ning/billing/payment/api/CreditCardPaymentMethodInfo.java b/api/src/main/java/com/ning/billing/payment/api/CreditCardPaymentMethodInfo.java
index 75a4ab2..6f767ff 100644
--- a/api/src/main/java/com/ning/billing/payment/api/CreditCardPaymentMethodInfo.java
+++ b/api/src/main/java/com/ning/billing/payment/api/CreditCardPaymentMethodInfo.java
@@ -23,6 +23,12 @@ public final class CreditCardPaymentMethodInfo extends PaymentMethodInfo {
         private String cardType;
         private String expirationDate;
         private String maskNumber;
+        private String cardAddress1;
+        private String cardAddress2;
+        private String cardCity;
+        private String cardState;
+        private String cardPostalCode;
+        private String cardCountry;
 
         public Builder() {
             super(Builder.class);
@@ -47,13 +53,55 @@ public final class CreditCardPaymentMethodInfo extends PaymentMethodInfo {
             return this;
         }
 
+        public Builder setCardAddress1(String creditCardAddress1) {
+            this.cardAddress1 = creditCardAddress1;
+            return this;
+        }
+
+        public Builder setCardAddress2(String creditCardAddress2) {
+            this.cardAddress2 = creditCardAddress2;
+            return this;
+        }
+
+        public Builder setCardCity(String creditCardCity) {
+            this.cardCity = creditCardCity;
+            return this;
+        }
+
+        public Builder setCardState(String creditCardState) {
+            this.cardState = creditCardState;
+            return this;
+        }
+
+        public Builder setCardPostalCode(String creditCardPostalCode) {
+            this.cardPostalCode = creditCardPostalCode;
+            return this;
+        }
+
+        public Builder setCardCountry(String creditCardCountry) {
+            this.cardCountry = creditCardCountry;
+            return this;
+        }
+
         public Builder setMaskNumber(String maskNumber) {
             this.maskNumber = maskNumber;
             return this;
         }
 
         public CreditCardPaymentMethodInfo build() {
-            return new CreditCardPaymentMethodInfo(id, accountId, defaultMethod, cardHolderName, cardType, expirationDate, maskNumber);
+            return new CreditCardPaymentMethodInfo(id,
+                                                   accountId,
+                                                   defaultMethod,
+                                                   cardHolderName,
+                                                   cardType,
+                                                   expirationDate,
+                                                   maskNumber,
+                                                   cardAddress1,
+                                                   cardAddress2,
+                                                   cardCity,
+                                                   cardState,
+                                                   cardPostalCode,
+                                                   cardCountry);
         }
     }
 
@@ -61,6 +109,12 @@ public final class CreditCardPaymentMethodInfo extends PaymentMethodInfo {
     private final String cardType;
     private final String expirationDate;
     private final String maskNumber;
+    private final String cardAddress1;
+    private final String cardAddress2;
+    private final String cardCity;
+    private final String cardState;
+    private final String cardPostalCode;
+    private final String cardCountry;
 
     public CreditCardPaymentMethodInfo(String id,
                                    String accountId,
@@ -68,12 +122,25 @@ public final class CreditCardPaymentMethodInfo extends PaymentMethodInfo {
                                    String cardHolderName,
                                    String cardType,
                                    String expirationDate,
-                                   String maskNumber) {
+                                   String maskNumber,
+                                   String cardAddress1,
+                                   String cardAddress2,
+                                   String cardCity,
+                                   String cardState,
+                                   String cardPostalCode,
+                                   String cardCountry) {
+
       super(id, accountId, defaultMethod, "CreditCard");
       this.cardHolderName = cardHolderName;
       this.cardType = cardType;
       this.expirationDate = expirationDate;
       this.maskNumber = maskNumber;
+      this.cardAddress1 = cardAddress1;
+      this.cardAddress2 = cardAddress2;
+      this.cardCity = cardCity;
+      this.cardState = cardState;
+      this.cardPostalCode = cardPostalCode;
+      this.cardCountry = cardCountry;
     }
 
     public String getCardHolderName() {
@@ -84,6 +151,30 @@ public final class CreditCardPaymentMethodInfo extends PaymentMethodInfo {
       return cardType;
     }
 
+    public String getCardAddress1() {
+        return cardAddress1;
+    }
+
+    public String getCardAddress2() {
+        return cardAddress2;
+    }
+
+    public String getCardCity() {
+        return cardCity;
+    }
+
+    public String getCardState() {
+        return cardState;
+    }
+
+    public String getCardPostalCode() {
+        return cardPostalCode;
+    }
+
+    public String getCardCountry() {
+        return cardCountry;
+    }
+
     public String getExpirationDate() {
       return expirationDate;
     }
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 8e665ed..be1f649 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
@@ -23,18 +23,19 @@ import javax.annotation.Nullable;
 import com.ning.billing.account.api.Account;
 
 public interface PaymentApi {
-    Either<PaymentError, PaymentMethodInfo> getPaymentMethod(@Nullable String accountKey, String paymentMethodId);
 
-    Either<PaymentError, List<PaymentMethodInfo>> getPaymentMethods(String accountKey);
+    Either<PaymentError, Void> updatePaymentGateway(String accountKey);
 
-    Either<PaymentError, Void> deletePaymentMethod(String accountKey, String paymentMethodId);
+    Either<PaymentError, PaymentMethodInfo> getPaymentMethod(@Nullable String accountKey, String paymentMethodId);
 
-    Either<PaymentError, Void> updatePaymentGateway(String accountKey);
+    Either<PaymentError, List<PaymentMethodInfo>> getPaymentMethods(String accountKey);
 
-    Either<PaymentError, String> addPaypalPaymentMethod(@Nullable String accountKey, PaypalPaymentMethodInfo paypalPaymentMethod);
+    Either<PaymentError, String> addPaymentMethod(@Nullable String accountKey, PaymentMethodInfo paymentMethod);
 
     Either<PaymentError, PaymentMethodInfo> updatePaymentMethod(String accountKey, PaymentMethodInfo paymentMethodInfo);
 
+    Either<PaymentError, Void> deletePaymentMethod(String accountKey, String paymentMethodId);
+
     List<Either<PaymentError, PaymentInfo>> createPayment(String accountKey, List<String> invoiceIds);
     List<Either<PaymentError, PaymentInfo>> createPayment(Account account, List<String> invoiceIds);
 
@@ -44,7 +45,7 @@ public interface PaymentApi {
 
     Either<PaymentError, String> createPaymentProviderAccount(Account account);
 
-    Either<PaymentError, PaymentProviderAccount> updatePaymentProviderAccount(Account account);
+    Either<PaymentError, Void> updatePaymentProviderAccount(Account account);
 
     PaymentAttempt getPaymentAttemptForPaymentId(String id);
 
diff --git a/api/src/main/java/com/ning/billing/payment/api/PaypalPaymentMethodInfo.java b/api/src/main/java/com/ning/billing/payment/api/PaypalPaymentMethodInfo.java
index 65c36e9..8b94f15 100644
--- a/api/src/main/java/com/ning/billing/payment/api/PaypalPaymentMethodInfo.java
+++ b/api/src/main/java/com/ning/billing/payment/api/PaypalPaymentMethodInfo.java
@@ -20,6 +20,8 @@ import com.google.common.base.Strings;
 
 
 public final class PaypalPaymentMethodInfo extends PaymentMethodInfo {
+    public static final String TYPE = "PayPal";
+
     public static final class Builder extends BuilderBase<PaypalPaymentMethodInfo, Builder> {
         private String baid;
         private String email;
@@ -55,7 +57,7 @@ public final class PaypalPaymentMethodInfo extends PaymentMethodInfo {
                                    Boolean defaultMethod,
                                    String baid,
                                    String email) {
-        super(id, accountId, defaultMethod, "PayPal");
+        super(id, accountId, defaultMethod, TYPE);
 
         if (Strings.isNullOrEmpty(accountId) || Strings.isNullOrEmpty(baid) || Strings.isNullOrEmpty(email)) {
             throw new IllegalArgumentException("accountId, baid and email should be present");
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 69e0dfe..b8e5b9e 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
@@ -70,9 +70,6 @@ public class DefaultPaymentApi implements PaymentApi {
             if (account != null) {
                 return getPaymentProviderPlugin(account);
             }
-            else {
-                throw new IllegalArgumentException("Did not find account with accountKey " + accountKey);
-            }
         }
 
         return pluginRegistry.getPlugin(paymentProviderName);
@@ -107,21 +104,21 @@ public class DefaultPaymentApi implements PaymentApi {
     }
 
     @Override
-    public Either<PaymentError, String> addPaypalPaymentMethod(@Nullable String accountKey, PaypalPaymentMethodInfo paypalPaymentMethod) {
+    public Either<PaymentError, String> addPaymentMethod(@Nullable String accountKey, PaymentMethodInfo paymentMethod) {
         final PaymentProviderPlugin plugin = getPaymentProviderPlugin(accountKey);
-        return plugin.addPaypalPaymentMethod(accountKey, paypalPaymentMethod);
+        return plugin.addPaymentMethod(accountKey, paymentMethod);
     }
 
     @Override
     public Either<PaymentError, Void> deletePaymentMethod(String accountKey, String paymentMethodId) {
         final PaymentProviderPlugin plugin = getPaymentProviderPlugin(accountKey);
-        return plugin.deletePaypalPaymentMethod(accountKey, paymentMethodId);
+        return plugin.deletePaymentMethod(accountKey, paymentMethodId);
     }
 
     @Override
     public Either<PaymentError, PaymentMethodInfo> updatePaymentMethod(String accountKey, PaymentMethodInfo paymentMethodInfo) {
         final PaymentProviderPlugin plugin = getPaymentProviderPlugin(accountKey);
-        return plugin.updatePaypalPaymentMethod(accountKey, paymentMethodInfo);
+        return plugin.updatePaymentMethod(accountKey, paymentMethodInfo);
     }
 
     @Override
@@ -184,9 +181,9 @@ public class DefaultPaymentApi implements PaymentApi {
     }
 
     @Override
-    public Either<PaymentError, PaymentProviderAccount> updatePaymentProviderAccount(Account account) {
+    public Either<PaymentError, Void> updatePaymentProviderAccount(Account account) {
         final PaymentProviderPlugin plugin = getPaymentProviderPlugin(account);
-        return plugin.updatePaymentProviderAccount(account);
+        return plugin.updatePaymentProviderAccountWithExistingContact(account);
     }
 
     @Override
diff --git a/payment/src/main/java/com/ning/billing/payment/provider/PaymentProviderPlugin.java b/payment/src/main/java/com/ning/billing/payment/provider/PaymentProviderPlugin.java
index 460951d..e1bc1c3 100644
--- a/payment/src/main/java/com/ning/billing/payment/provider/PaymentProviderPlugin.java
+++ b/payment/src/main/java/com/ning/billing/payment/provider/PaymentProviderPlugin.java
@@ -25,21 +25,22 @@ import com.ning.billing.payment.api.PaymentError;
 import com.ning.billing.payment.api.PaymentInfo;
 import com.ning.billing.payment.api.PaymentMethodInfo;
 import com.ning.billing.payment.api.PaymentProviderAccount;
-import com.ning.billing.payment.api.PaypalPaymentMethodInfo;
 
 public interface PaymentProviderPlugin {
     Either<PaymentError, PaymentInfo> processInvoice(Account account, Invoice invoice);
     Either<PaymentError, String> createPaymentProviderAccount(Account account);
-    Either<PaymentError, String> addPaypalPaymentMethod(String accountId, PaypalPaymentMethodInfo paypalPaymentMethod);
-    Either<PaymentError, PaymentProviderAccount> updatePaymentProviderAccount(Account account);
 
     Either<PaymentError, PaymentInfo> getPaymentInfo(String paymentId);
-    Either<PaymentError, PaymentMethodInfo> getPaymentMethodInfo(String paymentMethodId);
     Either<PaymentError, PaymentProviderAccount> getPaymentProviderAccount(String accountKey);
+    Either<PaymentError, Void> updatePaymentGateway(String accountKey);
+
+    Either<PaymentError, PaymentMethodInfo> getPaymentMethodInfo(String paymentMethodId);
     Either<PaymentError, List<PaymentMethodInfo>> getPaymentMethods(String accountKey);
+    Either<PaymentError, String> addPaymentMethod(String accountKey, PaymentMethodInfo paymentMethod);
+    Either<PaymentError, PaymentMethodInfo> updatePaymentMethod(String accountKey, PaymentMethodInfo paymentMethodInfo);
+    Either<PaymentError, Void> deletePaymentMethod(String accountKey, String paymentMethodId);
 
-    Either<PaymentError, Void> updatePaymentGateway(String accountKey);
-    Either<PaymentError, Void> deletePaypalPaymentMethod(String accountKey, String paymentMethodId);
-    Either<PaymentError, PaymentMethodInfo> updatePaypalPaymentMethod(String accountKey, PaymentMethodInfo paymentMethodInfo);
+    Either<PaymentError, Void> updatePaymentProviderAccountWithExistingContact(Account account);
+    Either<PaymentError, Void> updatePaymentProviderAccountWithNewContact(Account account);
 
 }
diff --git a/payment/src/test/java/com/ning/billing/payment/provider/MockPaymentProviderPlugin.java b/payment/src/test/java/com/ning/billing/payment/provider/MockPaymentProviderPlugin.java
index 121db01..14a438f 100644
--- a/payment/src/test/java/com/ning/billing/payment/provider/MockPaymentProviderPlugin.java
+++ b/payment/src/test/java/com/ning/billing/payment/provider/MockPaymentProviderPlugin.java
@@ -16,16 +16,21 @@
 
 package com.ning.billing.payment.provider;
 
+import java.util.ArrayList;
+import java.util.Collection;
 import java.util.List;
 import java.util.Map;
 import java.util.UUID;
 import java.util.concurrent.ConcurrentHashMap;
 
-import org.apache.commons.lang.math.RandomUtils;
+import org.apache.commons.lang.RandomStringUtils;
 import org.joda.time.DateTime;
 
+import com.google.common.base.Predicate;
+import com.google.common.collect.Collections2;
 import com.ning.billing.account.api.Account;
 import com.ning.billing.invoice.api.Invoice;
+import com.ning.billing.payment.api.CreditCardPaymentMethodInfo;
 import com.ning.billing.payment.api.Either;
 import com.ning.billing.payment.api.PaymentError;
 import com.ning.billing.payment.api.PaymentInfo;
@@ -36,20 +41,20 @@ import com.ning.billing.payment.api.PaypalPaymentMethodInfo;
 public class MockPaymentProviderPlugin implements PaymentProviderPlugin {
     private final Map<String, PaymentInfo> payments = new ConcurrentHashMap<String, PaymentInfo>();
     private final Map<String, PaymentProviderAccount> accounts = new ConcurrentHashMap<String, PaymentProviderAccount>();
+    private final Map<String, PaymentMethodInfo> paymentMethods = new ConcurrentHashMap<String, PaymentMethodInfo>();
 
     @Override
     public Either<PaymentError, PaymentInfo> processInvoice(Account account, Invoice invoice) {
         PaymentInfo payment = new PaymentInfo.Builder().setPaymentId(UUID.randomUUID().toString())
-                                            .setAmount(invoice.getBalance())
-                                            .setStatus("Processed")
-                                            .setBankIdentificationNumber("1234")
-                                            .setCreatedDate(new DateTime())
-                                            .setEffectiveDate(new DateTime())
-                                            .setPaymentNumber("12345")
-                                            .setReferenceId("12345")
-                                            .setType("Electronic")
-                                            .build();
-
+                                             .setAmount(invoice.getAmountOutstanding())
+                                             .setStatus("Processed")
+                                             .setBankIdentificationNumber("1234")
+                                             .setCreatedDate(new DateTime())
+                                             .setEffectiveDate(new DateTime())
+                                             .setPaymentNumber("12345")
+                                             .setReferenceId("12345")
+                                             .setType("Electronic")
+                                             .build();
         payments.put(payment.getPaymentId(), payment);
         return Either.right(payment);
     }
@@ -69,13 +74,14 @@ public class MockPaymentProviderPlugin implements PaymentProviderPlugin {
     @Override
     public Either<PaymentError, String> createPaymentProviderAccount(Account account) {
         if (account != null) {
-            PaymentProviderAccount paymentProviderAccount = accounts.put(account.getExternalKey(),
-                                                                         new PaymentProviderAccount.Builder().setAccountNumber(String.valueOf(RandomUtils.nextInt(10)))
-                                                                                                             .setDefaultPaymentMethod(String.valueOf(RandomUtils.nextInt(10)))
-                                                                                                             .setId(String.valueOf(RandomUtils.nextInt(10)))
-                                                                                                             .build());
-
-            return Either.right(paymentProviderAccount.getId());
+            String id = String.valueOf(RandomStringUtils.random(10));
+            accounts.put(account.getExternalKey(),
+                         new PaymentProviderAccount.Builder().setAccountNumber(String.valueOf(RandomStringUtils.random(10)))
+                                                             .setDefaultPaymentMethod(String.valueOf(RandomStringUtils.random(10)))
+                                                             .setId(id)
+                                                             .build());
+
+            return Either.right(id);
         }
         else {
             return Either.left(new PaymentError("unknown", "Did not get account to create payment provider account"));
@@ -83,51 +89,115 @@ public class MockPaymentProviderPlugin implements PaymentProviderPlugin {
     }
 
     @Override
-    public Either<PaymentError, PaymentProviderAccount> updatePaymentProviderAccount(Account account) {
-        // TODO Auto-generated method stub
-        return null;
+    public Either<PaymentError, PaymentProviderAccount> getPaymentProviderAccount(String accountKey) {
+        if (accountKey != null) {
+            return Either.right(accounts.get(accountKey));
+        }
+        else {
+            return Either.left(new PaymentError("unknown", "Did not get account for accountKey " + accountKey));
+        }
     }
 
     @Override
-    public Either<PaymentError, PaymentMethodInfo> getPaymentMethodInfo(String paymentMethodId) {
-        // TODO
-        return Either.left(new PaymentError("unknown", "Not implemented"));
+    public Either<PaymentError, String> addPaymentMethod(String accountKey, PaymentMethodInfo paymentMethod) {
+        if (paymentMethod != null) {
+            String paymentMethodId = RandomStringUtils.random(10);
+            PaymentMethodInfo realPaymentMethod = null;
+
+            if (paymentMethod instanceof PaypalPaymentMethodInfo) {
+                PaypalPaymentMethodInfo paypalPaymentMethod = (PaypalPaymentMethodInfo)paymentMethod;
+                realPaymentMethod = new PaypalPaymentMethodInfo.Builder(paypalPaymentMethod).setId(paymentMethodId).build();
+            }
+            else if (paymentMethod instanceof CreditCardPaymentMethodInfo) {
+                CreditCardPaymentMethodInfo ccPaymentMethod = (CreditCardPaymentMethodInfo)paymentMethod;
+                realPaymentMethod = new CreditCardPaymentMethodInfo.Builder(ccPaymentMethod).setId(paymentMethodId).build();
+            }
+            if (realPaymentMethod == null) {
+                return Either.left(new PaymentError("unsupported", "Payment method " + paymentMethod.getType() + " not supported by the plugin"));
+            }
+            else {
+                paymentMethods.put(paymentMethodId, paymentMethod);
+                return Either.right(paymentMethodId);
+            }
+        }
+        else {
+            return Either.left(new PaymentError("unknown", "Could not create add payment method " + paymentMethod + " for " + accountKey));
+        }
     }
 
     @Override
-    public Either<PaymentError, List<PaymentMethodInfo>> getPaymentMethods(String accountId) {
-        // TODO
-        return Either.left(new PaymentError("unknown", "Not implemented"));
+    public Either<PaymentError, PaymentMethodInfo> updatePaymentMethod(String accountKey, PaymentMethodInfo paymentMethod) {
+        if (paymentMethod != null) {
+            PaymentMethodInfo realPaymentMethod = null;
+
+            if (paymentMethod instanceof PaypalPaymentMethodInfo) {
+                PaypalPaymentMethodInfo paypalPaymentMethod = (PaypalPaymentMethodInfo)paymentMethod;
+                realPaymentMethod = new PaypalPaymentMethodInfo.Builder(paypalPaymentMethod).build();
+            }
+            else if (paymentMethod instanceof CreditCardPaymentMethodInfo) {
+                CreditCardPaymentMethodInfo ccPaymentMethod = (CreditCardPaymentMethodInfo)paymentMethod;
+                realPaymentMethod = new CreditCardPaymentMethodInfo.Builder(ccPaymentMethod).build();
+            }
+            if (realPaymentMethod == null) {
+                return Either.left(new PaymentError("unsupported", "Payment method " + paymentMethod.getType() + " not supported by the plugin"));
+            }
+            else {
+                paymentMethods.put(paymentMethod.getId(), paymentMethod);
+                return Either.right(realPaymentMethod);
+            }
+        }
+        else {
+            return Either.left(new PaymentError("unknown", "Could not create add payment method " + paymentMethod + " for " + accountKey));
+        }
     }
 
     @Override
-    public Either<PaymentError, Void> updatePaymentGateway(String accountKey) {
-        // TODO
-        return Either.left(new PaymentError("unknown", "Not implemented"));
+    public Either<PaymentError, Void> deletePaymentMethod(String accountKey, String paymentMethodId) {
+        if (paymentMethods.remove(paymentMethodId) == null) {
+            return Either.left(new PaymentError("unknown", "Did not get any result back"));
+        }
+        else {
+            return Either.right(null);
+        }
     }
 
     @Override
-    public Either<PaymentError, PaymentProviderAccount> getPaymentProviderAccount(String accountKey) {
-        // TODO
-        return Either.left(new PaymentError("unknown", "Not implemented"));
+    public Either<PaymentError, PaymentMethodInfo> getPaymentMethodInfo(String paymentMethodId) {
+        if (paymentMethodId != null) {
+            return Either.left(new PaymentError("unknown", "Could not retrieve payment method for paymentMethodId " + paymentMethodId));
+        }
+
+        return Either.right(paymentMethods.get(paymentMethodId));
+    }
+
+    @Override
+    public Either<PaymentError, List<PaymentMethodInfo>> getPaymentMethods(final String accountId) {
+
+        Collection<PaymentMethodInfo> filteredPaymentMethods = Collections2.filter(paymentMethods.values(), new Predicate<PaymentMethodInfo>() {
+            @Override
+            public boolean apply(PaymentMethodInfo input) {
+                return accountId.equals(input.getAccountId());
+            }
+        });
+        List<PaymentMethodInfo> result = new ArrayList<PaymentMethodInfo>(filteredPaymentMethods);
+        return Either.right(result);
     }
 
     @Override
-    public Either<PaymentError, String> addPaypalPaymentMethod(String accountId, PaypalPaymentMethodInfo paypalPaymentMethod) {
-        // TODO
-        return Either.left(new PaymentError("unknown", "Not implemented"));
+    public Either<PaymentError, Void> updatePaymentGateway(String accountKey) {
+        return Either.right(null);
     }
 
     @Override
-    public Either<PaymentError, Void> deletePaypalPaymentMethod(String accountKey, String paymentMethodId) {
-        // TODO
-        return Either.left(new PaymentError("unknown", "Not implemented"));
+    public Either<PaymentError, Void> updatePaymentProviderAccountWithExistingContact(Account account) {
+        // nothing to do here
+        return Either.right(null);
     }
 
     @Override
-    public Either<PaymentError, PaymentMethodInfo> updatePaypalPaymentMethod(String accountKey, PaymentMethodInfo paymentMethodInfo) {
-        // TODO
-        return Either.left(new PaymentError("unknown", "Not implemented"));
+    public Either<PaymentError, Void> updatePaymentProviderAccountWithNewContact(Account account) {
+        // nothing to do here
+        return Either.right(null);
     }
 
 }