Details
diff --git a/account/src/main/java/com/ning/billing/account/glue/AccountModule.java b/account/src/main/java/com/ning/billing/account/glue/AccountModule.java
index 48cd4f6..23087e9 100644
--- a/account/src/main/java/com/ning/billing/account/glue/AccountModule.java
+++ b/account/src/main/java/com/ning/billing/account/glue/AccountModule.java
@@ -45,7 +45,7 @@ public class AccountModule extends AbstractModule {
private void installAccountService() {
bind(AccountService.class).to(DefaultAccountService.class).asEagerSingleton();
}
-
+
protected void installTestModules() {
install(new ClockModule());
}
@@ -57,6 +57,6 @@ public class AccountModule extends AbstractModule {
installAccountDao();
installAccountService();
installAccountUserApi();
- installTestModules() ;
+ installTestModules();
}
}
diff --git a/account/src/test/java/com/ning/billing/account/glue/AccountModuleWithMocks.java b/account/src/test/java/com/ning/billing/account/glue/AccountModuleWithMocks.java
index 5a2da49..5c7b638 100644
--- a/account/src/test/java/com/ning/billing/account/glue/AccountModuleWithMocks.java
+++ b/account/src/test/java/com/ning/billing/account/glue/AccountModuleWithMocks.java
@@ -26,7 +26,7 @@ public class AccountModuleWithMocks extends AccountModule {
bind(MockAccountDao.class).asEagerSingleton();
bind(AccountDao.class).to(MockAccountDao.class);
}
-
+
@Override
protected void installTestModules() {
install(new MockClockModule());
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 0c8f8c4..8492b9f 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
@@ -35,6 +35,8 @@ public class PaymentAttempt {
private final String paymentId;
private final DateTime invoiceDate;
private final DateTime paymentAttemptDate;
+ private final Integer retryCount;
+ private final DateTime nextRetryDate;
private final DateTime createdDate;
private final DateTime updatedDate;
@@ -46,6 +48,8 @@ public class PaymentAttempt {
DateTime invoiceDate,
DateTime paymentAttemptDate,
String paymentId,
+ Integer retryCount,
+ DateTime nextRetryDate,
DateTime createdDate,
DateTime updatedDate) {
this.paymentAttemptId = paymentAttemptId;
@@ -56,6 +60,8 @@ public class PaymentAttempt {
this.invoiceDate = invoiceDate;
this.paymentAttemptDate = paymentAttemptDate == null ? new DateTime(DateTimeZone.UTC) : paymentAttemptDate;
this.paymentId = paymentId;
+ this.retryCount = retryCount;
+ this.nextRetryDate = nextRetryDate;
this.createdDate = createdDate;
this.updatedDate = updatedDate;
}
@@ -67,20 +73,33 @@ public class PaymentAttempt {
Currency currency,
DateTime invoiceDate,
DateTime paymentAttemptDate,
- String paymentId) {
- this(paymentAttemptId, invoiceId, accountId, amount, currency, invoiceDate, paymentAttemptDate, paymentId, new DateTime(DateTimeZone.UTC), new DateTime(DateTimeZone.UTC));
+ String paymentId,
+ Integer retryCount,
+ DateTime nextRetryDate) {
+ this(paymentAttemptId,
+ invoiceId,
+ accountId,
+ amount,
+ currency,
+ invoiceDate,
+ paymentAttemptDate,
+ paymentId,
+ retryCount,
+ nextRetryDate,
+ new DateTime(DateTimeZone.UTC),
+ new DateTime(DateTimeZone.UTC));
}
public PaymentAttempt(UUID paymentAttemptId, UUID invoiceId, UUID accountId, BigDecimal amount, Currency currency, DateTime invoiceDate, DateTime paymentAttemptDate) {
- this(paymentAttemptId, invoiceId, accountId, amount, currency, invoiceDate, paymentAttemptDate, null);
+ this(paymentAttemptId, invoiceId, accountId, amount, currency, invoiceDate, paymentAttemptDate, null, null, null);
}
public PaymentAttempt(UUID paymentAttemptId, UUID invoiceId, UUID accountId, DateTime invoiceDate, DateTime paymentAttemptDate) {
- this(paymentAttemptId, invoiceId, accountId, null, null, invoiceDate, paymentAttemptDate, null);
+ this(paymentAttemptId, invoiceId, accountId, null, null, invoiceDate, paymentAttemptDate, null, null, null);
}
public PaymentAttempt(UUID paymentAttemptId, Invoice invoice) {
- this(paymentAttemptId, invoice.getId(), invoice.getAccountId(), invoice.getAmountOutstanding(), invoice.getCurrency(), invoice.getInvoiceDate(), null);
+ this(paymentAttemptId, invoice.getId(), invoice.getAccountId(), invoice.getAmountOutstanding(), invoice.getCurrency(), invoice.getInvoiceDate(), null, null, null, null);
}
public DateTime getInvoiceDate() {
@@ -123,9 +142,17 @@ public class PaymentAttempt {
return currency;
}
+ public Integer getRetryCount() {
+ return retryCount;
+ }
+
+ public DateTime getNextRetryDate() {
+ return nextRetryDate;
+ }
+
@Override
public String toString() {
- return "PaymentAttempt [paymentAttemptId=" + paymentAttemptId + ", invoiceId=" + invoiceId + ", amount=" + amount + ", currency=" + currency + ", paymentId=" + paymentId + ", paymentAttemptDate=" + paymentAttemptDate + "]";
+ return "PaymentAttempt [paymentAttemptId=" + paymentAttemptId + ", invoiceId=" + invoiceId + ", accountId=" + accountId + ", amount=" + amount + ", currency=" + currency + ", paymentId=" + paymentId + ", invoiceDate=" + invoiceDate + ", paymentAttemptDate=" + paymentAttemptDate + ", retryCount=" + retryCount + ", nextRetryDate=" + nextRetryDate + ", createdDate=" + createdDate + ", updatedDate=" + updatedDate + "]";
}
public Builder cloner() {
@@ -141,6 +168,8 @@ public class PaymentAttempt {
private DateTime invoiceDate;
private DateTime paymentAttemptDate;
private String paymentId;
+ private Integer retryCount;
+ private DateTime nextRetryDate;
private DateTime createdDate;
private DateTime updatedDate;
@@ -156,6 +185,8 @@ public class PaymentAttempt {
this.invoiceDate = src.invoiceDate;
this.paymentAttemptDate = src.paymentAttemptDate;
this.paymentId = src.paymentId;
+ this.retryCount = src.retryCount;
+ this.nextRetryDate = src.nextRetryDate;
this.createdDate = src.createdDate;
this.updatedDate = src.updatedDate;
}
@@ -210,6 +241,16 @@ public class PaymentAttempt {
return this;
}
+ public Builder setRetryCount(Integer retryCount) {
+ this.retryCount = retryCount;
+ return this;
+ }
+
+ public Builder setNextRetryDate(DateTime nextRetryDate) {
+ this.nextRetryDate = nextRetryDate;
+ return this;
+ }
+
public PaymentAttempt build() {
return new PaymentAttempt(paymentAttemptId,
invoiceId,
@@ -219,6 +260,8 @@ public class PaymentAttempt {
invoiceDate,
paymentAttemptDate,
paymentId,
+ retryCount,
+ nextRetryDate,
createdDate,
updatedDate);
}
@@ -233,7 +276,11 @@ public class PaymentAttempt {
currency,
invoiceDate,
paymentAttemptDate,
- paymentId);
+ paymentId,
+ retryCount,
+ nextRetryDate,
+ createdDate,
+ updatedDate);
}
@Override
@@ -251,6 +298,8 @@ public class PaymentAttempt {
Objects.equal(currency, other.currency) &&
Objects.equal(invoiceDate, other.invoiceDate) &&
Objects.equal(paymentAttemptDate, other.paymentAttemptDate) &&
+ Objects.equal(retryCount, other.retryCount) &&
+ Objects.equal(nextRetryDate, other.nextRetryDate) &&
Objects.equal(paymentId, other.paymentId);
}
}
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 409ee7f..c20fc88 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
@@ -121,6 +121,18 @@ public class PaymentInfo implements EventBusNotification {
return paymentNumber;
}
+ public String getPaymentMethod() {
+ return paymentMethod;
+ }
+
+ public String getCreditCardType() {
+ return creditCardType;
+ }
+
+ public String getCreditCardCountry() {
+ return creditCardCountry;
+ }
+
public String getReferenceId() {
return referenceId;
}
@@ -170,6 +182,8 @@ 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;
@@ -338,7 +352,7 @@ public class PaymentInfo implements EventBusNotification {
@Override
public String toString() {
- return "PaymentInfo [paymentId=" + paymentId + ", amount=" + amount + ", refundAmount=" + refundAmount + ", paymentNumber=" + paymentNumber + ", bankIdentificationNumber=" + bankIdentificationNumber + ", status=" + status + ", type=" + type + ", referenceId=" + referenceId + ", paymentMethodId=" + paymentMethodId + ", paymentMethodType=" + paymentMethod + ", creditCardType=" + creditCardType + ", creditCardCountry=" + creditCardCountry + ", effectiveDate=" + effectiveDate + ", createdDate=" + createdDate + ", updatedDate=" + updatedDate + "]";
+ return "PaymentInfo [paymentId=" + paymentId + ", amount=" + amount + ", refundAmount=" + refundAmount + ", paymentNumber=" + paymentNumber + ", bankIdentificationNumber=" + bankIdentificationNumber + ", status=" + status + ", type=" + type + ", referenceId=" + referenceId + ", paymentMethodId=" + paymentMethodId + ", paymentMethod=" + paymentMethod + ", creditCardType=" + creditCardType + ", creditCardCountry=" + creditCardCountry + ", effectiveDate=" + effectiveDate + ", createdDate=" + createdDate + ", updatedDate=" + updatedDate + "]";
}
}
diff --git a/entitlement/src/test/java/com/ning/billing/entitlement/glue/MockEngineModule.java b/entitlement/src/test/java/com/ning/billing/entitlement/glue/MockEngineModule.java
index 0f6fca3..a00183b 100644
--- a/entitlement/src/test/java/com/ning/billing/entitlement/glue/MockEngineModule.java
+++ b/entitlement/src/test/java/com/ning/billing/entitlement/glue/MockEngineModule.java
@@ -27,9 +27,9 @@ public class MockEngineModule extends EntitlementModule {
install(new EventBusModule());
install(new CatalogModule());
install(new AccountModuleWithMocks());
- install (new MockClockModule());
+ install(new MockClockModule());
}
-
+
@Override
protected void configure() {
super.configure();
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 2a9d7f2..5cd87d7 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
@@ -84,6 +84,8 @@ public interface PaymentSqlDao extends Transactional<PaymentSqlDao>, CloseMe, Tr
stmt.bind("invoice_dt", getDate(paymentAttempt.getInvoiceDate()));
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("created_dt", getDate(paymentAttempt.getCreatedDate()));
stmt.bind("updated_dt", getDate(paymentAttempt.getUpdatedDate()));
}
@@ -107,10 +109,23 @@ public interface PaymentSqlDao extends Transactional<PaymentSqlDao>, CloseMe, Tr
DateTime invoiceDate = getDate(rs, "invoice_dt");
DateTime paymentAttemptDate = getDate(rs, "payment_attempt_dt");
String paymentId = rs.getString("payment_id");
+ Integer retryCount = rs.getInt("retry_count");
+ DateTime nextRetryDate = getDate(rs, "next_retry_dt");
DateTime createdDate = getDate(rs, "created_dt");
DateTime updatedDate = getDate(rs, "updated_dt");
- return new PaymentAttempt(paymentAttemptId, invoiceId, accountId, amount, currency, invoiceDate, paymentAttemptDate, paymentId, createdDate, updatedDate);
+ return new PaymentAttempt(paymentAttemptId,
+ invoiceId,
+ accountId,
+ amount,
+ currency,
+ invoiceDate,
+ paymentAttemptDate,
+ paymentId,
+ retryCount,
+ nextRetryDate,
+ createdDate,
+ updatedDate);
}
}
diff --git a/payment/src/main/java/com/ning/billing/payment/PaymentAttempt.java b/payment/src/main/java/com/ning/billing/payment/PaymentAttempt.java
index aa0ccc5..62fce18 100644
--- a/payment/src/main/java/com/ning/billing/payment/PaymentAttempt.java
+++ b/payment/src/main/java/com/ning/billing/payment/PaymentAttempt.java
@@ -30,13 +30,21 @@ public class PaymentAttempt {
private final UUID invoiceId;
private final BigDecimal paymentAttemptAmount;
private final DateTime paymentAttemptDate;
+ private final Integer retryCount;
+ private final DateTime nextRetryDate;
public PaymentAttempt(UUID paymentAttemptId, Invoice invoice) {
+ this(paymentAttemptId, invoice, null, null);
+ }
+
+ public PaymentAttempt(UUID paymentAttemptId, Invoice invoice, Integer retryCount, DateTime nextRetryDate) {
this.paymentAttemptId = paymentAttemptId;
this.accountId = invoice.getAccountId();
this.invoiceId = invoice.getId();
this.paymentAttemptAmount = invoice.getAmountOutstanding();
this.paymentAttemptDate = new DateTime(DateTimeZone.UTC);
+ this.retryCount = retryCount;
+ this.nextRetryDate = nextRetryDate;
}
public UUID getPaymentAttemptId() {
@@ -55,13 +63,21 @@ public class PaymentAttempt {
return paymentAttemptAmount;
}
- public DateTime getPaymentAttemptDate() {
- return paymentAttemptDate;
+ public DateTime getPaymentAttemptDate() {
+ return paymentAttemptDate;
+ }
+
+ public Integer getRetryCount() {
+ return retryCount;
}
- @Override
- public String toString() {
- return "PaymentAttempt [paymentAttemptId=" + paymentAttemptId + ", accountId=" + accountId + ", invoiceId=" + invoiceId + ", paymentAttemptAmount=" + paymentAttemptAmount + ", paymentAttemptDate=" + paymentAttemptDate + "]";
- }
+ public DateTime getNextRetryDate() {
+ return nextRetryDate;
+ }
+
+ @Override
+ public String toString() {
+ return "PaymentAttempt [paymentAttemptId=" + paymentAttemptId + ", accountId=" + accountId + ", invoiceId=" + invoiceId + ", paymentAttemptAmount=" + paymentAttemptAmount + ", paymentAttemptDate=" + paymentAttemptDate + ", retryCount=" + retryCount + ", nextRetryDate=" + nextRetryDate + "]";
+ }
}
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 4582d6e..a62c366 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
@@ -9,6 +9,8 @@ paymentAttemptFields(prefix) ::= <<
<prefix>payment_id,
<prefix>payment_attempt_dt,
<prefix>invoice_dt,
+ <prefix>retry_count,
+ <prefix>next_retry_dt,
<prefix>created_dt,
<prefix>updated_dt
>>
@@ -32,7 +34,7 @@ paymentInfoFields(prefix) ::= <<
insertPaymentAttempt() ::= <<
INSERT INTO payment_attempts (<paymentAttemptFields()>)
- VALUES (:payment_attempt_id, :invoice_id, :account_id, :amount, :currency, :payment_id, :payment_attempt_dt, :invoice_dt, :created_dt, :updated_dt);
+ VALUES (:payment_attempt_id, :invoice_id, :account_id, :amount, :currency, :payment_id, :payment_attempt_dt, :invoice_dt, :retry_count, :next_retry_dt, :created_dt, :updated_dt);
>>
getPaymentAttemptForPaymentId() ::= <<
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 e4e3501..a8bd47f 100644
--- a/payment/src/main/resources/com/ning/billing/payment/ddl.sql
+++ b/payment/src/main/resources/com/ning/billing/payment/ddl.sql
@@ -7,6 +7,8 @@ CREATE TABLE payment_attempts (
currency char(3),
payment_attempt_dt datetime NOT NULL,
payment_id varchar(36) COLLATE utf8_bin,
+ retry_count tinyint,
+ next_retry_dt datetime,
invoice_dt datetime NOT NULL,
created_dt datetime NOT NULL,
updated_dt datetime NOT NULL,