Skip to content

Instantly share code, notes, and snippets.

@Chicooz
Last active October 3, 2015 14:13
Show Gist options
  • Save Chicooz/a84be0892d56ec6b2e72 to your computer and use it in GitHub Desktop.
Save Chicooz/a84be0892d56ec6b2e72 to your computer and use it in GitHub Desktop.
payulatam not showing masked card
<div class="col-md-6 col-xs-offset-3">
<span class="form-row create-errors" style="color:red"></span>
<div id="mylistID" style=""></div>
<form action="" method="POST" id="create-form" class="clearfix">
<h2>Add New Card</h2>
<div class="row">
<label for="inputEmail" class="col-lg-3 control-label">Card Number</label>
<div class="col-lg-9">
<input type="text" class="form-control" value='4111111111111111' size="30" payu-content="number" onkeyup="payU.validateCard(this.value);" placeholder="Card Number">
</div>
</div>
<div class="row">
<label for="inputEmail" class="col-lg-3 control-label">Expiry</label>
<div class="col-lg-4">
<input type="text" class="form-control" value="11" size="2" payu-content="exp_month" placeholder="MM">
</div>
<div class="col-lg-4 col-xs-offset-1">
<input type="text" class="form-control" size="4" value="2020" payu-content="exp_year" placeholder="YYYY">
</div>
</div>
<div class="row">
<label for="inputEmail" class="col-lg-3 control-label">Document</label>
<div class="col-lg-9">
<input type="text" class="form-control" payu-content="document" value="22343" placeholder="Document">
</div>
</div>
<input payu-content="payer_id" value="22322343" type="hidden">
<div class="row">
<label for="inputEmail" class="col-lg-3 control-label">Name</label>
<div class="col-lg-9">
<input type="text" class="form-control" payu-content="name_card" placeholder="Name" value="my name">
</div>
</div>
<div class="row">
<label for="inputEmail" class="col-lg-3 control-label">CVC</label>
<div class="col-lg-4">
<input type="text" class="form-control" value="332" payu-content="cvc" placeholder="CVC">
</div>
</div>
<button class="btn btn-lg btn-primary signup-btn">Add Card</button><a class="pull-right back-login" href="/profile">Cancel</a>
</form>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script type="text/javascript" src="https://gateway.payulatam.com/ppp-web-gateway/javascript/PayU.js"></script>
<script type="text/javascript">
payU.setURL('http://api.payulatam.com/payments-api/4.0/service');
payU.setPublicKey("PK6gDnKQr45I844s3nR28bg32j");
payU.setAccountID("543662"); //3 brasil // 9 argentina // 1 colombia
payU.setListBoxID("mylistID");
payU.setLanguage("en"); // optional
payU.getPaymentMethods();
// function de respuesta
var responseHandler = function(response) {
console.log('HERE')
var $form = $('#create-form');
if (response.error) {
console.log("error", response.error)
// Show the errors on the form
$form.find('.create-errors').text(response.error);
$form.find('button').prop('disabled', false);
} else {
// token contains id, last4, and card type
var token = response.token;
console.log(response);
// Object {token: "5c22be41-210f-46a5-8910-b1464a81f116", name: "lovely love", payer_id: "560d62a486e8060000fffb72", method: "VISA", document: "283746"}
$form.find('button').prop('disabled', false);
}
};
jQuery(function($) {
$('#create-form').submit(function(event) {
console.log('submitting');
var $form = $(this);
// Disable the submit button to prevent repeated clicks
$form.find('button').prop('disabled', true);
payU.createToken(responseHandler, $form);
// Prevent the form from submitting with the default action
return false;
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment