Created
April 9, 2021 23:04
-
-
Save dragipostolovski/f05c221ff27d60395ca467616f443acf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// WordPress | |
jQuery(document).ready(function ( $ ) { | |
let payment = $('#your-button'); | |
// let secureFields = new SecureFields(); | |
let styles = { | |
// your style goes here | |
// Specific Style for Each Element | |
cardNumber: "border: 1px solid #eaeaea; height: 40px; padding: 10px; " + | |
"font-size: 18px; color: #818a91; background: #fafafa;", | |
cvv: "border: 1px solid #eaeaea; height: 40px; padding: 10px; " + | |
"font-size: 18px; color: #818a91; background: #fafafa;", | |
}; | |
secureFields.init(datatrans.transactionId, { | |
cardNumber: "cardNumberPlaceholder", | |
cvv: "cvvPlaceholder", | |
}, { | |
styles: styles | |
}); | |
secureFields.on("validate", function (data) { | |
// something bad happened | |
if (true == data.hasErrors) { | |
$('.pe-datatrans-error').html('Please enter valid card information.'); | |
} | |
}); | |
secureFields.on("success", function (data) { | |
if (data.transactionId) { | |
submitFormWithCoupon('no', data.cardInfo.brand, data.cardInfo.country); | |
} else { | |
$('.pe-datatrans-error').html(data); | |
} | |
}); | |
payment.on('click', '#go', function () { | |
secureFields.submit({ | |
amount: 3000, // ask for the amount in your form | |
expm: 12, // ask for the expm in your form | |
expy: 21, // ask for the expy in your form | |
currency: "EUR", | |
returnUrl: 'https://domain.com/thank-you' // 3D process return URL | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment