Encryption of Card Information
2C2P provides merchants with tools such as the JavaScript SDK to further protect sensitive information such as card data (e.g., expiry date, CVV).
With these tools, merchants do not need to undertake a complex and time-consuming PCI-DSS certification process. All the sensitive information is protected at 2C2P with the most advanced security that is compliant with PCI-DSS standards.
Import 2C2P JavaScript SDK
<script type="text/javascript" src="https://demo2.2c2p.com/2C2PFrontEnd/SecurePayment/api/my2c2p.1.6.9.min.js"></script>
Secure Pay JS library
For the demo and live environments, refer to the latest library
Prepare Card Data Fields
To prepare card data for encryption, follow the HTML fields below. Add 'data-encrypt' fields into the form to capture card information securely.
<form id="2c2p-payment-form" action="[Merchant Backend]" method="POST">
<input type="text" data-encrypt="cardnumber" maxlength="16" placeholder="Credit Card Number"><br/>
<input type="text" data-encrypt="month" maxlength="2" placeholder="MM"><br/>
<input type="text" data-encrypt="year" maxlength="4" placeholder="YYYY"><br/>
<input type="password" data-encrypt="cvv" maxlength="4" autocomplete="off" placeholder="CVV2/CVC2"><br/>
<input type="submit" value="Submit">
</form>
Attribute | Description |
---|---|
data-encrypt="cardnumber" | To capture the credit card number encrypted |
data-encrypt="month" | To capture the credit card expire month encrypted |
data-encrypt="year" | To capture the credit card expire year encrypted |
data-encrypt="cvv" | To capture the credit card security code encrypted |
Submit Form
Submit the form via the 2C2P SDK. Validation will be performed by 2C2P.
If successfully validated, the form will be submitted to the merchant backend. Otherwise, errors will be returned: refer to the table below for details on specific error codes.
<script type="text/javascript">
My2c2p.onSubmitForm("2c2p-payment-form", function(errCode,errDesc){
if(errCode!=0){
alert(errDesc+" ("+errCode+")");
}
});
</script>
Error Code | Description |
---|---|
0 | Success |
1 | Card number is required |
2 | Card number is invalid |
3 | Expiry month is required |
4 | Expiry month must be two numbers |
5 | Expiry year is required |
6 | Expiry year must be four numbers |
7 | Card already expired(year) |
8 | Card already expired(month) |
9 | Expiry month is invalid |
10 | CVV2/CVC2 is invalid |
Updated 10 days ago