Skip to content

Commit

Permalink
data #228 - Credit cards can be created with security parameters.
Browse files Browse the repository at this point in the history
  • Loading branch information
braintreeps committed May 14, 2013
1 parent d6f2875 commit f5db2e6
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/main/java/com/braintreegateway/CreditCardRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public class CreditCardRequest extends Request {
private String cardholderName;
private String customerId;
private String cvv;
private String deviceSessionId;
private String expirationDate;
private String expirationMonth;
private String expirationYear;
Expand Down Expand Up @@ -51,6 +52,11 @@ public CreditCardRequest cvv(String cvv) {
return this;
}

public CreditCardRequest deviceSessionId(String deviceSessionId) {
this.deviceSessionId = deviceSessionId;
return this;
}

public CustomerRequest done() {
return parent;
}
Expand Down Expand Up @@ -138,6 +144,7 @@ protected RequestBuilder buildRequest(String root) {
addElement("cardholderName", cardholderName).
addElement("cvv", cvv).
addElement("number", number).
addElement("deviceSessionId", deviceSessionId).
addElement("expirationDate", expirationDate).
addElement("expirationMonth", expirationMonth).
addElement("expirationYear", expirationYear).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,20 @@ public void createWithXmlCharacters() {
assertEquals("Special Chars <>&\"'", card.getCardholderName());
}

@Test
public void createWithSecurityParams() {
Customer customer = gateway.customer().create(new CustomerRequest()).getTarget();
CreditCardRequest request = new CreditCardRequest().
customerId(customer.getId()).
cardholderName("Special Chars").
number("5105105105105100").
expirationDate("05/12").
deviceSessionId("abc123");
Result<CreditCard> result = gateway.creditCard().create(request);

assertTrue(result.isSuccess());
}

@Test
public void createWithAddress() {
Customer customer = gateway.customer().create(new CustomerRequest()).getTarget();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.braintreegateway.integrationtest;

import com.braintreegateway.CreditCardRequest;
import com.braintreegateway.testhelpers.TestHelper;
import org.junit.Test;

import static org.junit.Assert.assertEquals;
Expand All @@ -12,6 +13,13 @@ public void toXmlEscapesXmlChars() {
cardholderName("Special Xml Chars <>&\"'");
assertEquals("<creditCard><cardholderName>Special Xml Chars &lt;&gt;&amp;&quot;&apos;</cardholderName></creditCard>", request.toXML());
}
@Test
public void toXmlIncludesSecurityParams() {
CreditCardRequest request = new CreditCardRequest().
deviceSessionId("dsid_abc123");

TestHelper.assertIncludes("dsid_abc123", request.toXML());
}

@Test
public void toQueryString() {
Expand Down

0 comments on commit f5db2e6

Please sign in to comment.