mercredi 26 août 2020

JavaScript with Random Number

I must set up a payment widget on a website, I'm obviously new in this, tried following the help site from our gateway provider and was able to do as follow:

<html>
<head><meta charset="utf-8">
<title></title>
<script type="text/javascript" src="https://checkout.co/widget.js"></script>
</head>
<body>
<script>
var checkout = new WidgetCheckout({
   currency: 'COP',
   amountInCents: 20000000,
   reference: 'ReferenceID',
   publicKey: 'pub_test_aoqCB6UQtUGCGN9SUzT7LBwNFbQYw0aG',
   redirectUrl: '' // Opcional
});
</script>
<button onclick="checkout.open (function ( result ) {
var transaction = result.transaction
console.log('Transaction ID: ', transaction.id)
console.log('Transaction object: ', transaction)
})">Pagar</button>
</body>
</html>

Now the question is: is there any way I can setup a autogenerated 10 lenght random number on reference field: 'ReferenceID'? I tryed adding Math.round(Date.now() + Math.random()*9) but obviously not working. See the result of what happens when I add Math.round...

Screenshot

Thanks for your help




Aucun commentaire:

Enregistrer un commentaire