diff --git a/src/main/java/com/ning/billing/recurly/model/Purchase.java b/src/main/java/com/ning/billing/recurly/model/Purchase.java
index a58692f6..18078ba6 100644
--- a/src/main/java/com/ning/billing/recurly/model/Purchase.java
+++ b/src/main/java/com/ning/billing/recurly/model/Purchase.java
@@ -88,6 +88,9 @@ public class Purchase extends RecurlyObject {
@XmlElement(name = "transaction_type")
private String transactionType;
+ @XmlElement(name = "vertex_transaction_type")
+ private String vertexTransactionType;
+
@XmlList
@XmlElementWrapper(name = "coupon_codes")
@XmlElement(name = "coupon_code")
@@ -245,6 +248,14 @@ public void setTransactionType(final Object transactionType) {
this.transactionType = stringOrNull(transactionType);
}
+ public String getVertexTransactionType() {
+ return vertexTransactionType;
+ }
+
+ public void setVertexTransactionType(final Object vertexTransactionType) {
+ this.vertexTransactionType = stringOrNull(vertexTransactionType);
+ }
+
@Override
public String toString() {
final StringBuilder sb = new StringBuilder();
@@ -268,6 +279,7 @@ public String toString() {
sb.append(", shippingAddressId='").append(shippingAddressId).append('\'');
sb.append(", gatewayCode='").append(gatewayCode).append('\'');
sb.append(", transactionType='").append(transactionType).append('\'');
+ sb.append(", vertexTransactionType='").append(vertexTransactionType).append('\'');
sb.append('}');
return sb.toString();
}
@@ -333,6 +345,9 @@ public boolean equals(final Object o) {
if (transactionType != null ? !transactionType.equals(purchase.transactionType) : purchase.transactionType != null) {
return false;
}
+ if (vertexTransactionType != null ? !vertexTransactionType.equals(purchase.vertexTransactionType) : purchase.vertexTransactionType != null) {
+ return false;
+ }
if (vatReverseChargeNotes != null ? !vatReverseChargeNotes.equals(purchase.vatReverseChargeNotes) : purchase.vatReverseChargeNotes != null) {
return false;
}
@@ -361,7 +376,8 @@ public int hashCode() {
billingInfoUuid,
shippingAddressId,
gatewayCode,
- transactionType
+ transactionType,
+ vertexTransactionType
);
}
diff --git a/src/test/java/com/ning/billing/recurly/model/TestPurchase.java b/src/test/java/com/ning/billing/recurly/model/TestPurchase.java
index afd99ce3..20d0134c 100644
--- a/src/test/java/com/ning/billing/recurly/model/TestPurchase.java
+++ b/src/test/java/com/ning/billing/recurly/model/TestPurchase.java
@@ -207,7 +207,94 @@ public void testSerializationWithBillingInfoUuid() throws Exception {
public void verifyPurchaseWithBillingInfoUuid(final Purchase purchase) {
assertEquals(purchase.getBillingInfoUuid(), "iiznlrvdt8py");
- }
+ }
+
+ @Test(groups = "fast")
+ public void testSerializationWithVertexTransactionType() throws Exception {
+ final String purchaseData = "" +
+ "USD" +
+ " automatic" +
+ " rental" +
+ " " +
+ " test" +
+ " " +
+ " Benjamin" +
+ " Du Monde" +
+ " 400 Alabama St" +
+ " San Francisco" +
+ " CA" +
+ " 94110" +
+ " US" +
+ " 2019" +
+ " 12" +
+ " 4000-0000-0000-0000" +
+ " " +
+ " " +
+ " " +
+ " " +
+ " 1000" +
+ " 1" +
+ " USD" +
+ " product-code" +
+ " " +
+ " " +
+ "";
+
+ // test serialization
+ final Purchase purchase = xmlMapper.readValue(purchaseData, Purchase.class);
+ verifyPurchaseWithVertexTransactionType(purchase);
+
+ // test deseralization
+ final Purchase purchaseExpected = xmlMapper.readValue(purchaseData, Purchase.class);
+ assertEquals(purchase, purchaseExpected);
+ }
+
+ public void verifyPurchaseWithVertexTransactionType(final Purchase purchase) {
+ assertEquals(purchase.getVertexTransactionType(), "rental");
+ assertEquals(purchase.getCurrency(), "USD");
+ assertEquals(purchase.getCollectionMethod(), "automatic");
+ }
+
+ @Test(groups = "fast")
+ public void testSerializationToXmlWithVertexTransactionType() throws Exception {
+ // Create purchase object programmatically and verify it serializes correctly to XML
+ final Purchase purchase = new Purchase();
+ purchase.setCurrency("USD");
+ purchase.setCollectionMethod("automatic");
+ purchase.setVertexTransactionType("lease");
+
+ final Account account = new Account();
+ account.setAccountCode("test-account");
+ purchase.setAccount(account);
+
+ // Serialize to XML string
+ final String xml = xmlMapper.writeValueAsString(purchase);
+
+ // Verify the XML contains the vertex_transaction_type element
+ assert xml.contains("lease") :
+ "Serialized XML should contain vertex_transaction_type element";
+ assert xml.contains("automatic");
+ assert xml.contains("USD");
+ }
+
+ @Test(groups = "fast")
+ public void testVertexTransactionTypeAllValidValues() throws Exception {
+ // Test all valid values: sale, rental, lease
+ final String[] validValues = {"sale", "rental", "lease"};
+
+ for (String value : validValues) {
+ final Purchase purchase = new Purchase();
+ purchase.setVertexTransactionType(value);
+ assertEquals(purchase.getVertexTransactionType(), value,
+ "Should correctly set and get value: " + value);
+
+ // Verify serialization/deserialization round-trip
+ final String xml = xmlMapper.writeValueAsString(purchase);
+ final Purchase deserializedPurchase = xmlMapper.readValue(xml, Purchase.class);
+ assertEquals(deserializedPurchase.getVertexTransactionType(), value,
+ "Should correctly deserialize value: " + value);
+ }
+ }
@Test(groups = "fast")
public void testHashCodeAndEquality() throws Exception {