676 lines
23 KiB
Java
676 lines
23 KiB
Java
package it.acxent.bank.sella;
|
|
|
|
import java.io.BufferedReader;
|
|
import java.io.IOException;
|
|
import java.io.InputStreamReader;
|
|
import java.net.MalformedURLException;
|
|
import java.net.URL;
|
|
import java.net.URLConnection;
|
|
import java.net.URLEncoder;
|
|
import java.net.UnknownServiceException;
|
|
|
|
public class GestPayCrypt20 {
|
|
private String ShopLogin;
|
|
|
|
private String Currency;
|
|
|
|
private String Amount;
|
|
|
|
private String ShopTransactionID;
|
|
|
|
private String BuyerName;
|
|
|
|
private String BuyerEmail;
|
|
|
|
private String Language;
|
|
|
|
private String CustomInfo;
|
|
|
|
private String AuthorizationCode;
|
|
|
|
private String ErrorCode;
|
|
|
|
private String ErrorDescription;
|
|
|
|
private String BankTransactionID;
|
|
|
|
private String AlertCode;
|
|
|
|
private String AlertDescription;
|
|
|
|
private String EncryptedString;
|
|
|
|
private String ToBeEncript;
|
|
|
|
private String Decripted;
|
|
|
|
private String TransactionResult;
|
|
|
|
private String ProtocolAuthServer = "";
|
|
|
|
private String DomainName = "";
|
|
|
|
private String separator;
|
|
|
|
private String errDescription;
|
|
|
|
private String errNumber;
|
|
|
|
private String Version = "2.0";
|
|
|
|
private String Min = "";
|
|
|
|
private String CVV = "";
|
|
|
|
private String country = "";
|
|
|
|
private String vbvrisp = "";
|
|
|
|
private String vbv = "";
|
|
|
|
public GestPayCrypt20() {
|
|
this.ShopLogin = "";
|
|
this.Currency = "";
|
|
this.Amount = "";
|
|
this.ShopTransactionID = "";
|
|
this.BuyerName = "";
|
|
this.BuyerEmail = "";
|
|
this.Language = "";
|
|
this.CustomInfo = "";
|
|
this.AuthorizationCode = "";
|
|
this.ErrorCode = "";
|
|
this.ErrorDescription = "";
|
|
this.BankTransactionID = "";
|
|
this.AlertCode = "";
|
|
this.AlertDescription = "";
|
|
this.EncryptedString = "";
|
|
this.ToBeEncript = "";
|
|
this.Decripted = "";
|
|
this.ProtocolAuthServer = "http://";
|
|
this.DomainName = "ecomm.sella.it/CryptHTTP";
|
|
this.separator = "*P1*";
|
|
this.errDescription = "";
|
|
this.errNumber = "0";
|
|
this.Min = "";
|
|
this.CVV = "";
|
|
this.country = "";
|
|
this.vbvrisp = "";
|
|
this.vbv = "";
|
|
}
|
|
|
|
public void SetShopLogin(String xstr) {
|
|
this.ShopLogin = xstr;
|
|
}
|
|
|
|
public void SetCurrency(String xstr) {
|
|
this.Currency = xstr;
|
|
}
|
|
|
|
public void SetAmount(String xstr) {
|
|
this.Amount = xstr;
|
|
}
|
|
|
|
public void SetShopTransactionID(String xstr) {
|
|
this.ShopTransactionID = URLEncoder.encode(xstr.trim());
|
|
}
|
|
|
|
public void SetMIN(String xstr) {
|
|
this.Min = xstr;
|
|
}
|
|
|
|
public void SetCVV(String xstr) {
|
|
this.CVV = xstr;
|
|
}
|
|
|
|
public void SetBuyerName(String xstr) {
|
|
this.BuyerName = URLEncoder.encode(xstr.trim());
|
|
}
|
|
|
|
public void SetBuyerEmail(String xstr) {
|
|
this.BuyerEmail = xstr.trim();
|
|
}
|
|
|
|
public void SetLanguage(String xstr) {
|
|
this.Language = xstr.trim();
|
|
}
|
|
|
|
public void SetCustomInfo(String xstr) {
|
|
this.CustomInfo = URLEncoder.encode(xstr.trim());
|
|
}
|
|
|
|
public void SetEncryptedString(String xstr) {
|
|
this.EncryptedString = xstr;
|
|
}
|
|
|
|
public String GetShopLogin() {
|
|
return this.ShopLogin;
|
|
}
|
|
|
|
public String GetCurrency() {
|
|
return this.Currency;
|
|
}
|
|
|
|
public String GetAmount() {
|
|
return this.Amount;
|
|
}
|
|
|
|
public String GetCountry() {
|
|
return this.country;
|
|
}
|
|
|
|
public String GetVBV() {
|
|
return this.vbv;
|
|
}
|
|
|
|
public String GetVBVrisp() {
|
|
return this.vbvrisp;
|
|
}
|
|
|
|
public String GetShopTransactionID() {
|
|
String app = "";
|
|
try {
|
|
app = URLDecode(this.ShopTransactionID);
|
|
} catch (Exception e) {}
|
|
return app;
|
|
}
|
|
|
|
public String GetBuyerName() {
|
|
String appBuyername = "";
|
|
try {
|
|
appBuyername = URLDecode(this.BuyerName);
|
|
} catch (Exception ex) {
|
|
appBuyername = "errore";
|
|
}
|
|
return appBuyername;
|
|
}
|
|
|
|
public String GetBuyerEmail() {
|
|
return this.BuyerEmail;
|
|
}
|
|
|
|
public String GetCustomInfo() {
|
|
String appCustom = "";
|
|
try {
|
|
appCustom = URLDecode(this.CustomInfo);
|
|
} catch (Exception e) {}
|
|
return appCustom;
|
|
}
|
|
|
|
public String GetAuthorizationCode() {
|
|
return this.AuthorizationCode;
|
|
}
|
|
|
|
public String GetErrorCode() {
|
|
return this.ErrorCode;
|
|
}
|
|
|
|
public String GetErrorDescription() {
|
|
return this.ErrorDescription;
|
|
}
|
|
|
|
public String GetBankTransactionID() {
|
|
return this.BankTransactionID;
|
|
}
|
|
|
|
public String GetTransactionResult() {
|
|
return this.TransactionResult;
|
|
}
|
|
|
|
public String GetAlertCode() {
|
|
return this.AlertCode;
|
|
}
|
|
|
|
public String GetAlertDescription() {
|
|
return this.AlertDescription;
|
|
}
|
|
|
|
public String GetEncryptedString() {
|
|
return this.EncryptedString;
|
|
}
|
|
|
|
public boolean Encrypt() {
|
|
String sErr = "";
|
|
this.ErrorCode = "0";
|
|
this.ErrorDescription = "";
|
|
try {
|
|
if (this.ShopLogin.length() <= 0) {
|
|
this.ErrorCode = "546";
|
|
this.ErrorDescription = "IDshop not valid";
|
|
return false;
|
|
}
|
|
if (this.Currency.length() <= 0) {
|
|
this.ErrorCode = "552";
|
|
this.ErrorDescription = "Currency not valid";
|
|
return false;
|
|
}
|
|
if (this.Amount.length() <= 0) {
|
|
this.ErrorCode = "553";
|
|
this.ErrorDescription = "Amount not valid";
|
|
return false;
|
|
}
|
|
if (this.ShopTransactionID.length() <= 0) {
|
|
this.ErrorCode = "551";
|
|
this.ErrorDescription = "Shop Transaction ID not valid";
|
|
return false;
|
|
}
|
|
this.ToBeEncript = "";
|
|
if (this.CVV.length() > 0)
|
|
this.ToBeEncript = this.ToBeEncript + this.ToBeEncript + "PAY1_CVV=" + this.separator;
|
|
if (this.Min.length() > 0)
|
|
this.ToBeEncript = this.ToBeEncript + this.ToBeEncript + "PAY1_MIN=" + this.separator;
|
|
if (this.Currency.length() > 0)
|
|
this.ToBeEncript = this.ToBeEncript + this.ToBeEncript + "PAY1_UICCODE=" + this.separator;
|
|
if (this.Amount.length() > 0)
|
|
this.ToBeEncript = this.ToBeEncript + this.ToBeEncript + "PAY1_AMOUNT=" + this.separator;
|
|
if (this.ShopTransactionID.length() > 0)
|
|
this.ToBeEncript = this.ToBeEncript + this.ToBeEncript + "PAY1_SHOPTRANSACTIONID=" + this.separator;
|
|
if (this.BuyerName.length() > 0)
|
|
this.ToBeEncript = this.ToBeEncript + this.ToBeEncript + "PAY1_CHNAME=" + this.separator;
|
|
if (this.BuyerEmail.length() > 0)
|
|
this.ToBeEncript = this.ToBeEncript + this.ToBeEncript + "PAY1_CHEMAIL=" + this.separator;
|
|
if (this.Language.length() > 0)
|
|
this.ToBeEncript = this.ToBeEncript + this.ToBeEncript + "PAY1_IDLANGUAGE=" + this.separator;
|
|
if (this.CustomInfo.length() > 0)
|
|
this.ToBeEncript = this.ToBeEncript + this.ToBeEncript + this.separator;
|
|
String urlString = this.ProtocolAuthServer + this.ProtocolAuthServer + "/Encrypt.asp?a=" + this.DomainName + "&b=" + this.ShopLogin + "&c=" + this.ToBeEncript.substring(4, this.ToBeEncript.length());
|
|
URL url = new URL(urlString);
|
|
URLConnection connection = url.openConnection();
|
|
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
|
int nStart = 0;
|
|
int nEnd = 0;
|
|
String line = "";
|
|
while (line != null) {
|
|
line = in.readLine();
|
|
if (line != null) {
|
|
nStart = line.indexOf("#cryptstring#");
|
|
nEnd = line.lastIndexOf("#/cryptstring#");
|
|
if (((nStart != -1) ? true : false) & ((nEnd > nStart + 14) ? true : false))
|
|
this.EncryptedString = line.substring(nStart + 13, nEnd);
|
|
nStart = line.indexOf("#error#");
|
|
nEnd = line.lastIndexOf("#/error#");
|
|
if (((nStart != -1) ? true : false) & ((nEnd > nStart + 8) ? true : false)) {
|
|
sErr = line.substring(nStart + 7, nEnd);
|
|
int intsep = sErr.indexOf("-");
|
|
this.ErrorCode = sErr.substring(0, intsep);
|
|
this.ErrorDescription = sErr.substring(intsep + 1, sErr.length());
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
in.close();
|
|
return true;
|
|
} catch (MalformedURLException ex) {
|
|
this.ErrorCode = "9999";
|
|
this.ErrorDescription = "Bad URL";
|
|
return false;
|
|
} catch (UnknownServiceException ex) {
|
|
this.ErrorCode = "9999";
|
|
this.ErrorDescription = "ServiceException occurred.";
|
|
return false;
|
|
} catch (IOException ex) {
|
|
this.ErrorCode = "9999";
|
|
this.ErrorDescription = "Bad URL Request";
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public boolean Decrypt() {
|
|
this.ErrorCode = "0";
|
|
this.ErrorDescription = "";
|
|
String strdaelim = "";
|
|
if (this.ShopLogin.length() <= 0) {
|
|
this.ErrorCode = "546";
|
|
this.ErrorDescription = "IDshop not valid";
|
|
return false;
|
|
}
|
|
if (this.EncryptedString.length() <= 0) {
|
|
this.ErrorCode = "1009";
|
|
this.ErrorDescription = "String to Decrypt not valid";
|
|
return false;
|
|
}
|
|
try {
|
|
String urlString = this.ProtocolAuthServer + this.ProtocolAuthServer + "/Decrypt.asp?a=" + this.DomainName + "&b=" + this.ShopLogin + "&c=" + this.EncryptedString;
|
|
URL url = new URL(urlString);
|
|
URLConnection connection = url.openConnection();
|
|
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
|
int nStart = 0;
|
|
int nEnd = 0;
|
|
String line = "";
|
|
while (line != null) {
|
|
line = in.readLine();
|
|
if (line != null) {
|
|
nStart = line.indexOf("#decryptstring#");
|
|
nEnd = line.lastIndexOf("#/decryptstring#");
|
|
if (((nStart != -1) ? true : false) & ((nEnd > nStart + 16) ? true : false))
|
|
this.Decripted = line.substring(nStart + 15, nEnd);
|
|
nStart = line.indexOf("#error#");
|
|
nEnd = line.lastIndexOf("#/error#");
|
|
if (((nStart != -1) ? true : false) & ((nEnd > nStart + 8) ? true : false)) {
|
|
String sErr = line.substring(nStart + 7, nEnd);
|
|
int intsep = sErr.indexOf("-");
|
|
this.ErrorCode = sErr.substring(0, intsep);
|
|
this.ErrorDescription = sErr.substring(intsep + 1, sErr.length());
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
in.close();
|
|
if (this.Decripted.trim() == "") {
|
|
this.ErrorCode = "9999";
|
|
this.ErrorDescription = "Void String";
|
|
return false;
|
|
}
|
|
if (!Parsing(this.Decripted))
|
|
return false;
|
|
return true;
|
|
} catch (MalformedURLException ex) {
|
|
this.ErrorCode = "9999";
|
|
this.ErrorDescription = "Bad URL";
|
|
return false;
|
|
} catch (UnknownServiceException ex) {
|
|
this.ErrorCode = "9999";
|
|
this.ErrorDescription = "Service Exception occurred.";
|
|
return false;
|
|
} catch (IOException ex) {
|
|
this.ErrorCode = "9999";
|
|
this.ErrorDescription = "Bad URL Request";
|
|
return false;
|
|
}
|
|
}
|
|
|
|
private boolean Parsing(String StringToBeParsed) {
|
|
int nStart = 0;
|
|
int nEnd = 0;
|
|
this.ErrorCode = "";
|
|
this.ErrorDescription = "";
|
|
try {
|
|
nStart = StringToBeParsed.indexOf("PAY1_UICCODE");
|
|
if (nStart != -1) {
|
|
nEnd = StringToBeParsed.indexOf(this.separator, nStart);
|
|
if (nEnd == -1) {
|
|
nEnd = StringToBeParsed.length();
|
|
this.Currency = StringToBeParsed.substring(nStart + 13, nEnd);
|
|
if (nStart >= 4) {
|
|
StringToBeParsed = StringToBeParsed.substring(0, nStart - 4);
|
|
} else {
|
|
StringToBeParsed = StringToBeParsed.substring(0, nStart);
|
|
}
|
|
} else {
|
|
this.Currency = StringToBeParsed.substring(nStart + 13, nEnd);
|
|
StringToBeParsed = StringToBeParsed.substring(0, nStart) + StringToBeParsed.substring(0, nStart);
|
|
}
|
|
}
|
|
nStart = StringToBeParsed.indexOf("PAY1_AMOUNT");
|
|
if (nStart != -1) {
|
|
nEnd = StringToBeParsed.indexOf(this.separator, nStart);
|
|
if (nEnd == -1) {
|
|
nEnd = StringToBeParsed.length();
|
|
this.Amount = StringToBeParsed.substring(nStart + 12, nEnd);
|
|
if (nStart >= 4) {
|
|
StringToBeParsed = StringToBeParsed.substring(0, nStart - 4);
|
|
} else {
|
|
StringToBeParsed = StringToBeParsed.substring(0, nStart);
|
|
}
|
|
} else {
|
|
this.Amount = StringToBeParsed.substring(nStart + 12, nEnd);
|
|
StringToBeParsed = StringToBeParsed.substring(0, nStart) + StringToBeParsed.substring(0, nStart);
|
|
}
|
|
}
|
|
nStart = StringToBeParsed.indexOf("PAY1_SHOPTRANSACTIONID");
|
|
if (nStart != -1) {
|
|
nEnd = StringToBeParsed.indexOf(this.separator, nStart);
|
|
if (nEnd == -1) {
|
|
nEnd = StringToBeParsed.length();
|
|
this.ShopTransactionID = StringToBeParsed.substring(nStart + 23, nEnd);
|
|
if (nStart >= 4) {
|
|
StringToBeParsed = StringToBeParsed.substring(0, nStart - 4);
|
|
} else {
|
|
StringToBeParsed = StringToBeParsed.substring(0, nStart);
|
|
}
|
|
} else {
|
|
this.ShopTransactionID = StringToBeParsed.substring(nStart + 23, nEnd);
|
|
StringToBeParsed = StringToBeParsed.substring(0, nStart) + StringToBeParsed.substring(0, nStart);
|
|
}
|
|
}
|
|
nStart = StringToBeParsed.indexOf("PAY1_CHNAME");
|
|
if (nStart != -1) {
|
|
nEnd = StringToBeParsed.indexOf(this.separator, nStart);
|
|
if (nEnd == -1) {
|
|
nEnd = StringToBeParsed.length();
|
|
this.BuyerName = StringToBeParsed.substring(nStart + 12, nEnd);
|
|
if (nStart >= 4) {
|
|
StringToBeParsed = StringToBeParsed.substring(0, nStart - 4);
|
|
} else {
|
|
StringToBeParsed = StringToBeParsed.substring(0, nStart);
|
|
}
|
|
} else {
|
|
this.BuyerName = StringToBeParsed.substring(nStart + 12, nEnd);
|
|
StringToBeParsed = StringToBeParsed.substring(0, nStart) + StringToBeParsed.substring(0, nStart);
|
|
}
|
|
}
|
|
nStart = StringToBeParsed.indexOf("PAY1_CHEMAIL");
|
|
if (nStart != -1) {
|
|
nEnd = StringToBeParsed.indexOf(this.separator, nStart);
|
|
if (nEnd == -1) {
|
|
nEnd = StringToBeParsed.length();
|
|
this.BuyerEmail = StringToBeParsed.substring(nStart + 13, nEnd);
|
|
if (nStart >= 4) {
|
|
StringToBeParsed = StringToBeParsed.substring(0, nStart - 4);
|
|
} else {
|
|
StringToBeParsed = StringToBeParsed.substring(0, nStart);
|
|
}
|
|
} else {
|
|
this.BuyerEmail = StringToBeParsed.substring(nStart + 13, nEnd);
|
|
StringToBeParsed = StringToBeParsed.substring(0, nStart) + StringToBeParsed.substring(0, nStart);
|
|
}
|
|
}
|
|
nStart = StringToBeParsed.indexOf("PAY1_AUTHORIZATIONCODE");
|
|
if (nStart != -1) {
|
|
nEnd = StringToBeParsed.indexOf(this.separator, nStart);
|
|
if (nEnd == -1) {
|
|
nEnd = StringToBeParsed.length();
|
|
this.AuthorizationCode = StringToBeParsed.substring(nStart + 23, nEnd);
|
|
if (nStart >= 4) {
|
|
StringToBeParsed = StringToBeParsed.substring(0, nStart - 4);
|
|
} else {
|
|
StringToBeParsed = StringToBeParsed.substring(0, nStart);
|
|
}
|
|
} else {
|
|
this.AuthorizationCode = StringToBeParsed.substring(nStart + 23, nEnd);
|
|
StringToBeParsed = StringToBeParsed.substring(0, nStart) + StringToBeParsed.substring(0, nStart);
|
|
}
|
|
}
|
|
nStart = StringToBeParsed.indexOf("PAY1_ERRORCODE");
|
|
if (nStart != -1) {
|
|
nEnd = StringToBeParsed.indexOf(this.separator, nStart);
|
|
if (nEnd == -1) {
|
|
nEnd = StringToBeParsed.length();
|
|
this.ErrorCode = StringToBeParsed.substring(nStart + 15, nEnd);
|
|
if (nStart >= 4) {
|
|
StringToBeParsed = StringToBeParsed.substring(0, nStart - 4);
|
|
} else {
|
|
StringToBeParsed = StringToBeParsed.substring(0, nStart);
|
|
}
|
|
} else {
|
|
this.ErrorCode = StringToBeParsed.substring(nStart + 15, nEnd);
|
|
StringToBeParsed = StringToBeParsed.substring(0, nStart) + StringToBeParsed.substring(0, nStart);
|
|
}
|
|
}
|
|
nStart = StringToBeParsed.indexOf("PAY1_ERRORDESCRIPTION");
|
|
if (nStart != -1) {
|
|
nEnd = StringToBeParsed.indexOf(this.separator, nStart);
|
|
if (nEnd == -1) {
|
|
nEnd = StringToBeParsed.length();
|
|
this.ErrorDescription = StringToBeParsed.substring(nStart + 22, nEnd);
|
|
if (nStart >= 4) {
|
|
StringToBeParsed = StringToBeParsed.substring(0, nStart - 4);
|
|
} else {
|
|
StringToBeParsed = StringToBeParsed.substring(0, nStart);
|
|
}
|
|
} else {
|
|
this.ErrorDescription = StringToBeParsed.substring(nStart + 22, nEnd);
|
|
StringToBeParsed = StringToBeParsed.substring(0, nStart) + StringToBeParsed.substring(0, nStart);
|
|
}
|
|
}
|
|
nStart = StringToBeParsed.indexOf("PAY1_BANKTRANSACTIONID");
|
|
if (nStart != -1) {
|
|
nEnd = StringToBeParsed.indexOf(this.separator, nStart);
|
|
if (nEnd == -1) {
|
|
nEnd = StringToBeParsed.length();
|
|
this.BankTransactionID = StringToBeParsed.substring(nStart + 23, nEnd);
|
|
if (nStart >= 4) {
|
|
StringToBeParsed = StringToBeParsed.substring(0, nStart - 4);
|
|
} else {
|
|
StringToBeParsed = StringToBeParsed.substring(0, nStart);
|
|
}
|
|
} else {
|
|
this.BankTransactionID = StringToBeParsed.substring(nStart + 23, nEnd);
|
|
StringToBeParsed = StringToBeParsed.substring(0, nStart) + StringToBeParsed.substring(0, nStart);
|
|
}
|
|
}
|
|
nStart = StringToBeParsed.indexOf("PAY1_ALERTCODE");
|
|
if (nStart != -1) {
|
|
nEnd = StringToBeParsed.indexOf(this.separator, nStart);
|
|
if (nEnd == -1) {
|
|
nEnd = StringToBeParsed.length();
|
|
this.AlertCode = StringToBeParsed.substring(nStart + 15, nEnd);
|
|
if (nStart >= 4) {
|
|
StringToBeParsed = StringToBeParsed.substring(0, nStart - 4);
|
|
} else {
|
|
StringToBeParsed = StringToBeParsed.substring(0, nStart);
|
|
}
|
|
} else {
|
|
this.AlertCode = StringToBeParsed.substring(nStart + 15, nEnd);
|
|
StringToBeParsed = StringToBeParsed.substring(0, nStart) + StringToBeParsed.substring(0, nStart);
|
|
}
|
|
}
|
|
nStart = StringToBeParsed.indexOf("PAY1_ALERTDESCRIPTION");
|
|
if (nStart != -1) {
|
|
nEnd = StringToBeParsed.indexOf(this.separator, nStart);
|
|
if (nEnd == -1) {
|
|
nEnd = StringToBeParsed.length();
|
|
this.AlertDescription = StringToBeParsed.substring(nStart + 22, nEnd);
|
|
if (nStart >= 4) {
|
|
StringToBeParsed = StringToBeParsed.substring(0, nStart - 4);
|
|
} else {
|
|
StringToBeParsed = StringToBeParsed.substring(0, nStart);
|
|
}
|
|
} else {
|
|
this.AlertDescription = StringToBeParsed.substring(nStart + 22, nEnd);
|
|
StringToBeParsed = StringToBeParsed.substring(0, nStart) + StringToBeParsed.substring(0, nStart);
|
|
}
|
|
}
|
|
nStart = StringToBeParsed.indexOf("PAY1_COUNTRY");
|
|
if (nStart != -1) {
|
|
nEnd = StringToBeParsed.indexOf(this.separator, nStart);
|
|
if (nEnd == -1) {
|
|
nEnd = StringToBeParsed.length();
|
|
this.country = StringToBeParsed.substring(nStart + 13, nEnd);
|
|
if (nStart >= 4) {
|
|
StringToBeParsed = StringToBeParsed.substring(0, nStart - 4);
|
|
} else {
|
|
StringToBeParsed = StringToBeParsed.substring(0, nStart);
|
|
}
|
|
} else {
|
|
this.country = StringToBeParsed.substring(nStart + 13, nEnd);
|
|
StringToBeParsed = StringToBeParsed.substring(0, nStart) + StringToBeParsed.substring(0, nStart);
|
|
}
|
|
}
|
|
nStart = StringToBeParsed.indexOf("PAY1_VBVRISP");
|
|
if (nStart != -1) {
|
|
nEnd = StringToBeParsed.indexOf(this.separator, nStart);
|
|
if (nEnd == -1) {
|
|
nEnd = StringToBeParsed.length();
|
|
this.vbvrisp = StringToBeParsed.substring(nStart + 13, nEnd);
|
|
if (nStart >= 4) {
|
|
StringToBeParsed = StringToBeParsed.substring(0, nStart - 4);
|
|
} else {
|
|
StringToBeParsed = StringToBeParsed.substring(0, nStart);
|
|
}
|
|
} else {
|
|
this.vbvrisp = StringToBeParsed.substring(nStart + 13, nEnd);
|
|
StringToBeParsed = StringToBeParsed.substring(0, nStart) + StringToBeParsed.substring(0, nStart);
|
|
}
|
|
}
|
|
nStart = StringToBeParsed.indexOf("PAY1_VBV");
|
|
if (nStart != -1) {
|
|
nEnd = StringToBeParsed.indexOf(this.separator, nStart);
|
|
if (nEnd == -1) {
|
|
nEnd = StringToBeParsed.length();
|
|
this.vbv = StringToBeParsed.substring(nStart + 9, nEnd);
|
|
if (nStart >= 4) {
|
|
StringToBeParsed = StringToBeParsed.substring(0, nStart - 4);
|
|
} else {
|
|
StringToBeParsed = StringToBeParsed.substring(0, nStart);
|
|
}
|
|
} else {
|
|
this.vbv = StringToBeParsed.substring(nStart + 9, nEnd);
|
|
StringToBeParsed = StringToBeParsed.substring(0, nStart) + StringToBeParsed.substring(0, nStart);
|
|
}
|
|
}
|
|
nStart = StringToBeParsed.indexOf("PAY1_IDLANGUAGE");
|
|
if (nStart != -1) {
|
|
nEnd = StringToBeParsed.indexOf(this.separator, nStart);
|
|
if (nEnd == -1) {
|
|
nEnd = StringToBeParsed.length();
|
|
this.Language = StringToBeParsed.substring(nStart + 16, nEnd);
|
|
if (nStart >= 4) {
|
|
StringToBeParsed = StringToBeParsed.substring(0, nStart - 4);
|
|
} else {
|
|
StringToBeParsed = StringToBeParsed.substring(0, nStart);
|
|
}
|
|
} else {
|
|
this.Language = StringToBeParsed.substring(nStart + 16, nEnd);
|
|
StringToBeParsed = StringToBeParsed.substring(0, nStart) + StringToBeParsed.substring(0, nStart);
|
|
}
|
|
}
|
|
nStart = StringToBeParsed.indexOf("PAY1_TRANSACTIONRESULT");
|
|
if (nStart != -1) {
|
|
nEnd = StringToBeParsed.indexOf(this.separator, nStart);
|
|
if (nEnd == -1) {
|
|
nEnd = StringToBeParsed.length();
|
|
this.TransactionResult = StringToBeParsed.substring(nStart + 23, nEnd);
|
|
if (nStart >= 4) {
|
|
StringToBeParsed = StringToBeParsed.substring(0, nStart - 4);
|
|
} else {
|
|
StringToBeParsed = StringToBeParsed.substring(0, nStart);
|
|
}
|
|
} else {
|
|
this.TransactionResult = StringToBeParsed.substring(nStart + 23, nEnd);
|
|
StringToBeParsed = StringToBeParsed.substring(0, nStart) + StringToBeParsed.substring(0, nStart);
|
|
}
|
|
}
|
|
this.CustomInfo = StringToBeParsed.trim();
|
|
} catch (Exception e) {
|
|
this.ErrorCode = "9999";
|
|
this.ErrorDescription = "Error parsing String";
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public String URLDecode(String str) throws Exception {
|
|
if (str == null)
|
|
return null;
|
|
char[] res = new char[str.length()];
|
|
int didx = 0;
|
|
for (int sidx = 0; sidx < str.length(); sidx++) {
|
|
char ch = str.charAt(sidx);
|
|
if (ch == '+') {
|
|
res[didx++] = ' ';
|
|
} else if (ch == '%') {
|
|
try {
|
|
res[didx++] =
|
|
(char)Integer.parseInt(str.substring(sidx + 1, sidx + 3), 16);
|
|
sidx += 2;
|
|
} catch (NumberFormatException e) {
|
|
didx--;
|
|
res[didx++] = ch;
|
|
}
|
|
} else {
|
|
res[didx++] = ch;
|
|
}
|
|
}
|
|
return String.valueOf(res, 0, didx);
|
|
}
|
|
}
|