Hi
Earlier, while using VF page we had the below snippet in use:
function tokenizeCreditCard(CCNumber){
if ( CCNumber == null || CCNumber.length < 15 || CCNumber.length > 16 )
{
popupjQuery$('#creditCardErrorDiv').html( '<b>'+'Please enter valid 16 digit Credit Card Numbers'+'</b>');
return false;
}
// Strip out spaces from input value
var fixedCard = CCNumber.replace( /s+/g, "" );
console.log( "noSpaces: '" + fixedCard + "'" );
CCNumber = fixedCard;
var token = "";
var isDebug = false;
var parsedJSON = "";
//popupjQuery$("[id*='BPCardNumber']").val('');
try
{
var soapMsg = '{ "cc":"' + CCNumber + '"}'; //json request message
sforce.connection.sessionId = "{!$Api.Session_ID}";
// url : "{!sdtUrl}",
sforce.connection.remoteFunction({
url : "{!sdtEndpoint}",
requestHeaders:
{
"Content-Type": "Application/json",
"Authorization": "{!sdtHeader}"
},
mimeType: "text/plain",
requestData: soapMsg,
method: "POST",
async: false,
onSuccess: function(response)
{
console.log('I am in Success '+response);
parsedJSON = JSON.parse(response);
var cc = parsedJSON.cc;
var CCToken = parsedJSON.ccToken;
if (typeof console != 'undefined') {
console.log('CCToken = '+CCToken);
}
if (typeof CCToken != 'undefined' && CCToken!= '') {
var lastDigits = CCToken.substring(CCToken.length - 4,CCToken.length);
var ccFormat = "**** **** **** "+lastDigits;
//popupjQuery$('.'+BPCardNumber).val(ccFormat);
popupjQuery$("[id*='BPCardNumber']").val(ccFormat);
errorMsg = '';
} else {
}
return;
},
onFailure: function(response)
{
console.log('error message on failure');
var errorMsg = GetErrMsg(response);
//popupjQuery$('#creditCardErrorDiv').html( 'Invalid Credit card number');
popupjQuery$('#creditCardErrorDiv').html( '<b>'+ errorMsg+'</b>');
return;
}
});
} catch(exception) {
console.log('exception message in catch block**');
}
}
This function will send the CCard No# to an endpoint and get a token.
how to convert this into skuid’s snippet ?
How to get the sessionID and how does it work for sforce.connection.remoteFunction(){} ?
Any ideas ?