Ejemplos
Last update: 4 days ago by Marian Guzmán - JC
Enlace de Pago
Petición HTTP con carga completa
curl -X POST 'http://{{url}}/whatsapp-bsp-api-endpoint-ws/services/v1/messaging' \-H 'Authorization: Bearer {{wa-msg-api-token}}' \-H 'Content-Type: application/json' \-d '{"from": "5511900000001","to": "5511900000002","type": "interactive","order_details": {"body": "Detalhes do seu pedido","footer": "Pagamento seguro","action": {"name": "review_and_pay","parameters": {"reference_id": "link-br-full-001","payment_type": "br","type": "digital-goods","payment_settings": [{"type": "payment_link","payment_link": { "uri": "https://minhaloja.com.br/pagar/001" }}],"currency": "BRL","total_amount": { "value": 50000, "offset": 100 },"order": {"status": "pending","tax": { "value": 0, "offset": 100, "description": "Imposto" },"items": [{"retailer_id": "SKU-001","name": "Bolo de chocolate","amount": { "value": 50000, "offset": 100 },"quantity": 1}],"subtotal": { "value": 50000, "offset": 100 }}}}}}'
Petición HTTP con carga simplificada
curl -X POST 'http://{{url}}/whatsapp-bsp-api-endpoint-ws/services/v1/messaging' \-H 'Authorization: Bearer {{wa-msg-api-token}}' \-H 'Content-Type: application/json' \-d '{"from": "5511900000001","to": "5511900000002","type": "interactive","order_details": {"body": "Detalhes do seu pedido","action": {"name": "review_and_pay","parameters": {"reference_id": "link-br-simple-002","payment_type": "br","type": "digital-goods","payment_settings": [{"type": "payment_link","payment_link": { "uri": "https://minhaloja.com.br/pagar/001" }}],"currency": "BRL","total_amount": { "value": 50000, "offset": 100 }}}}}'
Código Dinámico de PIX
Petición HTTP con carga completa
curl -X POST 'http://{{url}}/whatsapp-bsp-api-endpoint-ws/services/v1/messaging' \-H 'Authorization: Bearer {{wa-msg-api-token}}' \-H 'Content-Type: application/json' \-d '{"from": "5511900000001","to": "5511900000002","type": "interactive","order_details": {"body": "Detalhes do seu pedido","footer": "Pagamento seguro","action": {"name": "review_and_pay","parameters": {"reference_id": "pix-full-001","payment_type": "br","type": "digital-goods","payment_settings": [{"type": "pix_dynamic_code","pix_dynamic_code": {"code": "00020101021226700014br.gov.bcb.pix2548pix.example.com","merchant_name": "Minha Loja","key": "39580525000189","key_type": "CNPJ"}}],"currency": "BRL","total_amount": { "value": 50000, "offset": 100 },"order": {"status": "pending","tax": { "value": 0, "offset": 100, "description": "Imposto" },"items": [{"retailer_id": "SKU-001","name": "Bolo de chocolate","amount": { "value": 50000, "offset": 100 },"quantity": 1}],"subtotal": { "value": 50000, "offset": 100 }}}}}}'
Petición HTTP con carga simplificada
curl -X POST 'http://{{url}}/whatsapp-bsp-api-endpoint-ws/services/v1/messaging' \-H 'Authorization: Bearer {{wa-msg-api-token}}' \-H 'Content-Type: application/json' \-d '{"from": "5511900000001","to": "5511900000002","type": "interactive","order_details": {"body": "Detalhes do seu pedido","action": {"name": "review_and_pay","parameters": {"reference_id": "pix-simple-002","payment_type": "br","type": "digital-goods","payment_settings": [{"type": "pix_dynamic_code","pix_dynamic_code": {"code": "00020101021226700014br.gov.bcb.pix2548pix.example.com","merchant_name": "Minha Loja","key": "39580525000189","key_type": "CNPJ"}}],"currency": "BRL","total_amount": { "value": 50000, "offset": 100 }}}}}'
Boleto
Petición HTTP con carga completa
curl -X POST 'http://{{url}}/whatsapp-bsp-api-endpoint-ws/services/v1/messaging' \-H 'Authorization: Bearer {{wa-msg-api-token}}' \-H 'Content-Type: application/json' \-d '{"from": "5511900000001","to": "5511900000002","type": "interactive","order_details": {"body": "Detalhes do seu pedido","footer": "Pagamento seguro","action": {"name": "review_and_pay","parameters": {"reference_id": "boleto-br-full-001","payment_type": "br","type": "digital-goods","payment_settings": [{"type": "boleto","boleto": { "digitable_line": "03399026944140000002628346101018898510000008848" }}],"currency": "BRL","total_amount": { "value": 50000, "offset": 100 },"order": {"status": "pending","tax": { "value": 0, "offset": 100, "description": "Imposto" },"items": [{"retailer_id": "SKU-001","name": "Bolo de chocolate","amount": { "value": 50000, "offset": 100 },"quantity": 1}],"subtotal": { "value": 50000, "offset": 100 }}}}}}'
Petición HTTP con carga simplificada
curl -X POST 'http://{{url}}/whatsapp-bsp-api-endpoint-ws/services/v1/messaging' \-H 'Authorization: Bearer {{wa-msg-api-token}}' \-H 'Content-Type: application/json' \-d '{"from": "5511900000001","to": "5511900000002","type": "interactive","order_details": {"body": "Detalhes do seu pedido","action": {"name": "review_and_pay","parameters": {"reference_id": "boleto-br-simple-002","payment_type": "br","type": "digital-goods","payment_settings": [{"type": "boleto","boleto": { "digitable_line": "03399026944140000002628346101018898510000008848" }}],"currency": "BRL","total_amount": { "value": 50000, "offset": 100 }}}}}'
Múltiples métodos de pago
Petición HTTP con PIX, Enlace de Pago y Boleto
curl -X POST 'http://{{url}}/whatsapp-bsp-api-endpoint-ws/services/v1/messaging' \-H 'Authorization: Bearer {{wa-msg-api-token}}' \-H 'Content-Type: application/json' \-d '{"from": "5511900000001","to": "5511900000002","type": "interactive","order_details": {"body": "Detalhes do seu pedido","action": {"name": "review_and_pay","parameters": {"reference_id": "multi-br-001","payment_type": "br","type": "digital-goods","payment_settings": [{"type": "pix_dynamic_code","pix_dynamic_code": {"code": "00020101021226700014br.gov.bcb.pix2548pix.example.com","merchant_name": "Minha Loja","key": "39580525000189","key_type": "CNPJ"}},{"type": "payment_link","payment_link": { "uri": "https://minhaloja.com.br/pagar/001" }},{"type": "boleto","boleto": { "digitable_line": "03399026944140000002628346101018898510000008848" }}],"currency": "BRL","total_amount": { "value": 50000, "offset": 100 }}}}}'
Plantilla de detalles del pedido
Petición HTTP con PIX
curl -X POST 'http://{{url}}/whatsapp-bsp-api-endpoint-ws/services/v1/messaging' \-H 'Authorization: Bearer {{wa-msg-api-token}}' \-H 'Content-Type: application/json' \-d '{"from": "5511900000001","to": "5511900000002","type": "template","template": {"name": "payment_template","language": "es_MX","components": [{"type": "button","subtype": "order_details","index": 0,"parameters": [{"type": "action","action": {"order_details": {"reference_id": "tpl-pix-001","payment_type": "br","type": "digital-goods","payment_settings": [{"type": "pix_dynamic_code","pix_dynamic_code": {"code": "00020101021226700014br.gov.bcb.pix2548pix.example.com","merchant_name": "Minha Loja","key": "39580525000189","key_type": "CNPJ"}}],"currency": "BRL","total_amount": { "value": 50000, "offset": 100 }}}}]}]}}'
Petición HTTP con Boleto
curl -X POST 'http://{{url}}/whatsapp-bsp-api-endpoint-ws/services/v1/messaging' \-H 'Authorization: Bearer {{wa-msg-api-token}}' \-H 'Content-Type: application/json' \-d '{"from": "5511900000001","to": "5511900000002","type": "template","template": {"name": "payment_template","language": "es_MX","components": [{"type": "button","subtype": "order_details","index": 0,"parameters": [{"type": "action","action": {"order_details": {"reference_id": "tpl-boleto-001","payment_type": "br","type": "digital-goods","payment_settings": [{"type": "boleto","boleto": { "digitable_line": "03399026944140000002628346101018898510000008848" }}],"currency": "BRL","total_amount": { "value": 50000, "offset": 100 }}}}]}]}}'
Petición HTTP con Enlace de Pago
curl -X POST 'http://{{url}}/whatsapp-bsp-api-endpoint-ws/services/v1/messaging' \-H 'Authorization: Bearer {{wa-msg-api-token}}' \-H 'Content-Type: application/json' \-d '{"from": "5511900000001","to": "5511900000002","type": "template","template": {"name": "payment_template","language": "es_MX","components": [{"type": "button","subtype": "order_details","index": 0,"parameters": [{"type": "action","action": {"order_details": {"reference_id": "tpl-link-001","payment_type": "br","type": "digital-goods","payment_settings": [{"type": "payment_link","payment_link": { "uri": "https://minhaloja.com.br/pagar/001" }}],"currency": "BRL","total_amount": { "value": 50000, "offset": 100 }}}}]}]}}'
Crear plantilla de solicitud de pago
Petición HTTP con tres métodos de pago
curl -X POST 'http://{{url}}/whatsapp-bsp-admin-ext-endpoint-ws/services/v1/template' \-H 'Authorization: Bearer {{wa-msg-api-token}}' \-H 'Content-Type: application/json' \-d '{"wba_id": "100000000000000","name": "payment_template","language": "es_MX","category": "UTILITY","structure": {"body": { "text": "Elige tu método de pago preferido." },"buttons": [{"type": "PAYMENT_REQUEST","text": "Copy Pix code","payment_setting": {"type": "pix_dynamic_code","pix_dynamic_code": { "code": "00020101021226700014br.gov.bcb.pix2548pix.example.com" }}},{"type": "PAYMENT_REQUEST","text": "Copy Boleto code","payment_setting": {"type": "boleto","boleto": { "digitable_line": "03399026944140000002628346101018898510000008848" }}},{"type": "PAYMENT_REQUEST","text": "Open payment link","payment_setting": {"type": "payment_link","payment_link": { "uri": "https://minhaloja.com.br/pagar/001" }}}]}}'
Petición HTTP con botón de pago combinado con otros tipos
El botón de solicitud de pago puede combinarse con botones de sitio web (URL) y de llamada (PHONE_NUMBER).
Nota: Meta no acepta todas las combinaciones. En pruebas, el botón de pago no puede quedar en medio de tres botones.
curl -X POST 'http://{{url}}/whatsapp-bsp-admin-ext-endpoint-ws/services/v1/template' \-H 'Authorization: Bearer {{wa-msg-api-token}}' \-H 'Content-Type: application/json' \-d '{"wba_id": "100000000000000","name": "payment_template_promo","language": "es_MX","category": "MARKETING","structure": {"body": { "text": "Pacotes de viagem selecionados de 4 dias agora estão com 50% de desconto!" },"buttons": [{"type": "PAYMENT_REQUEST","text": "Copy Boleto code","payment_setting": {"type": "boleto","boleto": { "digitable_line": "03399026944140000002628346101018898510000008848" }}},{ "type": "URL", "text": "Visitar site", "url": "https://minhaloja.com.br" },{ "type": "PHONE_NUMBER", "text": "Ligue para nós", "phone_number": "+5511900000003" }]}}'
Enviar plantilla de solicitud de pago
Petición HTTP con un botón de pago
curl -X POST 'http://{{url}}/whatsapp-bsp-api-endpoint-ws/services/v1/messaging' \-H 'Authorization: Bearer {{wa-msg-api-token}}' \-H 'Content-Type: application/json' \-d '{"from": "5511900000001","to": "5511900000002","type": "template","template": {"name": "payment_template_promo","language": "es_MX","components": [{"type": "button","subtype": "payment_request","index": 0,"parameters": [{"type": "action","action": {"payment_request": {"payment_setting": {"type": "boleto","boleto": { "digitable_line": "03399026944140000002628346101018898510000008848" }}}}}]}]}}'
Petición HTTP con tres botones de pago
curl -X POST 'http://{{url}}/whatsapp-bsp-api-endpoint-ws/services/v1/messaging' \-H 'Authorization: Bearer {{wa-msg-api-token}}' \-H 'Content-Type: application/json' \-d '{"from": "5511900000001","to": "5511900000002","type": "template","template": {"name": "payment_template","language": "es_MX","components": [{"type": "button","subtype": "payment_request","index": 0,"parameters": [{"type": "action","action": {"payment_request": {"payment_setting": {"type": "pix_dynamic_code","pix_dynamic_code": { "code": "00020101021226700014br.gov.bcb.pix2548pix.example.com" }}}}}]},{"type": "button","subtype": "payment_request","index": 1,"parameters": [{"type": "action","action": {"payment_request": {"payment_setting": {"type": "boleto","boleto": { "digitable_line": "03399026944140000002628346101018898510000008848" }}}}}]},{"type": "button","subtype": "payment_request","index": 2,"parameters": [{"type": "action","action": {"payment_request": {"payment_setting": {"type": "payment_link","payment_link": { "uri": "https://minhaloja.com.br/pagar/001" }}}}}]}]}}'
