Created
July 28, 2017 14:40
-
-
Save kainlite/a4e939495765fdf6da3d19b7540b7438 to your computer and use it in GitHub Desktop.
Exploring ML API
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
| <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> | |
| <script src="https://secure.mlstatic.com/sdk/javascript/v1/mercadopago.js"></script> | |
| <script> | |
| $(document).ready ( function(){ | |
| function getIdentificationType(status, response) { | |
| if (status == 200) { | |
| console.log("Identification type:"); | |
| console.log(response); | |
| } | |
| }; | |
| function setPaymentMethodInfo(status, response) { | |
| if (status == 200) { | |
| console.log("Card type:"); | |
| console.log(response); | |
| } | |
| }; | |
| function sdkResponseHandler(status, response) { | |
| if (status == 200 || status == 201) { | |
| console.log("Card token response:"); | |
| console.log(response); | |
| } | |
| }; | |
| Mercadopago.setPublishableKey("YOUR-PUB-KEY"); | |
| Mercadopago.getIdentificationTypes(getIdentificationType); | |
| Mercadopago.getPaymentMethod({ | |
| "bin": "4509-9535-6623-3704".replace(/[ .-]/g, '').slice(0, 6) | |
| }, setPaymentMethodInfo); | |
| var form = document.createElement('input'); | |
| form.setAttribute('email',"test@test.com"); | |
| form.setAttribute('cardNumber',"4509 9535 6623 3704"); | |
| form.setAttribute('securityCode',"123"); | |
| form.setAttribute('cardExpirationMonth', "12"); | |
| form.setAttribute('cardExpirationYear', "2022"); | |
| form.setAttribute('cardholderName', "APRO"); | |
| form.setAttribute('docType', "DNI"); | |
| form.setAttribute('docNumber', "12345678"); | |
| document.body.appendChild(form); | |
| Mercadopago.createToken(form, sdkResponseHandler); | |
| }); | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment