You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Alguma coisa falta, mas não sei o que é... A documentação não é clara.
Frontend index.html
<!DOCTYPE html><htmllang="pt-br"><head><metacharset="UTF-8"><metahttp-equiv="X-UA-Compatible" content="IE=edge"><metaname="viewport" content="width=device-width, initial-scale=1.0"><title>Checkout Pro Integração</title><scriptsrc="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script><scriptsrc="https://secure.mlstatic.com/sdk/javascript/v1/mercadopago.js"></script></head><body><divstyle="width: 500px; height: 500px; background-color: #f0f0f0;"><formclass="cho-container" action="http://localhost:3001/pagar" method="post"><!--Botão renderizado aqui--></form></div><scriptsrc="https://sdk.mercadopago.com/js/v2"></script><script>// Adicione as credenciais do SDKconstmp=newMercadoPago('TEST-a324251b-bd2e-4c0f-9507-c8ec807b6145',{locale: 'pt-BR'});// Inicialize o checkoutmp.checkout({preference: {id: '1'},render: {container: '.cho-container',// Indique o nome da class onde será exibido o botão de pagamentolabel: 'Comprar agora',// Muda o texto do botão de pagamento (opcional)}});</script></body></html>
Server-side (node) index.js
constexpress=require("express");constapp=express();constcors=require("cors");constbody_parser=require("body-parser");constmercadopago=require('mercadopago');app.use(express.json());app.use(cors());app.use(body_parser.urlencoded({extended : true}));mercadopago.configure({access_token: 'TEST-3059303028461564-092022-f2dda18bb6dff04b17c65d5fd6a3d2e1-807277607'});app.post("/pagar",(req,res)=>{varpreference={items: [{id: '1',title: 'Lightweight Paper Table',description: 'Inspired by the classic foldable art of origami',category_id: 'home',quantity: 1,currency_id: 'BRL',unit_price: 55}]};mercadopago.preferences.create(preference).then(function(response){res.json({id: response.body.id});}).catch(function(error){console.log(error);});});app.listen(3001,()=>{console.info("Server running in 3001 port!");});
The text was updated successfully, but these errors were encountered:
Alguma coisa falta, mas não sei o que é... A documentação não é clara.
Frontend index.html
Server-side (node) index.js
The text was updated successfully, but these errors were encountered: