killbill-aplcache

Payment retries work

2/8/2012 5:30:24 AM

Details

diff --git a/api/src/main/java/com/ning/billing/payment/api/PaymentAttempt.java b/api/src/main/java/com/ning/billing/payment/api/PaymentAttempt.java
index 8492b9f..9d38f76 100644
--- a/api/src/main/java/com/ning/billing/payment/api/PaymentAttempt.java
+++ b/api/src/main/java/com/ning/billing/payment/api/PaymentAttempt.java
@@ -62,8 +62,8 @@ public class PaymentAttempt {
         this.paymentId = paymentId;
         this.retryCount = retryCount;
         this.nextRetryDate = nextRetryDate;
-        this.createdDate = createdDate;
-        this.updatedDate = updatedDate;
+        this.createdDate = createdDate == null ? new DateTime(DateTimeZone.UTC) : createdDate;
+        this.updatedDate = updatedDate == null ? new DateTime(DateTimeZone.UTC) : updatedDate;
     }
 
     public PaymentAttempt(UUID paymentAttemptId,
@@ -86,8 +86,8 @@ public class PaymentAttempt {
              paymentId,
              retryCount,
              nextRetryDate,
-             new DateTime(DateTimeZone.UTC),
-             new DateTime(DateTimeZone.UTC));
+             null,
+             null);
     }
 
     public PaymentAttempt(UUID paymentAttemptId, UUID invoiceId, UUID accountId, BigDecimal amount, Currency currency, DateTime invoiceDate, DateTime paymentAttemptDate) {
diff --git a/api/src/main/java/com/ning/billing/payment/api/PaymentInfo.java b/api/src/main/java/com/ning/billing/payment/api/PaymentInfo.java
index c20fc88..d187b1e 100644
--- a/api/src/main/java/com/ning/billing/payment/api/PaymentInfo.java
+++ b/api/src/main/java/com/ning/billing/payment/api/PaymentInfo.java
@@ -21,6 +21,7 @@ import java.math.BigDecimal;
 import org.codehaus.jackson.annotate.JsonCreator;
 import org.codehaus.jackson.annotate.JsonProperty;
 import org.joda.time.DateTime;
+import org.joda.time.DateTimeZone;
 
 import com.google.common.base.Objects;
 import com.ning.billing.util.eventbus.EventBusNotification;
@@ -62,7 +63,6 @@ public class PaymentInfo implements EventBusNotification {
         this.amount = amount;
         this.refundAmount = refundAmount;
         this.bankIdentificationNumber = bankIdentificationNumber;
-        this.effectiveDate = effectiveDate;
         this.paymentNumber = paymentNumber;
         this.status = status;
         this.type = type;
@@ -71,26 +71,27 @@ public class PaymentInfo implements EventBusNotification {
         this.paymentMethod = paymentMethod;
         this.creditCardType = creditCardType;
         this.creditCardCountry = creditCardCountry;
-        this.createdDate = createdDate;
-        this.updatedDate = updatedDate;
+        this.effectiveDate = effectiveDate;
+        this.createdDate = createdDate == null ? new DateTime(DateTimeZone.UTC) : createdDate;
+        this.updatedDate = updatedDate == null ? new DateTime(DateTimeZone.UTC) : updatedDate;
     }
 
     public PaymentInfo(PaymentInfo src) {
-        this.paymentId = src.paymentId;
-        this.amount = src.amount;
-        this.refundAmount = src.refundAmount;
-        this.paymentNumber = src.paymentNumber;
-        this.bankIdentificationNumber = src.bankIdentificationNumber;
-        this.status = src.status;
-        this.type = src.type;
-        this.referenceId = src.referenceId;
-        this.paymentMethodId = src.paymentMethodId;
-        this.paymentMethod = src.paymentMethod;
-        this.creditCardType = src.creditCardType;
-        this.creditCardCountry = src.creditCardCountry;
-        this.effectiveDate = src.effectiveDate;
-        this.createdDate = src.createdDate;
-        this.updatedDate = src.updatedDate;
+        this(src.paymentId,
+             src.amount,
+             src.refundAmount,
+             src.bankIdentificationNumber,
+             src.paymentNumber,
+             src.status,
+             src.type,
+             src.referenceId,
+             src.paymentMethodId,
+             src.paymentMethod,
+             src.creditCardType,
+             src.creditCardCountry,
+             src.effectiveDate,
+             src.createdDate,
+             src.updatedDate);
     }
 
     public Builder cloner() {
@@ -182,8 +183,6 @@ public class PaymentInfo implements EventBusNotification {
         private String paymentMethod;
         private String creditCardType;
         private String creditCardCountry;
-        private Integer retryCount;
-        private DateTime nextRetryDate;
         private DateTime effectiveDate;
         private DateTime createdDate;
         private DateTime updatedDate;
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 5cd87d7..8e08404 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
@@ -85,7 +85,7 @@ public interface PaymentSqlDao extends Transactional<PaymentSqlDao>, CloseMe, Tr
             stmt.bind("payment_attempt_dt", getDate(paymentAttempt.getPaymentAttemptDate()));
             stmt.bind("payment_id", paymentAttempt.getPaymentId());
             stmt.bind("retry_count", paymentAttempt.getRetryCount());
-            stmt.bind("next_retry_date", getDate(paymentAttempt.getNextRetryDate()));
+            stmt.bind("next_retry_dt", getDate(paymentAttempt.getNextRetryDate()));
             stmt.bind("created_dt", getDate(paymentAttempt.getCreatedDate()));
             stmt.bind("updated_dt", getDate(paymentAttempt.getUpdatedDate()));
         }