Created
June 10, 2016 03:16
-
-
Save rafaelaugustos/2181968dcfe9f25b8e4082a9fa55f445 to your computer and use it in GitHub Desktop.
This file contains 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
$('body').on('click', '#confirmarComp', function(e){ | |
e.preventDefault(); | |
//var listener = 'http://getmyidol.com/webservice/PDO/listener/listener.php'; | |
var ticketsEscolhidos = []; | |
var valor = 0; | |
var title = $(this).attr('data-event')+': '; | |
$('.qtd').each(function(){ | |
var qtd = $(this).val(); | |
if(qtd > 0){ | |
var preco = $(this).attr('data-value'); | |
valor += preco*qtd; | |
title += $(this).attr('data-title')+','; | |
var ticketId = $(this).attr('data-id'); | |
ticketsEscolhidos.push(ticketId+':'+qtd); | |
} | |
}); | |
$(this).text('aguarde...').prop('disabled', true); | |
var agora = Date.now(); | |
$.ajax({ | |
method: 'POST', | |
url: 'http://getmyidol.com/webservice/PDO/sell_ticket.php', | |
data: { | |
total: valor, | |
user_id: localStorage.userId, | |
event_id: evento_id, | |
tickets: ticketsEscolhidos | |
}, | |
dataType: 'json', | |
success: function(retorno){ | |
//inseriu a compra no banco. | |
if(retorno.sucesso == 'yes'){ | |
transacao_id = retorno.transacao_id; | |
ticketsComprados = retorno.ticketsComprados; | |
//enviarEmail(); | |
$.ajax({ | |
method: 'POST', | |
url: 'http://getmyidol.com/paypal/pagamento.php', | |
data: { | |
nm: title, | |
vl: valor, | |
tp: 'pagamento', | |
moeda: 'real', | |
tk: agora, | |
transacao: retorno.transaction_id | |
}, | |
success: function(r){ | |
var split = r.split('='); | |
paypal_transaction_id = split[2]; | |
sendPaypalTransactionId(retorno.transaction_id, paypal_transaction_id); | |
//myApp.popup('.popup-loading'); | |
$$('.fechar .close-popup').click(); | |
window.location.href = r; | |
} | |
}); | |
} | |
} | |
}); | |
/*paypal antigo aqui*/ | |
return false; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment