rgcl / webpay-nodejs

[Spanish/Chile] Módulo no oficial para integrar WebPay Plus en Node.js, con soporte para promesas.
GNU Lesser General Public License v3.0
93 stars 32 forks source link

getTransactionResult #3

Closed Gonzalo9823 closed 6 years ago

Gonzalo9823 commented 6 years ago

Hola, yo de nuevo, estoy teniendo un problema con conseguir el resultado de la transacción, me esta tirando un "Timeout error(272)".

Este es mi código:

const wp_token = req.body.wp_token

    wp.getTransactionResult(wp_token).then((transaccion) => {

        res.json({
            status: 1,
            transaccion
        })

    }).catch((e) => {
        res.json({
            status: 0,
            e
        })

    })

Y esta es la respuesta que me da, que viene por el catch:

"e": {
        "root": {
            "Envelope": {
                "Header": {
                    "Security": {
                        "attributes": {
                            "soap:mustUnderstand": "1"
                        },
                        "Signature": {
                            "attributes": {
                                "Id": "SIG-1037504"
                            },
                            "SignedInfo": {
                                "CanonicalizationMethod": {
                                    "attributes": {
                                        "Algorithm": "http://www.w3.org/2001/10/xml-exc-c14n#"
                                    },
                                    "InclusiveNamespaces": {
                                        "attributes": {
                                            "PrefixList": "soap"
                                        }
                                    }
                                },
                                "SignatureMethod": {
                                    "attributes": {
                                        "Algorithm": "http://www.w3.org/2000/09/xmldsig#rsa-sha1"
                                    }
                                },
                                "Reference": {
                                    "attributes": {
                                        "URI": "#id-1037503"
                                    },
                                    "Transforms": {
                                        "Transform": {
                                            "attributes": {
                                                "Algorithm": "http://www.w3.org/2001/10/xml-exc-c14n#"
                                            },
                                            "InclusiveNamespaces": {
                                                "attributes": {
                                                    "PrefixList": ""
                                                }
                                            }
                                        }
                                    },
                                    "DigestMethod": {
                                        "attributes": {
                                            "Algorithm": "http://www.w3.org/2000/09/xmldsig#sha1"
                                        }
                                    },
                                    "DigestValue": "kDFv8tyfbaGv5co0PuqmkdSzL50="
                                }
                            },
                            "SignatureValue": "otwu102WzVVEV3kXqJrcCtQT/Xkte6bQD9K1W4tb66fnrcCMK3Uk+uJsUfmLZxQyZzGZfUG24Ldy\n/a/STGJd30FwgnOR2IKzujorSLqqFJaFvuQRn/mrqKDlrRC9EDadsn3RQHlEzNPNB0jBVrOcTobj\nHo1OofqOsgdC2NTPXDXA7MjsR3qPG9PC9OrFV0unAXCeUdG4nN926ZAIPs0hMebTLPMs9rj9Mumz\nmahevIrAZgfJJ16pV7xge3ekkDO93JQTYImqsKp7AuXEarfVHhy6rPq7fyjPfJooids9krHqoxns\nE5qRe+pvJTs71EQlXI0/NaEQ5wUxX7cU6EWELg==",
                            "KeyInfo": {
                                "attributes": {
                                    "Id": "KI-AFF6A1C21E97D2C94215303031813931556261"
                                },
                                "SecurityTokenReference": {
                                    "attributes": {
                                        "wsu:Id": "STR-AFF6A1C21E97D2C94215303031813931556262"
                                    },
                                    "X509Data": {
                                        "X509IssuerSerial": {
                                            "X509IssuerName": "CN=10,OU=PRD,O=transbank,L=Santiago,ST=RM,C=CL",
                                            "X509SerialNumber": "9876689033494141554"
                                        }
                                    }
                                }
                            }
                        }
                    }
                },
                "Body": {
                    "attributes": {
                        "wsu:Id": "id-1037503"
                    },
                    "Fault": {
                        "faultcode": "soap:Server",
                        "faultstring": "<!-- Timeout error(272) -->"
                    }
                }
            }
        },
        "response": {
            "statusCode": 500,
            "body": "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"><soap:Header><wsse:Security xmlns:wsse=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\" xmlns:wsu=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\" soap:mustUnderstand=\"1\"><ds:Signature xmlns:ds=\"http://www.w3.org/2000/09/xmldsig#\" Id=\"SIG-1037504\"><ds:SignedInfo><ds:CanonicalizationMethod Algorithm=\"http://www.w3.org/2001/10/xml-exc-c14n#\"><ec:InclusiveNamespaces xmlns:ec=\"http://www.w3.org/2001/10/xml-exc-c14n#\" PrefixList=\"soap\"/></ds:CanonicalizationMethod><ds:SignatureMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#rsa-sha1\"/><ds:Reference URI=\"#id-1037503\"><ds:Transforms><ds:Transform Algorithm=\"http://www.w3.org/2001/10/xml-exc-c14n#\"><ec:InclusiveNamespaces xmlns:ec=\"http://www.w3.org/2001/10/xml-exc-c14n#\" PrefixList=\"\"/></ds:Transform></ds:Transforms><ds:DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\"/><ds:DigestValue>kDFv8tyfbaGv5co0PuqmkdSzL50=</ds:DigestValue></ds:Reference></ds:SignedInfo><ds:SignatureValue>otwu102WzVVEV3kXqJrcCtQT/Xkte6bQD9K1W4tb66fnrcCMK3Uk+uJsUfmLZxQyZzGZfUG24Ldy\n/a/STGJd30FwgnOR2IKzujorSLqqFJaFvuQRn/mrqKDlrRC9EDadsn3RQHlEzNPNB0jBVrOcTobj\nHo1OofqOsgdC2NTPXDXA7MjsR3qPG9PC9OrFV0unAXCeUdG4nN926ZAIPs0hMebTLPMs9rj9Mumz\nmahevIrAZgfJJ16pV7xge3ekkDO93JQTYImqsKp7AuXEarfVHhy6rPq7fyjPfJooids9krHqoxns\nE5qRe+pvJTs71EQlXI0/NaEQ5wUxX7cU6EWELg==</ds:SignatureValue><ds:KeyInfo Id=\"KI-AFF6A1C21E97D2C94215303031813931556261\"><wsse:SecurityTokenReference wsu:Id=\"STR-AFF6A1C21E97D2C94215303031813931556262\"><ds:X509Data><ds:X509IssuerSerial><ds:X509IssuerName>CN=10,OU=PRD,O=transbank,L=Santiago,ST=RM,C=CL</ds:X509IssuerName><ds:X509SerialNumber>9876689033494141554</ds:X509SerialNumber></ds:X509IssuerSerial></ds:X509Data></wsse:SecurityTokenReference></ds:KeyInfo></ds:Signature></wsse:Security></soap:Header><soap:Body xmlns:wsu=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\" wsu:Id=\"id-1037503\"><soap:Fault><faultcode>soap:Server</faultcode><faultstring>&lt;!-- Timeout error(272) --></faultstring></soap:Fault></soap:Body></soap:Envelope>",
            "headers": {
                "connection": "close",
                "date": "Fri, 29 Jun 2018 20:13:01 GMT",
                "transfer-encoding": "chunked",
                "content-type": "text/xml; charset=UTF-8",
                "set-cookie": [
                    "dtCookie=843E8D2E7E30A199BE4FE72269F9B5E4; domain=.transbank.cl; path=/",
                    "cookie_webpay3g=!35cKArih4L6VBAICxjiACn6ARqnkUc/IYzSiL7Y5IiBDaNNOat8qL8D770lgywaiG8qqI0/LlKcv9pQZwKJQ7PPk0yT0zNR4KgxJ9z3RAA==; path=/; Httponly; Secure"
                ],
                "x-powered-by": "Servlet/2.5 JSP/2.1"
            },
            "request": {
                "uri": {
                    "protocol": "https:",
                    "slashes": true,
                    "auth": null,
                    "host": "webpay3g.transbank.cl:443",
                    "port": "443",
                    "hostname": "webpay3g.transbank.cl",
                    "hash": null,
                    "search": null,
                    "query": null,
                    "pathname": "/WSWebpayTransaction/cxf/WSWebpayService",
                    "path": "/WSWebpayTransaction/cxf/WSWebpayService",
                    "href": "https://webpay3g.transbank.cl:443/WSWebpayTransaction/cxf/WSWebpayService"
                },
                "method": "POST",
                "headers": {
                    "User-Agent": "node-soap/0.18.0",
                    "Accept": "text/html,application/xhtml+xml,application/xml,text/xml;q=0.9,*/*;q=0.8",
                    "Accept-Encoding": "none",
                    "Accept-Charset": "utf-8",
                    "Connection": "close",
                    "Host": "webpay3g.transbank.cl:443",
                    "Content-Length": 4572,
                    "Content-Type": "text/xml; charset=utf-8",
                    "SOAPAction": "\"\""
                }
            }
        },
        "body": "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"><soap:Header><wsse:Security xmlns:wsse=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\" xmlns:wsu=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\" soap:mustUnderstand=\"1\"><ds:Signature xmlns:ds=\"http://www.w3.org/2000/09/xmldsig#\" Id=\"SIG-1037504\"><ds:SignedInfo><ds:CanonicalizationMethod Algorithm=\"http://www.w3.org/2001/10/xml-exc-c14n#\"><ec:InclusiveNamespaces xmlns:ec=\"http://www.w3.org/2001/10/xml-exc-c14n#\" PrefixList=\"soap\"/></ds:CanonicalizationMethod><ds:SignatureMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#rsa-sha1\"/><ds:Reference URI=\"#id-1037503\"><ds:Transforms><ds:Transform Algorithm=\"http://www.w3.org/2001/10/xml-exc-c14n#\"><ec:InclusiveNamespaces xmlns:ec=\"http://www.w3.org/2001/10/xml-exc-c14n#\" PrefixList=\"\"/></ds:Transform></ds:Transforms><ds:DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\"/><ds:DigestValue>kDFv8tyfbaGv5co0PuqmkdSzL50=</ds:DigestValue></ds:Reference></ds:SignedInfo><ds:SignatureValue>otwu102WzVVEV3kXqJrcCtQT/Xkte6bQD9K1W4tb66fnrcCMK3Uk+uJsUfmLZxQyZzGZfUG24Ldy\n/a/STGJd30FwgnOR2IKzujorSLqqFJaFvuQRn/mrqKDlrRC9EDadsn3RQHlEzNPNB0jBVrOcTobj\nHo1OofqOsgdC2NTPXDXA7MjsR3qPG9PC9OrFV0unAXCeUdG4nN926ZAIPs0hMebTLPMs9rj9Mumz\nmahevIrAZgfJJ16pV7xge3ekkDO93JQTYImqsKp7AuXEarfVHhy6rPq7fyjPfJooids9krHqoxns\nE5qRe+pvJTs71EQlXI0/NaEQ5wUxX7cU6EWELg==</ds:SignatureValue><ds:KeyInfo Id=\"KI-AFF6A1C21E97D2C94215303031813931556261\"><wsse:SecurityTokenReference wsu:Id=\"STR-AFF6A1C21E97D2C94215303031813931556262\"><ds:X509Data><ds:X509IssuerSerial><ds:X509IssuerName>CN=10,OU=PRD,O=transbank,L=Santiago,ST=RM,C=CL</ds:X509IssuerName><ds:X509SerialNumber>9876689033494141554</ds:X509SerialNumber></ds:X509IssuerSerial></ds:X509Data></wsse:SecurityTokenReference></ds:KeyInfo></ds:Signature></wsse:Security></soap:Header><soap:Body xmlns:wsu=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\" wsu:Id=\"id-1037503\"><soap:Fault><faultcode>soap:Server</faultcode><faultstring>&lt;!-- Timeout error(272) --></faultstring></soap:Fault></soap:Body></soap:Envelope>"
    }
}

Sabes porque podria estar pasando este error, me da el timeout inmediatamente despues de hacer el pedido.

rgcl commented 6 years ago

Hola, dentro de getTransactionResult debes llamar a acknowledgeTransaction(...), el cual retorna una promesa. Al hacer esto le dices a Transbank que tomas conocimiento de la transacción (no se perdió por ahí por la red) y que por tanto Transbank puede darla por finalizada. Si no llamas a acknowledgeTransaction(...) dentro de cierto tiempo, te lanzará el error que mencionas.

Revisa un ejemplo de uso aquí: https://github.com/sapienman/webpay-nodejs/blob/master/showcase/testNormal.js#L101