killbill-uncached
Changes
analytics/src/main/java/com/ning/billing/analytics/dao/BusinessInvoicePaymentMapper.java 35(+18 -17)
analytics/src/main/resources/com/ning/billing/analytics/dao/BusinessInvoicePaymentSqlDao.sql.stg 12(+8 -4)
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 a5ad78f..4889892 100644
--- a/analytics/src/main/java/com/ning/billing/analytics/AnalyticsListener.java
+++ b/analytics/src/main/java/com/ning/billing/analytics/AnalyticsListener.java
@@ -109,7 +109,8 @@ public class AnalyticsListener {
public void handlePaymentInfo(final PaymentInfoEvent paymentInfo) {
bipRecorder.invoicePaymentPosted(paymentInfo.getAccountId(),
paymentInfo.getPaymentId(),
- paymentInfo.getExtPaymentRefId(),
+ paymentInfo.getExtFirstPaymentRefId(),
+ paymentInfo.getExtSecondPaymentRefId(),
paymentInfo.getStatus().toString());
}
@@ -118,6 +119,7 @@ public class AnalyticsListener {
bipRecorder.invoicePaymentPosted(paymentError.getAccountId(),
paymentError.getPaymentId(),
null,
+ null,
paymentError.getMessage());
}
diff --git a/analytics/src/main/java/com/ning/billing/analytics/BusinessInvoicePaymentRecorder.java b/analytics/src/main/java/com/ning/billing/analytics/BusinessInvoicePaymentRecorder.java
index 1d7c3d0..2548ac8 100644
--- a/analytics/src/main/java/com/ning/billing/analytics/BusinessInvoicePaymentRecorder.java
+++ b/analytics/src/main/java/com/ning/billing/analytics/BusinessInvoicePaymentRecorder.java
@@ -65,7 +65,7 @@ public class BusinessInvoicePaymentRecorder {
this.accountRecorder = accountRecorder;
}
- public void invoicePaymentPosted(final UUID accountId, final UUID paymentId, @Nullable final String extPaymentRefId, final String message) {
+ public void invoicePaymentPosted(final UUID accountId, final UUID paymentId, @Nullable final String extFirstPaymentRefId, @Nullable final String extSecondPaymentRefId, final String message) {
final Account account;
try {
account = accountApi.getAccountById(accountId);
@@ -92,11 +92,11 @@ public class BusinessInvoicePaymentRecorder {
return;
}
- createPayment(account, invoicePayment, payment, paymentMethod, extPaymentRefId, message);
+ createPayment(account, invoicePayment, payment, paymentMethod, extFirstPaymentRefId, extSecondPaymentRefId, message);
}
private void createPayment(final Account account, @Nullable final InvoicePayment invoicePayment, final Payment payment,
- final PaymentMethod paymentMethod, final String extPaymentRefId, final String message) {
+ final PaymentMethod paymentMethod, final String extFirstPaymentRefId, final String extSecondPaymentRefId, final String message) {
final PaymentMethodPlugin pluginDetail = paymentMethod.getPluginDetail();
// TODO - make it generic
final String cardCountry = pluginDetail != null ? pluginDetail.getValueString("country") : null;
@@ -125,7 +125,8 @@ public class BusinessInvoicePaymentRecorder {
final BusinessInvoicePayment businessInvoicePayment = new BusinessInvoicePayment(
account.getExternalKey(),
payment.getAmount(),
- extPaymentRefId,
+ extFirstPaymentRefId,
+ extSecondPaymentRefId,
cardCountry,
cardType,
clock.getUTCNow(),
diff --git a/analytics/src/main/java/com/ning/billing/analytics/dao/BusinessInvoicePaymentBinder.java b/analytics/src/main/java/com/ning/billing/analytics/dao/BusinessInvoicePaymentBinder.java
index c55111c..b67e0ea 100644
--- a/analytics/src/main/java/com/ning/billing/analytics/dao/BusinessInvoicePaymentBinder.java
+++ b/analytics/src/main/java/com/ning/billing/analytics/dao/BusinessInvoicePaymentBinder.java
@@ -39,8 +39,10 @@ import com.ning.billing.analytics.utils.Rounder;
@Target({ElementType.PARAMETER})
public @interface BusinessInvoicePaymentBinder {
public static class BipBinderFactory implements BinderFactory {
+ @Override
public Binder build(final Annotation annotation) {
return new Binder<BusinessInvoicePaymentBinder, BusinessInvoicePayment>() {
+ @Override
public void bind(final SQLStatement q, final BusinessInvoicePaymentBinder bind, final BusinessInvoicePayment invoicePayment) {
q.bind("payment_id", invoicePayment.getPaymentId().toString());
@@ -57,7 +59,8 @@ public @interface BusinessInvoicePaymentBinder {
q.bind("updated_date", dateTimeNow.getMillis());
}
- q.bind("ext_payment_ref_id", invoicePayment.getExtPaymentRefId());
+ q.bind("ext_first_payment_ref_id", invoicePayment.getExtFirstPaymentRefId());
+ q.bind("ext_second_payment_ref_id", invoicePayment.getExtSecondPaymentRefId());
q.bind("account_key", invoicePayment.getAccountKey());
q.bind("invoice_id", invoicePayment.getInvoiceId().toString());
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 de11209..e9dee70 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
@@ -35,22 +35,23 @@ public class BusinessInvoicePaymentMapper implements ResultSetMapper<BusinessInv
final UUID paymentId = UUID.fromString(r.getString(1));
final DateTime createdDate = new DateTime(r.getLong(2), DateTimeZone.UTC);
final DateTime updatedDate = new DateTime(r.getLong(3), DateTimeZone.UTC);
- final String extPaymentRefId = r.getString(4);
- final String accountKey = r.getString(5);
- final UUID invoiceId = UUID.fromString(r.getString(6));
- final DateTime effectiveDate = new DateTime(r.getLong(7), DateTimeZone.UTC);
- final BigDecimal amount = BigDecimal.valueOf(r.getDouble(8));
- final Currency currency = Currency.valueOf(r.getString(9));
- final String paymentError = r.getString(10);
- final String processingStatus = r.getString(11);
- final BigDecimal requestedAmount = BigDecimal.valueOf(r.getDouble(12));
- final String pluginName = r.getString(13);
- final String paymentType = r.getString(14);
- final String paymentMethod = r.getString(15);
- final String cardType = r.getString(16);
- final String cardCountry = r.getString(17);
- final String invoicePaymentType = r.getString(18);
- final String linkedInvoicePaymentIdString = r.getString(19);
+ final String extFirstPaymentRefId = r.getString(4);
+ final String extSecondPaymentRefId = r.getString(5);
+ final String accountKey = r.getString(6);
+ final UUID invoiceId = UUID.fromString(r.getString(7));
+ final DateTime effectiveDate = new DateTime(r.getLong(8), DateTimeZone.UTC);
+ final BigDecimal amount = BigDecimal.valueOf(r.getDouble(9));
+ final Currency currency = Currency.valueOf(r.getString(10));
+ final String paymentError = r.getString(11);
+ final String processingStatus = r.getString(12);
+ final BigDecimal requestedAmount = BigDecimal.valueOf(r.getDouble(13));
+ final String pluginName = r.getString(14);
+ final String paymentType = r.getString(15);
+ final String paymentMethod = r.getString(16);
+ final String cardType = r.getString(17);
+ final String cardCountry = r.getString(18);
+ final String invoicePaymentType = r.getString(19);
+ final String linkedInvoicePaymentIdString = r.getString(20);
final UUID linkedInvoicePaymentId;
if (linkedInvoicePaymentIdString != null) {
@@ -59,7 +60,7 @@ public class BusinessInvoicePaymentMapper implements ResultSetMapper<BusinessInv
linkedInvoicePaymentId = null;
}
- return new BusinessInvoicePayment(accountKey, amount, extPaymentRefId, cardCountry, cardType, createdDate, currency,
+ return new BusinessInvoicePayment(accountKey, amount, extFirstPaymentRefId, extSecondPaymentRefId, 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/BusinessInvoicePayment.java b/analytics/src/main/java/com/ning/billing/analytics/model/BusinessInvoicePayment.java
index 73a1f8d..019816b 100644
--- a/analytics/src/main/java/com/ning/billing/analytics/model/BusinessInvoicePayment.java
+++ b/analytics/src/main/java/com/ning/billing/analytics/model/BusinessInvoicePayment.java
@@ -28,7 +28,8 @@ import com.ning.billing.catalog.api.Currency;
public class BusinessInvoicePayment {
private final UUID paymentId;
private final DateTime createdDate;
- private final String extPaymentRefId;
+ private final String extFirstPaymentRefId;
+ private final String extSecondPaymentRefId;
private final DateTime updatedDate;
private final String accountKey;
private final UUID invoiceId;
@@ -46,7 +47,7 @@ public class BusinessInvoicePayment {
private final String invoicePaymentType;
private final UUID linkedInvoicePaymentId;
- public BusinessInvoicePayment(final String accountKey, final BigDecimal amount, final String extPaymentRefId,
+ public BusinessInvoicePayment(final String accountKey, final BigDecimal amount, final String extFirstPaymentRefId, final String extSecondPaymentRefId,
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,
@@ -55,7 +56,8 @@ public class BusinessInvoicePayment {
@Nullable final UUID linkedInvoicePaymentId) {
this.accountKey = accountKey;
this.amount = amount;
- this.extPaymentRefId = extPaymentRefId;
+ this.extFirstPaymentRefId = extFirstPaymentRefId;
+ this.extSecondPaymentRefId = extSecondPaymentRefId;
this.cardCountry = cardCountry;
this.cardType = cardType;
this.createdDate = createdDate;
@@ -74,8 +76,12 @@ public class BusinessInvoicePayment {
this.linkedInvoicePaymentId = linkedInvoicePaymentId;
}
- public String getExtPaymentRefId() {
- return extPaymentRefId;
+ public String getExtFirstPaymentRefId() {
+ return extFirstPaymentRefId;
+ }
+
+ public String getExtSecondPaymentRefId() {
+ return extSecondPaymentRefId;
}
public DateTime getCreatedDate() {
@@ -157,7 +163,7 @@ public class BusinessInvoicePayment {
sb.append("{accountKey='").append(accountKey).append('\'');
sb.append(", paymentId=").append(paymentId);
sb.append(", createdDate=").append(createdDate);
- sb.append(", extPaymentRefId=").append(extPaymentRefId);
+ sb.append(", extFirstPaymentRefId=").append(extFirstPaymentRefId);
sb.append(", updatedDate=").append(updatedDate);
sb.append(", invoiceId=").append(invoiceId);
sb.append(", effectiveDate=").append(effectiveDate);
@@ -194,7 +200,7 @@ public class BusinessInvoicePayment {
if (amount != null ? Rounder.round(amount) != Rounder.round(that.amount) : that.amount != null) {
return false;
}
- if (extPaymentRefId != null ? !extPaymentRefId.equals(that.extPaymentRefId) : that.extPaymentRefId != null) {
+ if (extFirstPaymentRefId != null ? !extFirstPaymentRefId.equals(that.extFirstPaymentRefId) : that.extFirstPaymentRefId != null) {
return false;
}
if (cardCountry != null ? !cardCountry.equals(that.cardCountry) : that.cardCountry != null) {
@@ -253,7 +259,7 @@ public class BusinessInvoicePayment {
public int hashCode() {
int result = paymentId != null ? paymentId.hashCode() : 0;
result = 31 * result + (createdDate != null ? createdDate.hashCode() : 0);
- result = 31 * result + (extPaymentRefId != null ? extPaymentRefId.hashCode() : 0);
+ result = 31 * result + (extFirstPaymentRefId != null ? extFirstPaymentRefId.hashCode() : 0);
result = 31 * result + (updatedDate != null ? updatedDate.hashCode() : 0);
result = 31 * result + (accountKey != null ? accountKey.hashCode() : 0);
result = 31 * result + (invoiceId != null ? invoiceId.hashCode() : 0);
diff --git a/analytics/src/main/resources/com/ning/billing/analytics/dao/BusinessInvoicePaymentSqlDao.sql.stg b/analytics/src/main/resources/com/ning/billing/analytics/dao/BusinessInvoicePaymentSqlDao.sql.stg
index a71f3d5..54f8d22 100644
--- a/analytics/src/main/resources/com/ning/billing/analytics/dao/BusinessInvoicePaymentSqlDao.sql.stg
+++ b/analytics/src/main/resources/com/ning/billing/analytics/dao/BusinessInvoicePaymentSqlDao.sql.stg
@@ -5,7 +5,8 @@ select
payment_id
, created_date
, updated_date
-, ext_payment_ref_id
+, ext_first_payment_ref_id
+, ext_second_payment_ref_id
, account_key
, invoice_id
, effective_date
@@ -32,7 +33,8 @@ select
payment_id
, created_date
, updated_date
-, ext_payment_ref_id
+, ext_first_payment_ref_id
+, ext_second_payment_ref_id
, account_key
, invoice_id
, effective_date
@@ -59,7 +61,8 @@ insert into bip (
payment_id
, created_date
, updated_date
-, ext_payment_ref_id
+, ext_first_payment_ref_id
+, ext_second_payment_ref_id
, account_key
, invoice_id
, effective_date
@@ -79,7 +82,8 @@ insert into bip (
:payment_id
, :created_date
, :updated_date
-, :ext_payment_ref_id
+, :ext_first_payment_ref_id
+, :ext_second_payment_ref_id
, :account_key
, :invoice_id
, :effective_date
diff --git a/analytics/src/main/resources/com/ning/billing/analytics/ddl.sql b/analytics/src/main/resources/com/ning/billing/analytics/ddl.sql
index 1bfa1cb..e70e99d 100644
--- a/analytics/src/main/resources/com/ning/billing/analytics/ddl.sql
+++ b/analytics/src/main/resources/com/ning/billing/analytics/ddl.sql
@@ -114,7 +114,8 @@ create table bip (
, payment_id char(36) not null
, created_date bigint not null
, updated_date bigint not null
-, ext_payment_ref_id varchar(255) default null
+, ext_first_payment_ref_id varchar(255) default null
+, ext_second_payment_ref_id varchar(255) default null
, account_key varchar(50) not null comment 'Account external key'
, invoice_id char(36) not null
, effective_date bigint default null
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 d41ffbe..3740a57 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
@@ -236,7 +236,7 @@ public class TestAnalyticsService extends AnalyticsTestSuiteWithEmbeddedDB {
invoiceCreationNotification = new DefaultInvoiceCreationEvent(invoice.getId(), account.getId(),
INVOICE_AMOUNT, ACCOUNT_CURRENCY, null);
- paymentInfoNotification = new DefaultPaymentInfoEvent(account.getId(), invoices.get(0).getId(), null, invoices.get(0).getBalance(), -1, PaymentStatus.UNKNOWN, null, null, clock.getUTCNow());
+ paymentInfoNotification = new DefaultPaymentInfoEvent(account.getId(), invoices.get(0).getId(), null, invoices.get(0).getBalance(), -1, PaymentStatus.UNKNOWN, null, null, null, clock.getUTCNow());
//STEPH talk to Pierre
/*
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 7aed3b6..302881a 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
@@ -41,9 +41,10 @@ public class TestBusinessInvoicePaymentSqlDao extends AnalyticsTestSuiteWithEmbe
@Test(groups = "slow")
public void testCRUD() throws Exception {
- final String extPaymentRefId = UUID.randomUUID().toString();
+ final String extFirstPaymentRefId = UUID.randomUUID().toString();
+ final String extSecondPaymentRefId = UUID.randomUUID().toString();
final String accountKey = UUID.randomUUID().toString();
- final BusinessInvoicePayment invoicePayment = createInvoicePayment(extPaymentRefId, accountKey);
+ final BusinessInvoicePayment invoicePayment = createInvoicePayment(extFirstPaymentRefId, extSecondPaymentRefId, accountKey);
// Verify initial state
Assert.assertNull(invoicePaymentSqlDao.getInvoicePayment(invoicePayment.getPaymentId().toString()));
@@ -65,12 +66,14 @@ public class TestBusinessInvoicePaymentSqlDao extends AnalyticsTestSuiteWithEmbe
@Test(groups = "slow")
public void testSegmentation() throws Exception {
- final String extPaymentRefId1 = UUID.randomUUID().toString();
+ final String extFirstPaymentRefId1 = UUID.randomUUID().toString();
+ final String extSecondPaymentRefId1 = UUID.randomUUID().toString();
final String accountKey1 = UUID.randomUUID().toString();
- final BusinessInvoicePayment invoicePayment1 = createInvoicePayment(extPaymentRefId1, accountKey1);
- final String extPaymentRefId2 = UUID.randomUUID().toString();
+ final BusinessInvoicePayment invoicePayment1 = createInvoicePayment(extFirstPaymentRefId1, extSecondPaymentRefId1, accountKey1);
+ final String extFirstPaymentRefId2 = UUID.randomUUID().toString();
+ final String extSecondPaymentRefId2 = UUID.randomUUID().toString();
final String accountKey2 = UUID.randomUUID().toString();
- final BusinessInvoicePayment invoicePayment2 = createInvoicePayment(extPaymentRefId2, accountKey2);
+ final BusinessInvoicePayment invoicePayment2 = createInvoicePayment(extFirstPaymentRefId2, extSecondPaymentRefId2, accountKey2);
// Create both invoice payments
Assert.assertEquals(invoicePaymentSqlDao.createInvoicePayment(invoicePayment1), 1);
@@ -100,7 +103,7 @@ public class TestBusinessInvoicePaymentSqlDao extends AnalyticsTestSuiteWithEmbe
}
}
- private BusinessInvoicePayment createInvoicePayment(final String extPaymentRefId, final String accountKey) {
+ private BusinessInvoicePayment createInvoicePayment(final String extFirstPaymentRefId, final String extSecondPaymentRefId, 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);
@@ -119,7 +122,7 @@ public class TestBusinessInvoicePaymentSqlDao extends AnalyticsTestSuiteWithEmbe
final String invoicePaymentType = UUID.randomUUID().toString().substring(0, 10);
final UUID linkedInvoicePaymentId = UUID.randomUUID();
- return new BusinessInvoicePayment(accountKey, amount, extPaymentRefId,
+ return new BusinessInvoicePayment(accountKey, amount, extFirstPaymentRefId, extSecondPaymentRefId,
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 ce31865..97c3028 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
@@ -32,7 +32,8 @@ public class TestBusinessInvoicePayment extends AnalyticsTestSuite {
public void testEquals() throws Exception {
final String accountKey = UUID.randomUUID().toString();
final BigDecimal amount = BigDecimal.ONE;
- final String extPaymentRefId = UUID.randomUUID().toString();
+ 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);
@@ -49,7 +50,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 BusinessInvoicePayment invoicePayment = new BusinessInvoicePayment(accountKey, amount, extPaymentRefId,
+ final BusinessInvoicePayment invoicePayment = new BusinessInvoicePayment(accountKey, amount, extFirstPaymentRefId, extSecondPaymentRefId,
cardCountry, cardType, createdDate,
currency, effectiveDate, invoiceId,
paymentError, paymentId, paymentMethod,
@@ -61,7 +62,8 @@ public class TestBusinessInvoicePayment extends AnalyticsTestSuite {
Assert.assertTrue(invoicePayment.equals(invoicePayment));
Assert.assertEquals(invoicePayment.getAccountKey(), accountKey);
Assert.assertEquals(invoicePayment.getAmount(), amount);
- Assert.assertEquals(invoicePayment.getExtPaymentRefId(), extPaymentRefId);
+ 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);
@@ -79,7 +81,7 @@ public class TestBusinessInvoicePayment extends AnalyticsTestSuite {
Assert.assertEquals(invoicePayment.getInvoicePaymentType(), invoicePaymentType);
Assert.assertEquals(invoicePayment.getLinkedInvoicePaymentId(), linkedInvoicePaymentId);
- final BusinessInvoicePayment otherInvoicePayment = new BusinessInvoicePayment(null, null, extPaymentRefId, null, null, createdDate,
+ final BusinessInvoicePayment otherInvoicePayment = new BusinessInvoicePayment(null, null, extFirstPaymentRefId, extSecondPaymentRefId, 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/Payment.java b/api/src/main/java/com/ning/billing/payment/api/Payment.java
index e64d92e..a7a483b 100644
--- a/api/src/main/java/com/ning/billing/payment/api/Payment.java
+++ b/api/src/main/java/com/ning/billing/payment/api/Payment.java
@@ -47,13 +47,19 @@ public interface Payment {
public List<PaymentAttempt> getAttempts();
+ public String getExtFirstPaymentIdRef();
+
+ public String getExtSecondPaymentIdRef();
+
public interface PaymentAttempt {
public UUID getId();
public DateTime getEffectiveDate();
- public String getErrorMsg();
+ public String getGatewayErrorCode();
+
+ public String getGatewayErrorMsg();
public PaymentStatus getPaymentStatus();
}
diff --git a/api/src/main/java/com/ning/billing/payment/api/PaymentInfoEvent.java b/api/src/main/java/com/ning/billing/payment/api/PaymentInfoEvent.java
index 8bbae11..2b11f4f 100644
--- a/api/src/main/java/com/ning/billing/payment/api/PaymentInfoEvent.java
+++ b/api/src/main/java/com/ning/billing/payment/api/PaymentInfoEvent.java
@@ -39,5 +39,7 @@ public interface PaymentInfoEvent extends Entity, BusEvent {
public PaymentStatus getStatus();
- public String getExtPaymentRefId();
+ public String getExtFirstPaymentRefId();
+
+ public String getExtSecondPaymentRefId();
}
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 eeb356a..71e0ba7 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
@@ -39,5 +39,7 @@ public interface PaymentInfoPlugin {
public String getGatewayErrorCode();
- public String getExternalReferenceId();
+ public String getExtFirstReferenceId();
+
+ public String getExtSecondReferenceId();
}
diff --git a/beatrix/src/test/java/com/ning/billing/beatrix/integration/TestAnalytics.java b/beatrix/src/test/java/com/ning/billing/beatrix/integration/TestAnalytics.java
index 8a20602..cad4fd1 100644
--- a/beatrix/src/test/java/com/ning/billing/beatrix/integration/TestAnalytics.java
+++ b/beatrix/src/test/java/com/ning/billing/beatrix/integration/TestAnalytics.java
@@ -227,7 +227,8 @@ public class TestAnalytics extends TestIntegrationBase {
Assert.assertEquals(analyticsUserApi.getInvoicePaymentsForAccount(account.getExternalKey()).get(0).getAccountKey(), account.getExternalKey());
Assert.assertTrue(analyticsUserApi.getInvoicePaymentsForAccount(account.getExternalKey()).get(0).getAmount().compareTo(BigDecimal.ZERO) > 0);
Assert.assertTrue(analyticsUserApi.getInvoicePaymentsForAccount(account.getExternalKey()).get(0).getRequestedAmount().compareTo(BigDecimal.ZERO) > 0);
- Assert.assertNull(analyticsUserApi.getInvoicePaymentsForAccount(account.getExternalKey()).get(0).getExtPaymentRefId());
+ Assert.assertNull(analyticsUserApi.getInvoicePaymentsForAccount(account.getExternalKey()).get(0).getExtFirstPaymentRefId());
+ Assert.assertNull(analyticsUserApi.getInvoicePaymentsForAccount(account.getExternalKey()).get(0).getExtSecondPaymentRefId());
Assert.assertEquals(analyticsUserApi.getInvoicePaymentsForAccount(account.getExternalKey()).get(0).getProcessingStatus(), PaymentStatus.PAYMENT_FAILURE.toString());
Assert.assertEquals(analyticsUserApi.getInvoicePaymentsForAccount(account.getExternalKey()).get(0).getPluginName(), BeatrixModule.PLUGIN_NAME);
diff --git a/jaxrs/src/main/java/com/ning/billing/jaxrs/json/AccountTimelineJson.java b/jaxrs/src/main/java/com/ning/billing/jaxrs/json/AccountTimelineJson.java
index 41979d0..225bcd8 100644
--- a/jaxrs/src/main/java/com/ning/billing/jaxrs/json/AccountTimelineJson.java
+++ b/jaxrs/src/main/java/com/ning/billing/jaxrs/json/AccountTimelineJson.java
@@ -131,12 +131,16 @@ public class AccountTimelineJson {
chargebacks.add(new ChargebackJson(chargeback));
}
+ final int paymentAttemptSize = payment.getAttempts().size();
final String status = payment.getPaymentStatus().toString();
this.payments.add(new PaymentJsonWithBundleKeys(payment.getAmount(), payment.getPaidAmount(), account.getId().toString(),
payment.getInvoiceId().toString(), payment.getId().toString(),
payment.getPaymentMethodId().toString(),
payment.getEffectiveDate(), payment.getEffectiveDate(),
- payment.getAttempts().size(), payment.getCurrency().toString(), status,
+ paymentAttemptSize, payment.getCurrency().toString(), status,
+ payment.getAttempts().get(paymentAttemptSize - 1).getGatewayErrorCode(),
+ payment.getAttempts().get(paymentAttemptSize - 1).getGatewayErrorMsg(),
+ payment.getExtFirstPaymentIdRef(), payment.getExtSecondPaymentIdRef(),
getBundleExternalKey(payment.getInvoiceId(), invoices, bundles),
refunds, chargebacks));
}
diff --git a/jaxrs/src/main/java/com/ning/billing/jaxrs/json/PaymentJsonSimple.java b/jaxrs/src/main/java/com/ning/billing/jaxrs/json/PaymentJsonSimple.java
index 6d9cbaa..85fb420 100644
--- a/jaxrs/src/main/java/com/ning/billing/jaxrs/json/PaymentJsonSimple.java
+++ b/jaxrs/src/main/java/com/ning/billing/jaxrs/json/PaymentJsonSimple.java
@@ -17,13 +17,14 @@
package com.ning.billing.jaxrs.json;
import java.math.BigDecimal;
+import java.util.List;
import org.joda.time.DateTime;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.ning.billing.payment.api.Payment;
-import com.ning.billing.payment.api.PaymentStatus;
+import com.ning.billing.payment.api.Payment.PaymentAttempt;
import com.ning.billing.util.clock.DefaultClock;
public class PaymentJsonSimple {
@@ -47,8 +48,16 @@ public class PaymentJsonSimple {
private final String status;
+ private final String gatewayErrorCode;
+
+ private final String gatewayErrorMsg;
+
private final String paymentMethodId;
+ private final String extFirstPaymentIdRef;
+
+ private final String extSecondPaymentIdRef;
+
public PaymentJsonSimple() {
this.amount = null;
this.paidAmount = null;
@@ -61,6 +70,11 @@ public class PaymentJsonSimple {
this.currency = null;
this.retryCount = null;
this.status = null;
+ this.gatewayErrorCode = null;
+ this.gatewayErrorMsg = null;
+ this.extFirstPaymentIdRef = null;
+ this.extSecondPaymentIdRef = null;
+
}
@JsonCreator
@@ -74,7 +88,11 @@ public class PaymentJsonSimple {
@JsonProperty("effectiveDate") final DateTime effectiveDate,
@JsonProperty("retryCount") final Integer retryCount,
@JsonProperty("currency") final String currency,
- @JsonProperty("status") final String status) {
+ @JsonProperty("status") final String status,
+ @JsonProperty("gatewayErrorCode") final String gatewayErrorCode,
+ @JsonProperty("gatewayErrorMsg") final String gatewayErrorMsg,
+ @JsonProperty("extFirstPaymentIdRef") final String extFirstPaymentIdRef,
+ @JsonProperty("extSecondPaymentIdRef") final String extSecondPaymentIdRef) {
super();
this.amount = amount;
this.paidAmount = paidAmount;
@@ -87,6 +105,10 @@ public class PaymentJsonSimple {
this.currency = currency;
this.retryCount = retryCount;
this.status = status;
+ this.gatewayErrorCode = gatewayErrorCode;
+ this.gatewayErrorMsg = gatewayErrorMsg;
+ this.extFirstPaymentIdRef = extFirstPaymentIdRef;
+ this.extSecondPaymentIdRef = extSecondPaymentIdRef;
}
public PaymentJsonSimple(final Payment src) {
@@ -100,7 +122,11 @@ public class PaymentJsonSimple {
this.effectiveDate = src.getEffectiveDate();
this.currency = src.getCurrency().toString();
this.retryCount = src.getAttempts().size();
+ this.gatewayErrorCode = src.getAttempts().get(retryCount - 1).getGatewayErrorCode();
+ this.gatewayErrorMsg = src.getAttempts().get(retryCount - 1).getGatewayErrorMsg();;
this.status = src.getPaymentStatus().toString();
+ this.extFirstPaymentIdRef = src.getExtFirstPaymentIdRef();
+ this.extSecondPaymentIdRef = src.getExtSecondPaymentIdRef();
}
public BigDecimal getPaidAmount() {
@@ -148,6 +174,22 @@ public class PaymentJsonSimple {
return accountId;
}
+ public String getGatewayErrorCode() {
+ return gatewayErrorCode;
+ }
+
+ public String getGatewayErrorMsg() {
+ return gatewayErrorMsg;
+ }
+
+ public String getExtFirstPaymentIdRef() {
+ return extFirstPaymentIdRef;
+ }
+
+ public String getExtSecondPaymentIdRef() {
+ return extSecondPaymentIdRef;
+ }
+
@Override
public boolean equals(final Object o) {
if (this == o) {
diff --git a/jaxrs/src/main/java/com/ning/billing/jaxrs/json/PaymentJsonWithBundleKeys.java b/jaxrs/src/main/java/com/ning/billing/jaxrs/json/PaymentJsonWithBundleKeys.java
index 9451faa..ec87e78 100644
--- a/jaxrs/src/main/java/com/ning/billing/jaxrs/json/PaymentJsonWithBundleKeys.java
+++ b/jaxrs/src/main/java/com/ning/billing/jaxrs/json/PaymentJsonWithBundleKeys.java
@@ -50,10 +50,15 @@ public class PaymentJsonWithBundleKeys extends PaymentJsonSimple {
@JsonProperty("retryCount") final Integer retryCount,
@JsonProperty("currency") final String currency,
@JsonProperty("status") final String status,
+ @JsonProperty("gatewayErrorCode") final String gatewayErrorCode,
+ @JsonProperty("gatewayErrorMsg") final String gatewayErrorMsg,
+ @JsonProperty("extFirstPaymentIdRef") final String extFirstPaymentIdRef,
+ @JsonProperty("extSecondPaymentIdRef") final String extSecondPaymentIdRef,
@JsonProperty("externalBundleKeys") final String bundleKeys,
@JsonProperty("refunds") final List<RefundJson> refunds,
@JsonProperty("chargebacks") final List<ChargebackJson> chargebacks) {
- super(amount, paidAmount, accountId, invoiceId, paymentId, paymentMethodId, requestedDate, effectiveDate, retryCount, currency, status);
+ super(amount, paidAmount, accountId, invoiceId, paymentId, paymentMethodId, requestedDate, effectiveDate, retryCount, currency, status, gatewayErrorCode, gatewayErrorMsg,
+ extFirstPaymentIdRef, extSecondPaymentIdRef);
this.bundleKeys = bundleKeys;
this.refunds = refunds;
this.chargebacks = chargebacks;
diff --git a/jaxrs/src/test/java/com/ning/billing/jaxrs/json/TestBundleTimelineJson.java b/jaxrs/src/test/java/com/ning/billing/jaxrs/json/TestBundleTimelineJson.java
index 9c835af..c798b24 100644
--- a/jaxrs/src/test/java/com/ning/billing/jaxrs/json/TestBundleTimelineJson.java
+++ b/jaxrs/src/test/java/com/ning/billing/jaxrs/json/TestBundleTimelineJson.java
@@ -99,7 +99,11 @@ public class TestBundleTimelineJson extends JaxrsTestSuite {
"\"effectiveDate\":\"" + payment.getEffectiveDate().toDateTimeISO().toString() + "\"," +
"\"retryCount\":" + payment.getRetryCount() + "," +
"\"currency\":\"" + payment.getCurrency() + "\"," +
- "\"status\":\"" + payment.getStatus() + "\"}]," +
+ "\"status\":\"" + payment.getStatus() + "\"," +
+ "\"gatewayErrorCode\":\"" + payment.getGatewayErrorCode() + "\"," +
+ "\"gatewayErrorMsg\":\"" + payment.getGatewayErrorMsg() + "\"," +
+ "\"extFirstPaymentIdRef\":\"" + payment.getExtFirstPaymentIdRef() + "\"," +
+ "\"extSecondPaymentIdRef\":\"" + payment.getExtSecondPaymentIdRef() + "\"}]," +
"\"invoices\":[{\"amount\":" + invoice.getAmount() + "," +
"\"cba\":" + invoice.getCBA() + "," +
"\"creditAdj\":" + invoice.getCreditAdj() + "," +
@@ -165,8 +169,12 @@ public class TestBundleTimelineJson extends JaxrsTestSuite {
final Integer retryCount = Integer.MAX_VALUE;
final String currency = "USD";
final String status = UUID.randomUUID().toString();
+ final String gatewayErrorCode = "OK";
+ final String gatewayErrorMsg = "Excellent...";
+ final String extFirstPaymentIdRef = UUID.randomUUID().toString();
+ final String extSecondPaymentIdRef = UUID.randomUUID().toString();
return new PaymentJsonSimple(amount, paidAmount, accountId.toString(), invoiceId.toString(), paymentId.toString(),
- paymentMethodId.toString(), paymentRequestedDate, paymentEffectiveDate, retryCount, currency, status);
+ paymentMethodId.toString(), paymentRequestedDate, paymentEffectiveDate, retryCount, currency, status, gatewayErrorCode, gatewayErrorMsg, extFirstPaymentIdRef, extSecondPaymentIdRef);
}
}
diff --git a/payment/src/main/java/com/ning/billing/payment/api/DefaultPayment.java b/payment/src/main/java/com/ning/billing/payment/api/DefaultPayment.java
index 8bb07fd..6aa1705 100644
--- a/payment/src/main/java/com/ning/billing/payment/api/DefaultPayment.java
+++ b/payment/src/main/java/com/ning/billing/payment/api/DefaultPayment.java
@@ -44,13 +44,16 @@ public class DefaultPayment extends EntityBase implements Payment {
private final DateTime effectiveDate;
private final Integer paymentNumber;
private final PaymentStatus paymentStatus;
+ private final String extFirstPaymentIdRef;
+ private final String extSecondPaymentIdRef;
private final List<PaymentAttempt> attempts;
private DefaultPayment(final UUID id, final UUID accountId, final UUID invoiceId,
final UUID paymentMethodId, final BigDecimal amount, BigDecimal paidAmount, final Currency currency,
final DateTime effectiveDate, final Integer paymentNumber,
- final PaymentStatus paymentStatus, final String paymentError, final List<PaymentAttempt> attempts) {
+ final PaymentStatus paymentStatus, final String paymentError, final String extFirstPaymentIdRef,
+ final String extSecondPaymentIdRef, final List<PaymentAttempt> attempts) {
super(id);
this.accountId = accountId;
this.invoiceId = invoiceId;
@@ -61,6 +64,8 @@ public class DefaultPayment extends EntityBase implements Payment {
this.effectiveDate = effectiveDate;
this.paymentNumber = paymentNumber;
this.paymentStatus = paymentStatus;
+ this.extFirstPaymentIdRef = extFirstPaymentIdRef;
+ this.extSecondPaymentIdRef = extSecondPaymentIdRef;
this.attempts = attempts;
}
@@ -76,10 +81,11 @@ public class DefaultPayment extends EntityBase implements Payment {
src.getPaymentNumber(),
src.getPaymentStatus(),
null,
+ src.getExtFirstPaymentRefId(),
+ src.getExtSecondPaymentRefId(),
toPaymentAttempts(attempts));
}
-
@Override
public Integer getPaymentNumber() {
return paymentNumber;
@@ -125,6 +131,16 @@ public class DefaultPayment extends EntityBase implements Payment {
return paymentStatus;
}
+ @Override
+ public String getExtFirstPaymentIdRef() {
+ return extFirstPaymentIdRef;
+ }
+
+ @Override
+ public String getExtSecondPaymentIdRef() {
+ return extSecondPaymentIdRef;
+ }
+
@Override
public List<PaymentAttempt> getAttempts() {
@@ -160,11 +176,6 @@ public class DefaultPayment extends EntityBase implements Payment {
}
@Override
- public String getErrorMsg() {
- return input.getPaymentError();
- }
-
- @Override
public DateTime getEffectiveDate() {
return input.getEffectiveDate();
}
@@ -173,6 +184,16 @@ public class DefaultPayment extends EntityBase implements Payment {
public UUID getId() {
return input.getId();
}
+
+ @Override
+ public String getGatewayErrorCode() {
+ return input.getGatewayErrorCode();
+ }
+
+ @Override
+ public String getGatewayErrorMsg() {
+ return input.getGatewayErrorMsg();
+ }
};
}
}));
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 c40707c..d884734 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
@@ -36,7 +36,8 @@ public class DefaultPaymentInfoEvent extends EntityBase implements PaymentInfoEv
private final PaymentStatus status;
private final UUID userToken;
private final DateTime effectiveDate;
- private final String extPaymentRefId;
+ private final String extFirstPaymentRefId;
+ private final String extSecondPaymentRefId;
@JsonCreator
public DefaultPaymentInfoEvent(@JsonProperty("id") final UUID id,
@@ -46,7 +47,8 @@ public class DefaultPaymentInfoEvent extends EntityBase implements PaymentInfoEv
@JsonProperty("amount") final BigDecimal amount,
@JsonProperty("paymentNumber") final Integer paymentNumber,
@JsonProperty("status") final PaymentStatus status,
- @JsonProperty("extPaymentRefId") final String extPaymentRefId,
+ @JsonProperty("extFirstPaymentRefId") final String extFirstPaymentRefId,
+ @JsonProperty("extSecondPaymentRefId") final String extSecondPaymentRefId,
@JsonProperty("userToken") final UUID userToken,
@JsonProperty("effectiveDate") final DateTime effectiveDate) {
super(id);
@@ -56,7 +58,8 @@ public class DefaultPaymentInfoEvent extends EntityBase implements PaymentInfoEv
this.amount = amount;
this.paymentNumber = paymentNumber;
this.status = status;
- this.extPaymentRefId = extPaymentRefId;
+ this.extFirstPaymentRefId = extFirstPaymentRefId;
+ this.extSecondPaymentRefId = extSecondPaymentRefId;
this.userToken = userToken;
this.effectiveDate = effectiveDate;
}
@@ -64,8 +67,8 @@ public class DefaultPaymentInfoEvent extends EntityBase implements PaymentInfoEv
public DefaultPaymentInfoEvent(final UUID accountId, final UUID invoiceId,
final UUID paymentId, final BigDecimal amount, final Integer paymentNumber,
- final PaymentStatus status, final String extPaymentRefId, final UUID userToken, final DateTime effectiveDate) {
- this(UUID.randomUUID(), accountId, invoiceId, paymentId, amount, paymentNumber, status, extPaymentRefId, userToken, effectiveDate);
+ final PaymentStatus status, final String extFirstPaymentRefId, final String extSecondPaymentRefId, final UUID userToken, final DateTime effectiveDate) {
+ this(UUID.randomUUID(), accountId, invoiceId, paymentId, amount, paymentNumber, status, extFirstPaymentRefId, extSecondPaymentRefId, userToken, effectiveDate);
}
public DefaultPaymentInfoEvent(final DefaultPaymentInfoEvent src) {
@@ -76,7 +79,8 @@ public class DefaultPaymentInfoEvent extends EntityBase implements PaymentInfoEv
src.amount,
src.paymentNumber,
src.status,
- src.extPaymentRefId,
+ src.extFirstPaymentRefId,
+ src.extSecondPaymentRefId,
src.userToken,
src.effectiveDate);
}
@@ -137,8 +141,13 @@ public class DefaultPaymentInfoEvent extends EntityBase implements PaymentInfoEv
}
@Override
- public String getExtPaymentRefId() {
- return extPaymentRefId;
+ public String getExtFirstPaymentRefId() {
+ return extFirstPaymentRefId;
+ }
+
+ @Override
+ public String getExtSecondPaymentRefId() {
+ return extSecondPaymentRefId;
}
@Override
@@ -153,7 +162,8 @@ public class DefaultPaymentInfoEvent extends EntityBase implements PaymentInfoEv
sb.append(", status=").append(status);
sb.append(", userToken=").append(userToken);
sb.append(", effectiveDate=").append(effectiveDate);
- sb.append(", extPaymentRefId='").append(extPaymentRefId).append('\'');
+ sb.append(", extFirstPaymentRefId='").append(extFirstPaymentRefId).append('\'');
+ sb.append(", extSecondPaymentRefId='").append(extSecondPaymentRefId).append('\'');
sb.append('}');
return sb.toString();
}
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 c09bad9..f820705 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
@@ -447,7 +447,7 @@ public class PaymentProcessor extends ProcessorBase {
case PROCESSED:
// Update Payment/PaymentAttempt status
paymentStatus = PaymentStatus.SUCCESS;
- paymentDao.updateStatusForPaymentWithAttempt(paymentInput.getId(), paymentStatus, null, paymentPluginInfo.getExternalReferenceId(), attemptInput.getId(), context);
+ paymentDao.updateStatusForPaymentWithAttempt(paymentInput.getId(), paymentStatus, paymentPluginInfo.getGatewayErrorCode(), null, paymentPluginInfo.getExtFirstReferenceId(), paymentPluginInfo.getExtSecondReferenceId(), attemptInput.getId(), context);
// Fetch latest objects
allAttempts = paymentDao.getAttemptsForPayment(paymentInput.getId());
@@ -463,7 +463,7 @@ public class PaymentProcessor extends ProcessorBase {
// Create Bus event
event = new DefaultPaymentInfoEvent(account.getId(),
invoice.getId(), payment.getId(), payment.getAmount(), payment.getPaymentNumber(), paymentStatus,
- paymentPluginInfo.getExternalReferenceId(), context.getUserToken(), payment.getEffectiveDate());
+ paymentPluginInfo.getExtFirstReferenceId(), paymentPluginInfo.getExtSecondReferenceId(), context.getUserToken(), payment.getEffectiveDate());
break;
case ERROR:
@@ -475,7 +475,7 @@ public class PaymentProcessor extends ProcessorBase {
paymentStatus = PaymentStatus.PAYMENT_FAILURE_ABORTED;
}
- paymentDao.updateStatusForPaymentWithAttempt(paymentInput.getId(), paymentStatus, paymentPluginInfo.getGatewayError(), null, attemptInput.getId(), context);
+ paymentDao.updateStatusForPaymentWithAttempt(paymentInput.getId(), paymentStatus, paymentPluginInfo.getGatewayErrorCode(), paymentPluginInfo.getGatewayError(),null, null, attemptInput.getId(), context);
log.info(String.format("Could not process payment for account %s, invoice %s, error = %s",
account.getId(), invoice.getId(), paymentPluginInfo.getGatewayError()));
@@ -496,7 +496,7 @@ public class PaymentProcessor extends ProcessorBase {
paymentStatus = isInstantPayment ? PaymentStatus.PAYMENT_FAILURE_ABORTED : scheduleRetryOnPluginFailure(paymentInput.getId());
// STEPH message might need truncation to fit??
- paymentDao.updateStatusForPaymentWithAttempt(paymentInput.getId(), paymentStatus, e.getMessage(), null, attemptInput.getId(), context);
+ paymentDao.updateStatusForPaymentWithAttempt(paymentInput.getId(), paymentStatus, null, e.getMessage(), null, null, 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/dao/AuditedPaymentDao.java b/payment/src/main/java/com/ning/billing/payment/dao/AuditedPaymentDao.java
index 0a2aa27..a749627 100644
--- a/payment/src/main/java/com/ning/billing/payment/dao/AuditedPaymentDao.java
+++ b/payment/src/main/java/com/ning/billing/payment/dao/AuditedPaymentDao.java
@@ -121,16 +121,21 @@ public class AuditedPaymentDao implements PaymentDao {
@Override
public void updateStatusForPaymentWithAttempt(final UUID paymentId,
- final PaymentStatus paymentStatus, final String paymentError, final String extPaymentRefId, final UUID attemptId,
+ final PaymentStatus paymentStatus,
+ final String gatewayErrorCode,
+ final String gatewayErrorMsg,
+ final String extFirstPaymentRefId,
+ final String extSecondPaymentRefId,
+ final UUID attemptId,
final CallContext context) {
paymentSqlDao.inTransaction(new Transaction<Void, PaymentSqlDao>() {
@Override
public Void inTransaction(final PaymentSqlDao transactional,
final TransactionStatus status) throws Exception {
- updatePaymentStatusFromTransaction(paymentId, paymentStatus, extPaymentRefId, context, transactional);
+ updatePaymentStatusFromTransaction(paymentId, paymentStatus, extFirstPaymentRefId, extSecondPaymentRefId, context, transactional);
final PaymentAttemptSqlDao transPaymentAttemptSqlDao = transactional.become(PaymentAttemptSqlDao.class);
- updatePaymentAttemptStatusFromTransaction(attemptId, paymentStatus, paymentError, context, transPaymentAttemptSqlDao);
+ updatePaymentAttemptStatusFromTransaction(attemptId, paymentStatus, gatewayErrorCode, gatewayErrorMsg, context, transPaymentAttemptSqlDao);
return null;
}
});
@@ -147,8 +152,8 @@ public class AuditedPaymentDao implements PaymentDao {
transactional.insertAuditFromTransaction(audit, context);
}
- private void updatePaymentStatusFromTransaction(final UUID paymentId, final PaymentStatus paymentStatus, final String extPaymentRefId, final CallContext context, final PaymentSqlDao transactional) {
- transactional.updatePaymentStatusAndExtRef(paymentId.toString(), paymentStatus.toString(), extPaymentRefId, context);
+ private void updatePaymentStatusFromTransaction(final UUID paymentId, final PaymentStatus paymentStatus, final String extFirstPaymentRefId, final String extSecondPaymentRefId, final CallContext context, final PaymentSqlDao transactional) {
+ transactional.updatePaymentStatusAndExtRef(paymentId.toString(), paymentStatus.toString(), extFirstPaymentRefId, extSecondPaymentRefId, context);
final PaymentModelDao savedPayment = transactional.getPayment(paymentId.toString());
final Long recordId = transactional.getRecordId(savedPayment.getId().toString());
final EntityHistory<PaymentModelDao> history = new EntityHistory<PaymentModelDao>(savedPayment.getId(), recordId, savedPayment, ChangeType.UPDATE);
@@ -158,8 +163,8 @@ public class AuditedPaymentDao implements PaymentDao {
transactional.insertAuditFromTransaction(audit, context);
}
- private void updatePaymentAttemptStatusFromTransaction(final UUID attemptId, final PaymentStatus processingStatus, final String paymentError, final CallContext context, final PaymentAttemptSqlDao transactional) {
- transactional.updatePaymentAttemptStatus(attemptId.toString(), processingStatus.toString(), paymentError);
+ private void updatePaymentAttemptStatusFromTransaction(final UUID attemptId, final PaymentStatus processingStatus, final String gatewayErrorCode, final String gatewayErrorMsg, final CallContext context, final PaymentAttemptSqlDao transactional) {
+ transactional.updatePaymentAttemptStatus(attemptId.toString(), processingStatus.toString(), gatewayErrorCode, gatewayErrorMsg);
final PaymentAttemptModelDao savedAttempt = transactional.getPaymentAttempt(attemptId.toString());
final Long recordId = transactional.getRecordId(savedAttempt.getId().toString());
final EntityHistory<PaymentAttemptModelDao> history = new EntityHistory<PaymentAttemptModelDao>(savedAttempt.getId(), recordId, savedAttempt, ChangeType.UPDATE);
diff --git a/payment/src/main/java/com/ning/billing/payment/dao/PaymentAttemptHistoryBinder.java b/payment/src/main/java/com/ning/billing/payment/dao/PaymentAttemptHistoryBinder.java
index 7f66ace..dc59070 100644
--- a/payment/src/main/java/com/ning/billing/payment/dao/PaymentAttemptHistoryBinder.java
+++ b/payment/src/main/java/com/ning/billing/payment/dao/PaymentAttemptHistoryBinder.java
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright 2010-2011 Ning, Inc.
*
* Ning licenses this file to you under the Apache License, version 2.0
@@ -47,7 +47,8 @@ public @interface PaymentAttemptHistoryBinder {
q.bind("id", attempt.getId().toString());
q.bind("paymentId", attempt.getPaymentId().toString());
q.bind("processingStatus", attempt.getPaymentStatus().toString());
- q.bind("paymentError", attempt.getPaymentError());
+ q.bind("gatewayErrorCode", attempt.getGatewayErrorCode() );
+ q.bind("gatewayErrorMsg", attempt.getGatewayErrorMsg() );
q.bind("requestedAmount", attempt.getRequestedAmount());
}
};
diff --git a/payment/src/main/java/com/ning/billing/payment/dao/PaymentAttemptModelDao.java b/payment/src/main/java/com/ning/billing/payment/dao/PaymentAttemptModelDao.java
index 383bd0f..2234c61 100644
--- a/payment/src/main/java/com/ning/billing/payment/dao/PaymentAttemptModelDao.java
+++ b/payment/src/main/java/com/ning/billing/payment/dao/PaymentAttemptModelDao.java
@@ -30,12 +30,13 @@ public class PaymentAttemptModelDao extends EntityBase {
private final UUID paymentId;
private final PaymentStatus processingStatus;
private final DateTime effectiveDate;
- private final String paymentError;
+ private final String gatewayErrorCode;
+ private final String gatewayErrorMsg;
private final BigDecimal requestedAmount;
public PaymentAttemptModelDao(final UUID id, final UUID accountId, final UUID invoiceId,
final UUID paymentId, final PaymentStatus processingStatus, final DateTime effectiveDate,
- final BigDecimal requestedAmount, final String paymentError) {
+ final BigDecimal requestedAmount, final String gatewayErrorCode, final String gatewayErrorMsg) {
super(id);
this.accountId = accountId;
this.invoiceId = invoiceId;
@@ -43,20 +44,21 @@ public class PaymentAttemptModelDao extends EntityBase {
this.processingStatus = processingStatus;
this.effectiveDate = effectiveDate;
this.requestedAmount = requestedAmount;
- this.paymentError = paymentError;
+ this.gatewayErrorCode = gatewayErrorCode;
+ this.gatewayErrorMsg = gatewayErrorMsg;
}
public PaymentAttemptModelDao(final UUID accountId, final UUID invoiceId, final UUID paymentId, final PaymentStatus paymentStatus, final DateTime effectiveDate, final BigDecimal requestedAmount) {
- this(UUID.randomUUID(), accountId, invoiceId, paymentId, paymentStatus, effectiveDate, requestedAmount, null);
+ this(UUID.randomUUID(), accountId, invoiceId, paymentId, paymentStatus, effectiveDate, requestedAmount, null, null);
}
public PaymentAttemptModelDao(final UUID accountId, final UUID invoiceId, final UUID paymentId, final DateTime effectiveDate, final BigDecimal requestedAmount) {
- this(UUID.randomUUID(), accountId, invoiceId, paymentId, PaymentStatus.UNKNOWN, effectiveDate, requestedAmount, null);
+ this(UUID.randomUUID(), accountId, invoiceId, paymentId, PaymentStatus.UNKNOWN, effectiveDate, requestedAmount, null, null);
}
- public PaymentAttemptModelDao(final PaymentAttemptModelDao src, final PaymentStatus newProcessingStatus, final String paymentError) {
+ public PaymentAttemptModelDao(final PaymentAttemptModelDao src, final PaymentStatus newProcessingStatus, final String gatewayErrorCode, final String gatewayErrorMsg) {
this(src.getId(), src.getAccountId(), src.getInvoiceId(), src.getPaymentId(), newProcessingStatus,
- src.getEffectiveDate(), src.getRequestedAmount(), paymentError);
+ src.getEffectiveDate(), src.getRequestedAmount(), gatewayErrorCode, gatewayErrorMsg);
}
public UUID getAccountId() {
@@ -79,8 +81,12 @@ public class PaymentAttemptModelDao extends EntityBase {
return effectiveDate;
}
- public String getPaymentError() {
- return paymentError;
+ public String getGatewayErrorCode() {
+ return gatewayErrorCode;
+ }
+
+ public String getGatewayErrorMsg() {
+ return gatewayErrorMsg;
}
public BigDecimal getRequestedAmount() {
diff --git a/payment/src/main/java/com/ning/billing/payment/dao/PaymentAttemptSqlDao.java b/payment/src/main/java/com/ning/billing/payment/dao/PaymentAttemptSqlDao.java
index 669e669..f69622f 100644
--- a/payment/src/main/java/com/ning/billing/payment/dao/PaymentAttemptSqlDao.java
+++ b/payment/src/main/java/com/ning/billing/payment/dao/PaymentAttemptSqlDao.java
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright 2010-2011 Ning, Inc.
*
* Ning licenses this file to you under the Apache License, version 2.0
@@ -56,7 +56,8 @@ public interface PaymentAttemptSqlDao extends Transactional<PaymentAttemptSqlDao
@SqlUpdate
void updatePaymentAttemptStatus(@Bind("id") final String attemptId,
@Bind("processingStatus") final String processingStatus,
- @Bind("paymentError") final String paymentError);
+ @Bind("gatewayErrorCode") final String gatewayErrorCode,
+ @Bind("gatewayErrorMsg") final String gatewayErrorMsg);
@SqlQuery
PaymentAttemptModelDao getPaymentAttempt(@Bind("id") final String attemptId);
@@ -76,7 +77,8 @@ public interface PaymentAttemptSqlDao extends Transactional<PaymentAttemptSqlDao
stmt.bind("id", attempt.getId().toString());
stmt.bind("paymentId", attempt.getPaymentId().toString());
stmt.bind("processingStatus", attempt.getPaymentStatus().toString());
- stmt.bind("paymentError", attempt.getPaymentError());
+ stmt.bind("gatewayErrorCode", attempt.getGatewayErrorCode());
+ stmt.bind("gatewayErrorMsg", attempt.getGatewayErrorMsg());
stmt.bind("requestedAmount", attempt.getRequestedAmount());
}
}
@@ -92,9 +94,10 @@ public interface PaymentAttemptSqlDao extends Transactional<PaymentAttemptSqlDao
final UUID paymentId = getUUID(rs, "payment_id");
final DateTime effectiveDate = getDateTime(rs, "effective_date");
final PaymentStatus processingStatus = PaymentStatus.valueOf(rs.getString("processing_status"));
- final String paymentError = rs.getString("payment_error");
+ final String gatewayErrorCode = rs.getString("gateway_error_code");
+ final String gatewayErrorMsg = rs.getString("gateway_error_msg");
final BigDecimal requestedAmount = rs.getBigDecimal("requested_amount");
- return new PaymentAttemptModelDao(id, accountId, invoiceId, paymentId, processingStatus, effectiveDate, requestedAmount, paymentError);
+ return new PaymentAttemptModelDao(id, accountId, invoiceId, paymentId, processingStatus, effectiveDate, requestedAmount, gatewayErrorCode, gatewayErrorMsg);
}
}
}
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 68a7fec..4d24526 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
@@ -29,7 +29,7 @@ public interface PaymentDao {
public PaymentAttemptModelDao insertNewAttemptForPayment(final UUID paymentId, final PaymentAttemptModelDao attempt, final CallContext context);
- public void updateStatusForPaymentWithAttempt(final UUID paymentId, final PaymentStatus paymentStatus, final String paymentError, final String extPaymentRefId, final UUID attemptId, final CallContext context);
+ public void updateStatusForPaymentWithAttempt(final UUID paymentId, final PaymentStatus paymentStatus, final String gatewayErrorCode, final String gatewayErrorMsg, final String extFirstPaymentRefId, final String extSecondPaymentRefId, final UUID attemptId, final CallContext context);
public PaymentAttemptModelDao getPaymentAttempt(final UUID attemptId);
diff --git a/payment/src/main/java/com/ning/billing/payment/dao/PaymentHistoryBinder.java b/payment/src/main/java/com/ning/billing/payment/dao/PaymentHistoryBinder.java
index d47cf05..a6db584 100644
--- a/payment/src/main/java/com/ning/billing/payment/dao/PaymentHistoryBinder.java
+++ b/payment/src/main/java/com/ning/billing/payment/dao/PaymentHistoryBinder.java
@@ -49,7 +49,8 @@ public @interface PaymentHistoryBinder {
q.bind("amount", payment.getAmount());
q.bind("currency", payment.getCurrency().toString());
q.bind("paymentStatus", payment.getPaymentStatus().toString());
- q.bind("externalPaymentRefId", payment.getExtPaymentRefId());
+ q.bind("extFirstPaymentRefId", payment.getExtFirstPaymentRefId());
+ q.bind("extSecondPaymentRefId", payment.getExtSecondPaymentRefId());
q.bind("effectiveDate", getDate(payment.getEffectiveDate()));
}
};
diff --git a/payment/src/main/java/com/ning/billing/payment/dao/PaymentModelDao.java b/payment/src/main/java/com/ning/billing/payment/dao/PaymentModelDao.java
index 24a9f74..3091e47 100644
--- a/payment/src/main/java/com/ning/billing/payment/dao/PaymentModelDao.java
+++ b/payment/src/main/java/com/ning/billing/payment/dao/PaymentModelDao.java
@@ -36,11 +36,12 @@ public class PaymentModelDao extends EntityBase {
private final DateTime effectiveDate;
private final Integer paymentNumber;
private final PaymentStatus paymentStatus;
- private final String extPaymentRefId;
+ private final String extFirstPaymentRefId;
+ private final String extSecondPaymentRefId;
public PaymentModelDao(final UUID id, final UUID accountId, final UUID invoiceId, final UUID paymentMethodId,
final Integer paymentNumber, final BigDecimal amount, final Currency currency,
- final PaymentStatus paymentStatus, final DateTime effectiveDate, final String extPaymentRefId) {
+ final PaymentStatus paymentStatus, final DateTime effectiveDate, final String extFirstPaymentRefId, final String extSecondPaymentRefId) {
super(id);
this.accountId = accountId;
this.invoiceId = invoiceId;
@@ -50,21 +51,22 @@ public class PaymentModelDao extends EntityBase {
this.currency = currency;
this.paymentStatus = paymentStatus;
this.effectiveDate = effectiveDate;
- this.extPaymentRefId = extPaymentRefId;
+ this.extFirstPaymentRefId = extFirstPaymentRefId;
+ this.extSecondPaymentRefId = extSecondPaymentRefId;
}
public PaymentModelDao(final UUID accountId, final UUID invoiceId, final UUID paymentMethodId,
final BigDecimal amount, final Currency currency, final DateTime effectiveDate, final PaymentStatus paymentStatus) {
- this(UUID.randomUUID(), accountId, invoiceId, paymentMethodId, INVALID_PAYMENT_NUMBER, amount, currency, paymentStatus, effectiveDate, null);
+ this(UUID.randomUUID(), accountId, invoiceId, paymentMethodId, INVALID_PAYMENT_NUMBER, amount, currency, paymentStatus, effectiveDate, null, null);
}
public PaymentModelDao(final UUID accountId, final UUID invoiceId, final UUID paymentMethodId,
final BigDecimal amount, final Currency currency, final DateTime effectiveDate) {
- this(UUID.randomUUID(), accountId, invoiceId, paymentMethodId, INVALID_PAYMENT_NUMBER, amount, currency, PaymentStatus.UNKNOWN, effectiveDate, null);
+ this(UUID.randomUUID(), accountId, invoiceId, paymentMethodId, INVALID_PAYMENT_NUMBER, amount, currency, PaymentStatus.UNKNOWN, effectiveDate, null, null);
}
public PaymentModelDao(final PaymentModelDao src, final PaymentStatus newPaymentStatus) {
- this(src.getId(), src.getAccountId(), src.getInvoiceId(), src.getPaymentMethodId(), src.getPaymentNumber(), src.getAmount(), src.getCurrency(), newPaymentStatus, src.getEffectiveDate(), null);
+ this(src.getId(), src.getAccountId(), src.getInvoiceId(), src.getPaymentMethodId(), src.getPaymentNumber(), src.getAmount(), src.getCurrency(), newPaymentStatus, src.getEffectiveDate(), null, null);
}
public UUID getAccountId() {
@@ -99,7 +101,11 @@ public class PaymentModelDao extends EntityBase {
return effectiveDate;
}
- public String getExtPaymentRefId() {
- return extPaymentRefId;
+ public String getExtFirstPaymentRefId() {
+ return extFirstPaymentRefId;
+ }
+
+ public String getExtSecondPaymentRefId() {
+ return extSecondPaymentRefId;
}
}
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 a9dda96..a669904 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
@@ -54,7 +54,8 @@ public interface PaymentSqlDao extends Transactional<PaymentSqlDao>, UpdatableEn
@SqlUpdate
void updatePaymentStatusAndExtRef(@Bind("id") final String paymentId, @Bind("paymentStatus") final String paymentStatus,
- @Bind("externalPaymentRefId") final String externalPaymentRefId, @CallContextBinder final CallContext context);
+ @Bind("extFirstPaymentRefId") final String extFirstPaymentRefId, @Bind("extSecondPaymentRefId") final String extSecondPaymentRefId,
+ @CallContextBinder final CallContext context);
@SqlUpdate
void updatePaymentAmount(@Bind("id") final String paymentId, @Bind("amount") final BigDecimal amount,
@@ -87,7 +88,8 @@ public interface PaymentSqlDao extends Transactional<PaymentSqlDao>, UpdatableEn
stmt.bind("currency", payment.getCurrency().toString());
stmt.bind("effectiveDate", getDate(payment.getEffectiveDate()));
stmt.bind("paymentStatus", payment.getPaymentStatus().toString());
- stmt.bind("externalPaymentRefId", payment.getExtPaymentRefId());
+ stmt.bind("extFirstPaymentRefId", payment.getExtFirstPaymentRefId());
+ stmt.bind("extSecondPaymentRefId", payment.getExtSecondPaymentRefId());
}
}
@@ -105,9 +107,9 @@ public interface PaymentSqlDao extends Transactional<PaymentSqlDao>, UpdatableEn
final DateTime effectiveDate = getDateTime(rs, "effective_date");
final Currency currency = Currency.valueOf(rs.getString("currency"));
final PaymentStatus paymentStatus = PaymentStatus.valueOf(rs.getString("payment_status"));
- final String extPaymentRefId = rs.getString("external_payment_ref_id");
-
- return new PaymentModelDao(id, accountId, invoiceId, paymentMethodId, paymentNumber, amount, currency, paymentStatus, effectiveDate, extPaymentRefId);
+ final String extFirstPaymentRefId = rs.getString("ext_first_payment_ref_id");
+ final String extSecondPaymentRefId = rs.getString("ext_second_payment_ref_id");
+ return new PaymentModelDao(id, accountId, invoiceId, paymentMethodId, paymentNumber, amount, currency, paymentStatus, effectiveDate, extFirstPaymentRefId, extSecondPaymentRefId);
}
}
}
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 e4c20f3..3dd0a01 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
@@ -73,7 +73,13 @@ public class DefaultNoOpPaymentInfoPlugin implements PaymentInfoPlugin {
@Override
- public String getExternalReferenceId() {
+ public String getExtFirstReferenceId() {
+ return null;
+ }
+
+
+ @Override
+ public String getExtSecondReferenceId() {
return null;
}
}
diff --git a/payment/src/main/resources/com/ning/billing/payment/dao/PaymentAttemptSqlDao.sql.stg b/payment/src/main/resources/com/ning/billing/payment/dao/PaymentAttemptSqlDao.sql.stg
index 89b76b1..aa3201a 100644
--- a/payment/src/main/resources/com/ning/billing/payment/dao/PaymentAttemptSqlDao.sql.stg
+++ b/payment/src/main/resources/com/ning/billing/payment/dao/PaymentAttemptSqlDao.sql.stg
@@ -3,7 +3,8 @@ group PaymentAttemptSqlDao;
paymentAttemptFields(prefix) ::= <<
<prefix>id,
<prefix>payment_id,
- <prefix>payment_error,
+ <prefix>gateway_error_code,
+ <prefix>gateway_error_msg,
<prefix>processing_status,
<prefix>requested_amount,
<prefix>created_by,
@@ -14,7 +15,7 @@ paymentAttemptFields(prefix) ::= <<
insertPaymentAttempt() ::= <<
INSERT INTO payment_attempts (<paymentAttemptFields()>)
- VALUES (:id, :paymentId, :paymentError, :processingStatus, :requestedAmount, :userName, :createdDate, :userName, :createdDate);
+ VALUES (:id, :paymentId, :gatewayErrorCode, :gatewayErrorMsg, :processingStatus, :requestedAmount, :userName, :createdDate, :userName, :createdDate);
>>
getPaymentAttempt() ::= <<
@@ -41,7 +42,8 @@ getPaymentAttempts() ::= <<
updatePaymentAttemptStatus() ::= <<
UPDATE payment_attempts
SET processing_status = :processingStatus,
- payment_error = :paymentError
+ gateway_error_code = :gatewayErrorCode,
+ gateway_error_msg = :gatewayErrorMsg
WHERE id = :id;
>>
@@ -62,7 +64,8 @@ historyFields(prefix) ::= <<
<prefix>record_id,
<prefix>id,
<prefix>payment_id,
- <prefix>payment_error,
+ <prefix>gateway_error_code,
+ <prefix>gateway_error_msg,
<prefix>processing_status,
<prefix>requested_amount,
<prefix>created_by,
@@ -73,7 +76,7 @@ historyFields(prefix) ::= <<
insertHistoryFromTransaction() ::= <<
INSERT INTO payment_attempt_history (<historyFields()>)
- VALUES (:recordId, :id, :paymentId, :paymentError, :processingStatus, :requestedAmount, :userName, :createdDate, :userName, :updatedDate);
+ VALUES (:recordId, :id, :paymentId, :gatewayErrorCode, :gatewayErrorMsg, :processingStatus, :requestedAmount, :userName, :createdDate, :userName, :updatedDate);
>>
getHistoryRecordId() ::= <<
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 742d9f7..e9630e3 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,7 +9,8 @@ paymentFields(prefix) ::= <<
<prefix>effective_date,
<prefix>currency,
<prefix>payment_status,
- <prefix>external_payment_ref_id,
+ <prefix>ext_first_payment_ref_id,
+ <prefix>ext_second_payment_ref_id,
<prefix>created_by,
<prefix>created_date,
<prefix>updated_by,
@@ -18,7 +19,7 @@ paymentFields(prefix) ::= <<
insertPayment() ::= <<
INSERT INTO payments (<paymentFields()>)
- VALUES (:id, :accountId, :invoiceId, :paymentMethodId, :amount, :effectiveDate, :currency, :paymentStatus, :externalPaymentRefId, :userName, :createdDate, :userName, :createdDate);
+ VALUES (:id, :accountId, :invoiceId, :paymentMethodId, :amount, :effectiveDate, :currency, :paymentStatus, :extFirstPaymentRefId, :extSecondPaymentRefId, :userName, :createdDate, :userName, :createdDate);
>>
getPayment() ::= <<
@@ -45,7 +46,9 @@ getPaymentsForAccount() ::= <<
updatePaymentStatusAndExtRef() ::= <<
UPDATE payments
- SET payment_status = :paymentStatus, external_payment_ref_id = :externalPaymentRefId
+ SET payment_status = :paymentStatus,
+ ext_first_payment_ref_id = :extFirstPaymentRefId,
+ ext_second_payment_ref_id = :extSecondPaymentRefId
WHERE id = :id;
>>
@@ -72,7 +75,8 @@ historyFields(prefix) ::= <<
<prefix>effective_date,
<prefix>currency,
<prefix>payment_status,
- <prefix>external_payment_ref_id,
+ <prefix>ext_first_payment_ref_id,
+ <prefix>ext_second_payment_ref_id,
<prefix>created_by,
<prefix>created_date,
<prefix>updated_by,
@@ -81,7 +85,7 @@ historyFields(prefix) ::= <<
insertHistoryFromTransaction() ::= <<
INSERT INTO payment_history (<historyFields()>)
- VALUES (:recordId, :id, :accountId, :invoiceId, :paymentMethodId, :amount, :effectiveDate, :currency, :paymentStatus, :externalPaymentRefId, :userName, :createdDate, :userName, :updatedDate);
+ VALUES (:recordId, :id, :accountId, :invoiceId, :paymentMethodId, :amount, :effectiveDate, :currency, :paymentStatus, :extFirstPaymentRefId, :extSecondPaymentRefId, :userName, :createdDate, :userName, :updatedDate);
>>
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 6d184f5..1c47a7c 100644
--- a/payment/src/main/resources/com/ning/billing/payment/ddl.sql
+++ b/payment/src/main/resources/com/ning/billing/payment/ddl.sql
@@ -11,7 +11,8 @@ CREATE TABLE payments (
currency char(3),
effective_date datetime,
payment_status varchar(50),
- external_payment_ref_id varchar(64),
+ 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,
@@ -36,7 +37,8 @@ CREATE TABLE payment_history (
currency char(3),
effective_date datetime,
payment_status varchar(50),
- external_payment_ref_id varchar(64),
+ 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,
@@ -53,7 +55,8 @@ CREATE TABLE payment_attempts (
record_id int(11) unsigned NOT NULL AUTO_INCREMENT,
id char(36) NOT NULL,
payment_id char(36) COLLATE utf8_bin NOT NULL,
- payment_error varchar(256),
+ gateway_error_code varchar(32),
+ gateway_error_msg varchar(256),
processing_status varchar(50),
requested_amount decimal(8,2),
created_by varchar(50) NOT NULL,
@@ -74,7 +77,8 @@ CREATE TABLE payment_attempt_history (
record_id int(11) unsigned NOT NULL,
id char(36) NOT NULL,
payment_id char(36) COLLATE utf8_bin NOT NULL,
- payment_error varchar(256),
+ gateway_error_code varchar(32),
+ gateway_error_msg varchar(256),
processing_status varchar(50),
requested_amount decimal(8,2),
created_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 fd710e5..eb7d76b 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
@@ -41,7 +41,7 @@ public class TestEventJson extends PaymentTestSuite {
@Test(groups = "fast")
public void testPaymentInfoEvent() throws Exception {
- final PaymentInfoEvent e = new DefaultPaymentInfoEvent(UUID.randomUUID(), UUID.randomUUID(), UUID.randomUUID(), new BigDecimal(12.9), new Integer(13), PaymentStatus.SUCCESS, "ext-ref-12345", UUID.randomUUID(), new DateTime());
+ final PaymentInfoEvent e = new DefaultPaymentInfoEvent(UUID.randomUUID(), UUID.randomUUID(), UUID.randomUUID(), new BigDecimal(12.9), new Integer(13), PaymentStatus.SUCCESS, "ext-ref1-12345", "ext-ref2-12345", UUID.randomUUID(), new DateTime());
final String json = mapper.writeValueAsString(e);
final Class<?> clazz = Class.forName(DefaultPaymentInfoEvent.class.getName());
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 9f4775c..3946116 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
@@ -52,10 +52,12 @@ public class MockPaymentDao implements PaymentDao {
return attempt;
}
+
@Override
- public void updateStatusForPaymentWithAttempt(final UUID paymentId,
- final PaymentStatus paymentStatus, final String paymentError, final String extpaymentRefId, final UUID attemptId,
- final CallContext context) {
+ public void updateStatusForPaymentWithAttempt(UUID paymentId,
+ PaymentStatus paymentStatus, String gatewayErrorCode, String gatewayErrorMsg,
+ String extFirstPaymentRefId, String extSecondPaymentRefId,
+ UUID attemptId, CallContext context) {
synchronized (this) {
final PaymentModelDao entry = payments.remove(paymentId);
if (entry != null) {
@@ -63,7 +65,7 @@ public class MockPaymentDao implements PaymentDao {
}
final PaymentAttemptModelDao tmp = attempts.remove(attemptId);
if (tmp != null) {
- attempts.put(attemptId, new PaymentAttemptModelDao(tmp, paymentStatus, paymentError));
+ attempts.put(attemptId, new PaymentAttemptModelDao(tmp, paymentStatus, gatewayErrorCode, gatewayErrorMsg));
}
}
}
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 74cd804..27196ca 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
@@ -137,9 +137,9 @@ public class TestPaymentDao extends PaymentTestSuiteWithEmbeddedDB {
PaymentModelDao savedPayment = paymentDao.insertPaymentWithAttempt(payment, attempt, context);
final PaymentStatus paymentStatus = PaymentStatus.SUCCESS;
- final String paymentError = "No error";
+ final String gatewayErrorCode = "OK";
- paymentDao.updateStatusForPaymentWithAttempt(payment.getId(), paymentStatus, paymentError, null, attempt.getId(), context);
+ paymentDao.updateStatusForPaymentWithAttempt(payment.getId(), paymentStatus, gatewayErrorCode, null, null, null, attempt.getId(), context);
final List<PaymentModelDao> payments = paymentDao.getPaymentsForInvoice(invoiceId);
assertEquals(payments.size(), 1);
@@ -161,7 +161,7 @@ public class TestPaymentDao extends PaymentTestSuiteWithEmbeddedDB {
assertEquals(savedAttempt.getAccountId(), accountId);
assertEquals(savedAttempt.getInvoiceId(), invoiceId);
assertEquals(savedAttempt.getPaymentStatus(), PaymentStatus.SUCCESS);
- assertEquals(savedAttempt.getPaymentError(), paymentError);
+ assertEquals(savedAttempt.getGatewayErrorCode(), gatewayErrorCode);
assertEquals(savedAttempt.getRequestedAmount().compareTo(amount), 0);
}
@@ -253,7 +253,8 @@ public class TestPaymentDao extends PaymentTestSuiteWithEmbeddedDB {
assertEquals(savedAttempt1.getAccountId(), accountId);
assertEquals(savedAttempt1.getInvoiceId(), invoiceId);
assertEquals(savedAttempt1.getPaymentStatus(), PaymentStatus.UNKNOWN);
- assertEquals(savedAttempt1.getPaymentError(), null);
+ assertEquals(savedAttempt1.getGatewayErrorCode(), null);
+ assertEquals(savedAttempt1.getGatewayErrorMsg(), null);
assertEquals(savedAttempt1.getRequestedAmount().compareTo(amount), 0);
final PaymentAttemptModelDao savedAttempt2 = attempts.get(1);
@@ -261,7 +262,8 @@ public class TestPaymentDao extends PaymentTestSuiteWithEmbeddedDB {
assertEquals(savedAttempt2.getAccountId(), accountId);
assertEquals(savedAttempt2.getInvoiceId(), invoiceId);
assertEquals(savedAttempt2.getPaymentStatus(), PaymentStatus.UNKNOWN);
- assertEquals(savedAttempt2.getPaymentError(), null);
+ assertEquals(savedAttempt2.getGatewayErrorCode(), null);
+ assertEquals(savedAttempt2.getGatewayErrorMsg(), null);
assertEquals(savedAttempt2.getRequestedAmount().compareTo(newAmount), 0);
}
diff --git a/server/src/test/java/com/ning/billing/jaxrs/TestInvoice.java b/server/src/test/java/com/ning/billing/jaxrs/TestInvoice.java
index e586273..b6b73fb 100644
--- a/server/src/test/java/com/ning/billing/jaxrs/TestInvoice.java
+++ b/server/src/test/java/com/ning/billing/jaxrs/TestInvoice.java
@@ -205,7 +205,7 @@ public class TestInvoice extends TestJaxrsBase {
}
// CREATE INSTA PAYMENT
- final PaymentJsonSimple payment = new PaymentJsonSimple(cur.getAmount(), BigDecimal.ZERO, accountJson.getAccountId(), cur.getInvoiceId(), null, null, null, null, 0, null, null);
+ final PaymentJsonSimple payment = new PaymentJsonSimple(cur.getAmount(), BigDecimal.ZERO, accountJson.getAccountId(), cur.getInvoiceId(), null, null, null, null, 0, null, null, null, null, null, null);
final String postJson = mapper.writeValueAsString(payment);
uri = JaxrsResource.INVOICES_PATH + "/" + cur.getInvoiceId() + "/" + JaxrsResource.PAYMENTS;