How to make Secure Forms place values into a nested JSON field.

 

We do not support nested parameters at the moment.

Example of secure forms usage:

f.field('#cc-number .fake-input', {
type: 'credit_card_number',
name: 'credit_card_number',
successColor: 'green',
errorColor: 'red',
placeholder: '4111 1111 1111 1111',
validations: ['required', 'validCardNumber'],
});

// ...

f.submit('/post', {
headers: {
'x-custom-header': 'Oh yes. I am a custom header',
},
data: {
"methodName": "MakeReservation",
},
}, function(status, data) {
document.getElementById('response').innerText = JSON.stringify(data, null, ' ');
});
}

The field credit_card_number will be merged with data JSON from submit() method. So the resulting payload would look like

{
"methodName": "MakeReservation",
"credit_card_cid": "123",
"credit_card_expiration_month": "06",
"credit_card_expiration_year": 2017,
"credit_card_number": "tok_123456789abcd",
"credit_card_type_id": "1"
}

there is currently no way to make it nested into a nested field like params in the sample below

{
"methodName": "MakeReservation",
"params": {

"credit_card_cid": "123",
"credit_card_expiration_month": "06",
"credit_card_expiration_year": 2017,
"credit_card_number": "4111111111111111",
"credit_card_type_id": "1"
}


}

Where "credit_card_number": "4111111111111111", should be tokenized.

 

 

 

 

 

Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.