forked from AuthorizeNet/sdk-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTransaction.java
More file actions
80 lines (66 loc) · 2.82 KB
/
Transaction.java
File metadata and controls
80 lines (66 loc) · 2.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package net.authorize;
import java.io.Serializable;
import java.math.BigDecimal;
import net.authorize.util.XmlUtility;
import org.w3c.dom.Node;
public abstract class Transaction implements Serializable{
private static final long serialVersionUID = 1L;
public static final int MAX_AUTH_CODE_LENGTH = 6;
public static final String VERSION = "3.1";
public static String TRANSACTION_FIELD_DELIMITER = "|";
public static String ENCAP_CHAR_DELIMITER = "";
public static final String BRACKET_PIPE_DELIMITER = "<|>";
public static final String TRUE = "TRUE";
public static final String FALSE = "FALSE";
public static final String ZERO_STRING = "0.00";
public static final BigDecimal ZERO_AMOUNT = new BigDecimal(0.00);
public static final String EMPTY_STRING = "";
public static final int CURRENCY_DECIMAL_PLACES = 2;
public static final int QUANTITY_DECIMAL_PLACES = 4;
/**
* Convenience method for overriding the transaction field delimited.
*
* Character that will be used to separate fields in the transaction response.
* The system will use the character passed in this field or the value stored
* in the Merchant Interface if no value is passed.
*
* @param transactionFieldDelimiter
*/
public static void setTransactionFieldDelimiter(String transactionFieldDelimiter) {
Transaction.TRANSACTION_FIELD_DELIMITER = transactionFieldDelimiter;
}
public String toNVPString() { return ""; }
public String toXMLString() { return ""; }
/**
* Convenience method for overriding the encap char delimiter.
*
* Character that will be used to encapsulate the fields in the transaction response.
* The system will use the character passed in this field or the value stored in
* the Merchant Interface if no value is passed.
*/
public static void setEncapCharDelimiter(String encapCharDelimiter) {
Transaction.ENCAP_CHAR_DELIMITER = encapCharDelimiter;
}
/**
* Try to encode string value as per proper xml requirements
* Will default to original value (without encoding) if there are any exceptions
* @param document the document to create text node to
* @param value string value to encode
* @return Node with encoded text value appropriate for XML
*/
public static Node getEncodedString(net.authorize.util.BasicXmlDocument document, String value) {
String encodedValue = XmlUtility.escapeStringForXml(value);
Node node = document.getDocument().createTextNode(encodedValue);
return node;
}
/**
* Try to decode string value from xml node as per proper xml requirements
* @param node which is a text element
* @return decoded String value
*/
public static String getDecodedString(Node node) {
String value = node.getTextContent();
String decodedValue = XmlUtility.descapeStringForXml(value);
return decodedValue;
}
}