public class WorldpayCSE
extends java.lang.Object
WPCardData
payload.
Example usage:
WPCardData cardData = new WPCardData();
cardData.setCardHolderName("John Smith");
cardData.setCardNumber("444433332221111");
cardData.setCvc("123");
cardData.setExpiryMonth("11");
cardData.setExpiryYear("2020");
String publicKey = "1#10001#121ad121...";// check setPublicKey(String)
for more details
String encryptedData = "";
WorldpayCSE worldPayCSE = new WorldpayCSE();
try {
worldPayCSE.setPublicKey(publicKey);
encryptedData = worldPayCSE.encrypt(cardData);
} catch (WPCSEException e) {
//show error message
}
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
A_256_GCM |
static java.lang.String |
API_VERSION |
static java.lang.String |
CHANNEL |
static java.lang.String |
LIB_VERSION |
static java.lang.String |
RSA_1_5 |
Constructor and Description |
---|
WorldpayCSE()
Creates a WorldpayCSE object.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
encrypt(WPCardData cardData)
Validates and encrypts the supplied card data.
|
WPPublicKey |
getPublicKey()
Returns the current public(RSA) key in string format
|
static boolean |
isValidPublicKey(java.lang.String stringKey)
Validates in a more convenient way if the public key is valid.
|
void |
setPublicKey(java.lang.String publicKey)
Sets the public(RSA) key that will be used for any future
encrypt(WPCardData) calls. |
void |
setPublicKey(WPPublicKey publicKey)
Sets the public(RSA) key that will be used for any future
encrypt(WPCardData) calls. |
static java.util.Set<java.lang.Integer> |
validate(WPCardData data)
Validates the payment card field values and returns the list of error codes.
|
public static final java.lang.String RSA_1_5
public static final java.lang.String A_256_GCM
public static final java.lang.String API_VERSION
public static final java.lang.String LIB_VERSION
public static final java.lang.String CHANNEL
public void setPublicKey(java.lang.String publicKey) throws WPCSEInvalidPublicKey
encrypt(WPCardData)
calls.
sequence#exponent#modulsExample:
"1#10001#bf49edcaba456c6357e4ace484c3fba212543e78bf 72a8c2238caaa1c7ed20262956caa61d74840598d9b0707bc8 2e66f18c8b369c77ae6be0429c93323bb7511fc73d9c7f6988 72a8384370cd77c7516caa25a195d48701e3e0462d61200983 ba26cc4a20bb059d5beda09270ea6dcf15dd92084c4d5867b6 0986151717a8022e4054462ee74ab8533dda77cee227a49fda f58eaeb95df90cb8c05ee81f58bec95339b6262633aef216f3 ae503e8be0650350c48859eef406e63d4399994b147e45aaa1 4cf9936ac6fdd7d4ec5e66b527d041750ba63a8296b3e6e774 a02ee6025c6ee66ef54c3688e4844be8951a8435e6b6e8d676 3d9ee5f16521577e159d"
publicKey
- the public key in Worldpay text format.WPCSEInvalidPublicKey
- if the public key does not adhere to the Worldpay format.public WPPublicKey getPublicKey()
WPPublicKey
instancepublic void setPublicKey(WPPublicKey publicKey)
encrypt(WPCardData)
calls.publicKey
- a WPPublicKey
instancepublic static boolean isValidPublicKey(java.lang.String stringKey)
setPublicKey(String)
method and you do not want to handle WPCSEInvalidPublicKey exception.stringKey
- the public key in plain string formatpublic java.lang.String encrypt(WPCardData cardData) throws WPCSEException
WPCSEInvalidCardData
exception that contains all error codes.cardData
- An object containing information about the card details to encrypt.WPCSEException
- could be an instance of WPCSEInvalidCardData
or other generic instance.public static java.util.Set<java.lang.Integer> validate(WPCardData data)
data
- the WPCardData
objectWPValidationErrorCodes