File tree Expand file tree Collapse file tree 1 file changed +6
-7
lines changed
packages/apps/mercadopago/src Expand file tree Collapse file tree 1 file changed +6
-7
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,12 @@ export const mercadopago = {
1717 const { method, body : notification } = req ;
1818 if ( method === 'POST' && notification ) {
1919 logger . info ( 'Webhook body' , { notification } ) ;
20+ if ( notification . type !== 'payment' || ! notification . data ?. id ) {
21+ res . sendStatus ( 400 ) ;
22+ return ;
23+ }
24+ logger . info ( `MP Notification for Payment #${ notification . data . id } ` ) ;
25+
2026 try {
2127 const app = ( await api . get (
2228 `applications?app_id=${ config . get ( ) . apps . mercadoPago . appId } &fields=hidden_data` ,
@@ -31,15 +37,8 @@ export const mercadopago = {
3137 return ;
3238 }
3339
34- if ( notification . type !== 'payment' || ! notification . data ?. id ) {
35- res . sendStatus ( 400 ) ;
36- return ;
37- }
38- logger . info ( `MP Notification for Payment #${ notification . data . id } ` ) ;
39-
4040 const docRef = getFirestore ( ) . collection ( 'mercadopagoPayments' )
4141 . doc ( String ( notification . data . id ) ) ;
42-
4342 docRef . get ( )
4443 . then ( async ( doc ) => {
4544 if ( doc . exists ) {
You can’t perform that action at this time.
0 commit comments