plxdcma_paypalinterface
v1.0.4
Published
Readme
//COMOS USARSE
var client_id=AbKuzief1VKTu7UDqN-uCOCIDMd7ZqTJaSgWTQUfTHAZnOEavwFGRCWY9MFRkoFxQysOsYAhtp3PBmAy
var secret_key=EGiWv95OYhPq0WugQBXARkp911-DK_LmuJEsaowUm_EsNBeutNAzifq9ZRpvKDVmcXtzMPqt2DqNSoGI
myPaypalModule.asSandBox(app,http://localhost:3304,client_id,secret_key,function(req,res,transactionId,paypaltransactionqueryresultobject){
//Success function
pool.query(`select paypaltransactions_products.*,evento_selableproducts.evento from paypaltransactions_products
inner join evento_selableproducts on evento_selableproducts.id = paypaltransactions_products.eventoselableproduct
where transactionid = ${transactionId}`,function(er,result){
var ev=null
for(var each in result){
var rx=result[each]
ev=rx.evento
break
}
var userinsession=sessions.usuarioEn(req,res)
if(userinsession != null){
userinsession.didHandleAPrePago=true
}
pool.query(`insert into facturas(date,postpago,emisor)value(now(),0,${paypaltransactionqueryresultobject.emisor})`,function(er,facturainsert){
var ds=datetimestring()
pool.query(`update paypaltransaction set facturaid = ${facturainsert.insertId} where id = '${transactionId}'`)
pool.query(`insert into notificaciones set ?`,{
emisor:paypaltransactionqueryresultobject.emisor,
receptor:ev,
tipo:seGeneroUnaFacturaPrePago,
data:facturainsert.insertId,
datetime:ds,
state:0,
response:0
})
var promesas=[]
for(var i = 0 ; i < result.length;i++){
var rx=result[i]
pool.query(`update inventario set current = current - ${rx.cuantity} where id = (select inventario from evento_selableproducts where id = ${rx.eventoselableproduct})`)
}
res.redirect("/finishpaypal")
})
})},function(req,res,transactionId){ //Cancel function
res.write("Cancel function")
res.end()},pool)
