killbill-aplcache
Changes
payment/src/main/java/com/ning/billing/payment/provider/NoOpPaymentProviderPluginModule.java 36(+36 -0)
Details
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 0977071..3b2ebed 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
@@ -16,6 +16,9 @@
package com.ning.billing.payment.api;
+import org.codehaus.jackson.annotate.JsonCreator;
+import org.codehaus.jackson.annotate.JsonProperty;
+
import com.google.common.base.Strings;
@@ -54,11 +57,12 @@ public final class PaypalPaymentMethodInfo extends PaymentMethodInfo {
private final String baid;
private final String email;
- public PaypalPaymentMethodInfo(String id,
- String accountId,
- Boolean defaultMethod,
- String baid,
- String email) {
+ @JsonCreator
+ public PaypalPaymentMethodInfo(@JsonProperty("id") String id,
+ @JsonProperty("accountId") String accountId,
+ @JsonProperty("defaultMethod") Boolean defaultMethod,
+ @JsonProperty("baid") String baid,
+ @JsonProperty("email") String email) {
super(id, accountId, defaultMethod, TYPE);
if (Strings.isNullOrEmpty(baid) || Strings.isNullOrEmpty(email)) {
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 20923e4..04ee105 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
@@ -178,9 +178,9 @@ public class DefaultPaymentApi implements PaymentApi {
invoicePaymentApi.notifyOfPaymentAttempt(new DefaultInvoicePayment(paymentAttempt.getPaymentAttemptId(),
invoice.getId(),
paymentAttempt.getPaymentAttemptDate(),
- paymentInfo == null ? null : paymentInfo.getAmount(),
+ paymentInfo == null || paymentInfo.getStatus().equalsIgnoreCase("Error") ? null : paymentInfo.getAmount(),
// paymentInfo.getRefundAmount(), TODO
- paymentInfo == null ? null : invoice.getCurrency()));
+ paymentInfo == null || paymentInfo.getStatus().equalsIgnoreCase("Error") ? null : invoice.getCurrency()));
}
}
diff --git a/payment/src/main/java/com/ning/billing/payment/provider/NoOpPaymentProviderPlugin.java b/payment/src/main/java/com/ning/billing/payment/provider/NoOpPaymentProviderPlugin.java
new file mode 100644
index 0000000..71c7e41
--- /dev/null
+++ b/payment/src/main/java/com/ning/billing/payment/provider/NoOpPaymentProviderPlugin.java
@@ -0,0 +1,108 @@
+/*
+ * Copyright 2010-2012 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.util.Arrays;
+import java.util.List;
+import java.util.UUID;
+
+import org.joda.time.DateTime;
+import org.joda.time.DateTimeZone;
+
+import com.ning.billing.account.api.Account;
+import com.ning.billing.invoice.api.Invoice;
+import com.ning.billing.payment.api.Either;
+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;
+
+public class NoOpPaymentProviderPlugin implements PaymentProviderPlugin {
+
+ @Override
+ public Either<PaymentError, PaymentInfo> processInvoice(Account account, Invoice invoice) {
+ PaymentInfo payment = new PaymentInfo.Builder()
+ .setPaymentId(UUID.randomUUID().toString())
+ .setAmount(invoice.getBalance())
+ .setStatus("Processed")
+ .setCreatedDate(new DateTime(DateTimeZone.UTC))
+ .setEffectiveDate(new DateTime(DateTimeZone.UTC))
+ .setType("Electronic")
+ .build();
+ return Either.right(payment);
+ }
+
+ @Override
+ public Either<PaymentError, PaymentInfo> getPaymentInfo(String paymentId) {
+ return Either.right(null);
+ }
+
+ @Override
+ public Either<PaymentError, String> createPaymentProviderAccount(Account account) {
+ return Either.left(new PaymentError("unsupported", "Account creation not supported in this plugin"));
+ }
+
+ @Override
+ public Either<PaymentError, PaymentProviderAccount> getPaymentProviderAccount(String accountKey) {
+ return Either.right(null);
+ }
+
+ @Override
+ public Either<PaymentError, String> addPaymentMethod(String accountKey, PaymentMethodInfo paymentMethod) {
+ return Either.right(null);
+ }
+
+ public void setDefaultPaymentMethodOnAccount(PaymentProviderAccount account, String paymentMethodId) {
+ // NO-OP
+ }
+
+ @Override
+ public Either<PaymentError, PaymentMethodInfo> updatePaymentMethod(String accountKey, PaymentMethodInfo paymentMethod) {
+ return Either.right(paymentMethod);
+ }
+
+ @Override
+ public Either<PaymentError, Void> deletePaymentMethod(String accountKey, String paymentMethodId) {
+ return Either.right(null);
+ }
+
+ @Override
+ public Either<PaymentError, PaymentMethodInfo> getPaymentMethodInfo(String paymentMethodId) {
+ return Either.right(null);
+ }
+
+ @Override
+ public Either<PaymentError, List<PaymentMethodInfo>> getPaymentMethods(final String accountKey) {
+ return Either.right(Arrays.<PaymentMethodInfo>asList());
+ }
+
+ @Override
+ public Either<PaymentError, Void> updatePaymentGateway(String accountKey) {
+ return Either.right(null);
+ }
+
+ @Override
+ public Either<PaymentError, Void> updatePaymentProviderAccountExistingContact(Account account) {
+ return Either.right(null);
+ }
+
+ @Override
+ public Either<PaymentError, Void> updatePaymentProviderAccountWithNewContact(Account account) {
+ return Either.right(null);
+ }
+
+}
diff --git a/payment/src/main/java/com/ning/billing/payment/provider/NoOpPaymentProviderPluginModule.java b/payment/src/main/java/com/ning/billing/payment/provider/NoOpPaymentProviderPluginModule.java
new file mode 100644
index 0000000..a403274
--- /dev/null
+++ b/payment/src/main/java/com/ning/billing/payment/provider/NoOpPaymentProviderPluginModule.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2010-2012 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 com.google.inject.AbstractModule;
+import com.google.inject.name.Names;
+
+public class NoOpPaymentProviderPluginModule extends AbstractModule {
+ private final String instanceName;
+
+ public NoOpPaymentProviderPluginModule(String instanceName) {
+ this.instanceName = instanceName;
+ }
+
+ @Override
+ protected void configure() {
+ bind(NoOpPaymentProviderPlugin.class)
+ .annotatedWith(Names.named(instanceName))
+ .toProvider(new NoOpPaymentProviderPluginProvider(instanceName))
+ .asEagerSingleton();
+ }
+}
diff --git a/payment/src/main/java/com/ning/billing/payment/provider/NoOpPaymentProviderPluginProvider.java b/payment/src/main/java/com/ning/billing/payment/provider/NoOpPaymentProviderPluginProvider.java
new file mode 100644
index 0000000..5ba98b7
--- /dev/null
+++ b/payment/src/main/java/com/ning/billing/payment/provider/NoOpPaymentProviderPluginProvider.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2010-2012 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 com.google.inject.Inject;
+import com.google.inject.Provider;
+
+public class NoOpPaymentProviderPluginProvider implements Provider<NoOpPaymentProviderPlugin> {
+ private PaymentProviderPluginRegistry registry;
+ private final String instanceName;
+
+ public NoOpPaymentProviderPluginProvider(String instanceName) {
+ this.instanceName = instanceName;
+ }
+
+ @Inject
+ public void setPaymentProviderPluginRegistry(PaymentProviderPluginRegistry registry) {
+ this.registry = registry;
+ }
+
+ @Override
+ public NoOpPaymentProviderPlugin get() {
+ NoOpPaymentProviderPlugin plugin = new NoOpPaymentProviderPlugin();
+
+ registry.register(plugin, instanceName);
+ return plugin;
+ }
+
+}
diff --git a/payment/src/main/java/com/ning/billing/payment/RetryService.java b/payment/src/main/java/com/ning/billing/payment/RetryService.java
index 49acce3..7f1994c 100644
--- a/payment/src/main/java/com/ning/billing/payment/RetryService.java
+++ b/payment/src/main/java/com/ning/billing/payment/RetryService.java
@@ -53,7 +53,7 @@ public class RetryService implements KillbillService {
public void initialize() throws NotificationQueueAlreadyExists {
retryQueue = notificationQueueService.createNotificationQueue(SERVICE_NAME, QUEUE_NAME, new NotificationQueueHandler() {
@Override
- public void handleReadyNotification(String notificationKey) {
+ public void handleReadyNotification(String notificationKey, DateTime eventDateTime) {
retry(notificationKey);
}
},
diff --git a/payment/src/main/java/com/ning/billing/payment/setup/PaymentConfig.java b/payment/src/main/java/com/ning/billing/payment/setup/PaymentConfig.java
index 6837ec7..0eff9ca 100644
--- a/payment/src/main/java/com/ning/billing/payment/setup/PaymentConfig.java
+++ b/payment/src/main/java/com/ning/billing/payment/setup/PaymentConfig.java
@@ -18,13 +18,12 @@ package com.ning.billing.payment.setup;
import org.skife.config.Config;
import org.skife.config.Default;
-import org.skife.config.DefaultNull;
import com.ning.billing.util.notificationq.NotificationConfig;
public interface PaymentConfig extends NotificationConfig {
@Config("killbill.payment.provider.default")
- @DefaultNull
+ @Default("noop")
public String getDefaultPaymentProvider();
@Config("killbill.payment.dao.claim.time")
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 a8bd47f..abbd8a6 100644
--- a/payment/src/main/resources/com/ning/billing/payment/ddl.sql
+++ b/payment/src/main/resources/com/ning/billing/payment/ddl.sql
@@ -25,7 +25,7 @@ CREATE TABLE payments (
status varchar(20) COLLATE utf8_bin,
reference_id varchar(36) COLLATE utf8_bin,
payment_type varchar(20) COLLATE utf8_bin,
- payment_method_id varchar(20) COLLATE utf8_bin,
+ payment_method_id varchar(36) COLLATE utf8_bin,
payment_method varchar(20) COLLATE utf8_bin,
card_type varchar(20) COLLATE utf8_bin,
card_country varchar(50) COLLATE utf8_bin,