Paypal IPN 不适用于 woocommerce

Posted

技术标签:

【中文标题】Paypal IPN 不适用于 woocommerce【英文标题】:Paypal IPN is not working with woocommerce 【发布时间】:2020-07-19 01:53:11 【问题描述】:

我刚刚尝试设置 Paypal-Payment。购买订单时,即使已在贝宝成功购买,订单也未处理并停留在“待付款”状态。我查看了 wc 日志,上面写着“收到来自 PayPal 的无效响应。

在 htaccess 中,我强制使用 https。我在某处红色表示 https 可能是一个问题,但我没有得到答案:

RewriteEngine On
RewriteCond %HTTPS !=on
RewriteRule ^ https://%HTTP_HOST%REQUEST_URI [L,R=301]

这是日志:

2020-04-06T22:58:20+00:00 INFO Received invalid response from PayPal IPN
2020-04-06T23:05:38+00:00 INFO Checking IPN response is valid
2020-04-06T23:05:40+00:00 INFO IPN Response: Array
(
    [headers] => Requests_Utility_CaseInsensitiveDictionary Object
        (
            [data:protected] => Array
                (
                    [cache-control] => max-age=0, no-cache, no-store, must-revalidate
                    [content-encoding] => gzip
                    [content-type] => text/html; charset=UTF-8
                    [paypal-debug-id] => e4c98f0598d92
                    [x-frame-options] => SAMEORIGIN
                    [content-length] => 33
                    [dc] => slc-b-origin-www-2.paypal.com
                    [date] => Mon, 06 Apr 2020 23:05:40 GMT
                    [vary] => Accept-Encoding
                    [set-cookie] => Array
                        (
                            [0] => cwrClyrK4LoCV1fydGbAxiNL6iG=PJUGIfuJg_KNPRMmTBqwlQPVKd6wlywLX0ACxxxSJgwep9Rim9f962iQBfN77mkmh0RIAJzlhtfExKYHyPMSqkJxUEiLM2G9t2jnv97qhVbovwDGM_utWOsWcvpX5rxihyq6W_OfibIik_6ppz8tC-CYr_3Ql1TNJRH5najO9n1b00S5MFxyBJxBLOscMf1EFJ7jl0sxUPUncEy_KRmz9Klaz4_g7w4NKzUHRg_Uk8IoWoOUG1KswPcfg58bODMhnrCGqSsukcMNX7uO9yXroBWIcCGP_7ygIYsmjGadodPPcH9Md6J4n1aZDnulZOmWmKPtOSyT0K5MJfu0Ysi0rwz_luyk_gbIxE3ieOGb-s0vN_aN1t5kNh3NxggHFBKLKVj-fCQ4lVuIBC0IjDwnOWcnc_H4idIfJYIy-17gTlt1EZm3GV6UiSeFjli; Path=/; Domain=paypal.com; HttpOnly; Secure
                            [1] => cookie_check=yes; Path=/; Domain=paypal.com; Expires=Thu, 04 Apr 2030 23:05:40 GMT; HttpOnly; Secure
                            [2] => navcmd=_notify-validate; Path=/; Domain=paypal.com; HttpOnly; Secure
                            [3] => navlns=0.0; Path=/; Domain=paypal.com; Expires=Wed, 06 Apr 2022 23:05:40 GMT; HttpOnly; Secure
                            [4] => X-PP-SILOVER=name%3DLIVE6.WEB.1%26silo_version%3D880%26app%3Dappdispatcher%26TIME%3D1586214340%26HTTP_X_PP_AZ_LOCATOR%3Ddcg14.slc; Path=/; Domain=paypal.com; Expires=Mon, 06 Apr 2020 23:35:40 GMT; HttpOnly; Secure
                            [5] => X-PP-L7=1; Path=/; Domain=paypal.com; Secure
                            [6] => akavpau_ppsd=1586214940~id=1845e1edd1d3ea70e90442f2f8c7a479; Domain=www.paypal.com; Path=/; Secure; SameSite=None
                        )

                    [strict-transport-security] => max-age=63072000
                )

        )

    [body] => INVALID
    [response] => Array
        (
            [code] => 200
            [message] => OK
        )

    [cookies] => Array
        (
            [0] => WP_Http_Cookie Object
                (
                    [name] => cwrClyrK4LoCV1fydGbAxiNL6iG
                    [value] => PJUGIfuJg_KNPRMmTBqwlQPVKd6wlywLX0ACxxxSJgwep9Rim9f962iQBfN77mkmh0RIAJzlhtfExKYHyPMSqkJxUEiLM2G9t2jnv97qhVbovwDGM_utWOsWcvpX5rxihyq6W_OfibIik_6ppz8tC-CYr_3Ql1TNJRH5najO9n1b00S5MFxyBJxBLOscMf1EFJ7jl0sxUPUncEy_KRmz9Klaz4_g7w4NKzUHRg_Uk8IoWoOUG1KswPcfg58bODMhnrCGqSsukcMNX7uO9yXroBWIcCGP_7ygIYsmjGadodPPcH9Md6J4n1aZDnulZOmWmKPtOSyT0K5MJfu0Ysi0rwz_luyk_gbIxE3ieOGb-s0vN_aN1t5kNh3NxggHFBKLKVj-fCQ4lVuIBC0IjDwnOWcnc_H4idIfJYIy-17gTlt1EZm3GV6UiSeFjli
                    [expires] => 
                    [path] => /
                    [domain] => paypal.com
                    [host_only] => 
                )

            [1] => WP_Http_Cookie Object
                (
                    [name] => cookie_check
                    [value] => yes
                    [expires] => 1901574340
                    [path] => /
                    [domain] => paypal.com
                    [host_only] => 
                )

            [2] => WP_Http_Cookie Object
                (
                    [name] => navcmd
                    [value] => _notify-validate
                    [expires] => 
                    [path] => /
                    [domain] => paypal.com
                    [host_only] => 
                )

            [3] => WP_Http_Cookie Object
                (
                    [name] => navlns
                    [value] => 0.0
                    [expires] => 1649286340
                    [path] => /
                    [domain] => paypal.com
                    [host_only] => 
                )

            [4] => WP_Http_Cookie Object
                (
                    [name] => X-PP-SILOVER
                    [value] => name=LIVE6.WEB.1&silo_version=880&app=appdispatcher&TIME=1586214340&HTTP_X_PP_AZ_LOCATOR=dcg14.slc
                    [expires] => 1586216140
                    [path] => /
                    [domain] => paypal.com
                    [host_only] => 
                )

            [5] => WP_Http_Cookie Object
                (
                    [name] => X-PP-L7
                    [value] => 1
                    [expires] => 
                    [path] => /
                    [domain] => paypal.com
                    [host_only] => 
                )

            [6] => WP_Http_Cookie Object
                (
                    [name] => akavpau_ppsd
                    [value] => 1586214940~id=1845e1edd1d3ea70e90442f2f8c7a479
                    [expires] => 
                    [path] => /
                    [domain] => www.paypal.com
                    [host_only] => 
                )

        )

    [filename] => 
    [http_response] => WP_HTTP_Requests_Response Object
        (
            [response:protected] => Requests_Response Object
                (
                    [body] => INVALID
                    [raw] => HTTP/1.1 200 OK
Cache-Control: max-age=0, no-cache, no-store, must-revalidate
Content-Encoding: gzip
Content-Type: text/html; charset=UTF-8
Paypal-Debug-Id: e4c98f0598d92
X-Frame-Options: SAMEORIGIN
Content-Length: 33
DC: slc-b-origin-www-2.paypal.com
Date: Mon, 06 Apr 2020 23:05:40 GMT
Connection: close
Vary: Accept-Encoding
Set-Cookie: cwrClyrK4LoCV1fydGbAxiNL6iG=PJUGIfuJg_KNPRMmTBqwlQPVKd6wlywLX0ACxxxSJgwep9Rim9f962iQBfN77mkmh0RIAJzlhtfExKYHyPMSqkJxUEiLM2G9t2jnv97qhVbovwDGM_utWOsWcvpX5rxihyq6W_OfibIik_6ppz8tC-CYr_3Ql1TNJRH5najO9n1b00S5MFxyBJxBLOscMf1EFJ7jl0sxUPUncEy_KRmz9Klaz4_g7w4NKzUHRg_Uk8IoWoOUG1KswPcfg58bODMhnrCGqSsukcMNX7uO9yXroBWIcCGP_7ygIYsmjGadodPPcH9Md6J4n1aZDnulZOmWmKPtOSyT0K5MJfu0Ysi0rwz_luyk_gbIxE3ieOGb-s0vN_aN1t5kNh3NxggHFBKLKVj-fCQ4lVuIBC0IjDwnOWcnc_H4idIfJYIy-17gTlt1EZm3GV6UiSeFjli; Path=/; Domain=paypal.com; HttpOnly; Secure
Set-Cookie: cookie_check=yes; Path=/; Domain=paypal.com; Expires=Thu, 04 Apr 2030 23:05:40 GMT; HttpOnly; Secure
Set-Cookie: navcmd=_notify-validate; Path=/; Domain=paypal.com; HttpOnly; Secure
Set-Cookie: navlns=0.0; Path=/; Domain=paypal.com; Expires=Wed, 06 Apr 2022 23:05:40 GMT; HttpOnly; Secure
Set-Cookie: X-PP-SILOVER=name%3DLIVE6.WEB.1%26silo_version%3D880%26app%3Dappdispatcher%26TIME%3D1586214340%26HTTP_X_PP_AZ_LOCATOR%3Ddcg14.slc; Path=/; Domain=paypal.com; Expires=Mon, 06 Apr 2020 23:35:40 GMT; HttpOnly; Secure
Set-Cookie: X-PP-L7=1; Path=/; Domain=paypal.com; Secure
Set-Cookie: akavpau_ppsd=1586214940~id=1845e1edd1d3ea70e90442f2f8c7a479; Domain=www.paypal.com; Path=/; Secure; SameSite=None
Strict-Transport-Security: max-age=63072000

INVALID
                    [headers] => Requests_Response_Headers Object
                        (
                            [data:protected] => Array
                                (
                                    [cache-control] => Array
                                        (
                                            [0] => max-age=0, no-cache, no-store, must-revalidate
                                        )

                                    [content-encoding] => Array
                                        (
                                            [0] => gzip
                                        )

                                    [content-type] => Array
                                        (
                                            [0] => text/html; charset=UTF-8
                                        )

                                    [paypal-debug-id] => Array
                                        (
                                            [0] => e4c98f0598d92
                                        )

                                    [x-frame-options] => Array
                                        (
                                            [0] => SAMEORIGIN
                                        )

                                    [content-length] => Array
                                        (
                                            [0] => 33
                                        )

                                    [dc] => Array
                                        (
                                            [0] => slc-b-origin-www-2.paypal.com
                                        )

                                    [date] => Array
                                        (
                                            [0] => Mon, 06 Apr 2020 23:05:40 GMT
                                        )

                                    [vary] => Array
                                        (
                                            [0] => Accept-Encoding
                                        )

                                    [set-cookie] => Array
                                        (
                                            [0] => cwrClyrK4LoCV1fydGbAxiNL6iG=PJUGIfuJg_KNPRMmTBqwlQPVKd6wlywLX0ACxxxSJgwep9Rim9f962iQBfN77mkmh0RIAJzlhtfExKYHyPMSqkJxUEiLM2G9t2jnv97qhVbovwDGM_utWOsWcvpX5rxihyq6W_OfibIik_6ppz8tC-CYr_3Ql1TNJRH5najO9n1b00S5MFxyBJxBLOscMf1EFJ7jl0sxUPUncEy_KRmz9Klaz4_g7w4NKzUHRg_Uk8IoWoOUG1KswPcfg58bODMhnrCGqSsukcMNX7uO9yXroBWIcCGP_7ygIYsmjGadodPPcH9Md6J4n1aZDnulZOmWmKPtOSyT0K5MJfu0Ysi0rwz_luyk_gbIxE3ieOGb-s0vN_aN1t5kNh3NxggHFBKLKVj-fCQ4lVuIBC0IjDwnOWcnc_H4idIfJYIy-17gTlt1EZm3GV6UiSeFjli; Path=/; Domain=paypal.com; HttpOnly; Secure
                                            [1] => cookie_check=yes; Path=/; Domain=paypal.com; Expires=Thu, 04 Apr 2030 23:05:40 GMT; HttpOnly; Secure
                                            [2] => navcmd=_notify-validate; Path=/; Domain=paypal.com; HttpOnly; Secure
                                            [3] => navlns=0.0; Path=/; Domain=paypal.com; Expires=Wed, 06 Apr 2022 23:05:40 GMT; HttpOnly; Secure
                                            [4] => X-PP-SILOVER=name%3DLIVE6.WEB.1%26silo_version%3D880%26app%3Dappdispatcher%26TIME%3D1586214340%26HTTP_X_PP_AZ_LOCATOR%3Ddcg14.slc; Path=/; Domain=paypal.com; Expires=Mon, 06 Apr 2020 23:35:40 GMT; HttpOnly; Secure
                                            [5] => X-PP-L7=1; Path=/; Domain=paypal.com; Secure
                                            [6] => akavpau_ppsd=1586214940~id=1845e1edd1d3ea70e90442f2f8c7a479; Domain=www.paypal.com; Path=/; Secure; SameSite=None
                                        )

                                    [strict-transport-security] => Array
                                        (
                                            [0] => max-age=63072000
                                        )

                                )

                        )

                    [status_code] => 200
                    [protocol_version] => 1.1
                    [success] => 1
                    [redirects] => 0
                    [url] => https://www.paypal.com/cgi-bin/webscr
                    [history] => Array
                        (
                        )

                    [cookies] => Requests_Cookie_Jar Object
                        (
                            [cookies:protected] => Array
                                (
                                    [cwrClyrK4LoCV1fydGbAxiNL6iG] => Requests_Cookie Object
                                        (
                                            [name] => cwrClyrK4LoCV1fydGbAxiNL6iG
                                            [value] => PJUGIfuJg_KNPRMmTBqwlQPVKd6wlywLX0ACxxxSJgwep9Rim9f962iQBfN77mkmh0RIAJzlhtfExKYHyPMSqkJxUEiLM2G9t2jnv97qhVbovwDGM_utWOsWcvpX5rxihyq6W_OfibIik_6ppz8tC-CYr_3Ql1TNJRH5najO9n1b00S5MFxyBJxBLOscMf1EFJ7jl0sxUPUncEy_KRmz9Klaz4_g7w4NKzUHRg_Uk8IoWoOUG1KswPcfg58bODMhnrCGqSsukcMNX7uO9yXroBWIcCGP_7ygIYsmjGadodPPcH9Md6J4n1aZDnulZOmWmKPtOSyT0K5MJfu0Ysi0rwz_luyk_gbIxE3ieOGb-s0vN_aN1t5kNh3NxggHFBKLKVj-fCQ4lVuIBC0IjDwnOWcnc_H4idIfJYIy-17gTlt1EZm3GV6UiSeFjli
                                            [attributes] => Requests_Utility_CaseInsensitiveDictionary Object
                                                (
                                                    [data:protected] => Array
                                                        (
                                                            [path] => /
                                                            [domain] => paypal.com
                                                            [httponly] => 1
                                                            [secure] => 1
                                                        )

                                                )

                                            [flags] => Array
                                                (
                                                    [creation] => 1586214340
                                                    [last-access] => 1586214340
                                                    [persistent] => 
                                                    [host-only] => 
                                                )

                                            [reference_time] => 1586214340
                                        )

                                    [cookie_check] => Requests_Cookie Object
                                        (
                                            [name] => cookie_check
                                            [value] => yes
                                            [attributes] => Requests_Utility_CaseInsensitiveDictionary Object
                                                (
                                                    [data:protected] => Array
                                                        (
                                                            [path] => /
                                                            [domain] => paypal.com
                                                            [expires] => 1901574340
                                                            [httponly] => 1
                                                            [secure] => 1
                                                        )

                                                )

                                            [flags] => Array
                                                (
                                                    [creation] => 1586214340
                                                    [last-access] => 1586214340
                                                    [persistent] => 
                                                    [host-only] => 
                                                )

                                            [reference_time] => 1586214340
                                        )

                                    [navcmd] => Requests_Cookie Object
                                        (
                                            [name] => navcmd
                                            [value] => _notify-validate
                                            [attributes] => Requests_Utility_CaseInsensitiveDictionary Object
                                                (
                                                    [data:protected] => Array
                                                        (
                                                            [path] => /
                                                            [domain] => paypal.com
                                                            [httponly] => 1
                                                            [secure] => 1
                                                        )

                                                )

                                            [flags] => Array
                                                (
                                                    [creation] => 1586214340
                                                    [last-access] => 1586214340
                                                    [persistent] => 
                                                    [host-only] => 
                                                )

                                            [reference_time] => 1586214340
                                        )

                                    [navlns] => Requests_Cookie Object
                                        (
                                            [name] => navlns
                                            [value] => 0.0
                                            [attributes] => Requests_Utility_CaseInsensitiveDictionary Object
                                                (
                                                    [data:protected] => Array
                                                        (
                                                            [path] => /
                                                            [domain] => paypal.com
                                                            [expires] => 1649286340
                                                            [httponly] => 1
                                                            [secure] => 1
                                                        )

                                                )

                                            [flags] => Array
                                                (
                                                    [creation] => 1586214340
                                                    [last-access] => 1586214340
                                                    [persistent] => 
                                                    [host-only] => 
                                                )

                                            [reference_time] => 1586214340
                                        )

                                    [X-PP-SILOVER] => Requests_Cookie Object
                                        (
                                            [name] => X-PP-SILOVER
                                            [value] => name%3DLIVE6.WEB.1%26silo_version%3D880%26app%3Dappdispatcher%26TIME%3D1586214340%26HTTP_X_PP_AZ_LOCATOR%3Ddcg14.slc
                                            [attributes] => Requests_Utility_CaseInsensitiveDictionary Object
                                                (
                                                    [data:protected] => Array
                                                        (
                                                            [path] => /
                                                            [domain] => paypal.com
                                                            [expires] => 1586216140
                                                            [httponly] => 1
                                                            [secure] => 1
                                                        )

                                                )

                                            [flags] => Array
                                                (
                                                    [creation] => 1586214340
                                                    [last-access] => 1586214340
                                                    [persistent] => 
                                                    [host-only] => 
                                                )

                                            [reference_time] => 1586214340
                                        )

                                    [X-PP-L7] => Requests_Cookie Object
                                        (
                                            [name] => X-PP-L7
                                            [value] => 1
                                            [attributes] => Requests_Utility_CaseInsensitiveDictionary Object
                                                (
                                                    [data:protected] => Array
                                                        (
                                                            [path] => /
                                                            [domain] => paypal.com
                                                            [secure] => 1
                                                        )

                                                )

                                            [flags] => Array
                                                (
                                                    [creation] => 1586214340
                                                    [last-access] => 1586214340
                                                    [persistent] => 
                                                    [host-only] => 
                                                )

                                            [reference_time] => 1586214340
                                        )

                                    [akavpau_ppsd] => Requests_Cookie Object
                                        (
                                            [name] => akavpau_ppsd
                                            [value] => 1586214940~id=1845e1edd1d3ea70e90442f2f8c7a479
                                            [attributes] => Requests_Utility_CaseInsensitiveDictionary Object
                                                (
                                                    [data:protected] => Array
                                                        (
                                                            [domain] => www.paypal.com
                                                            [path] => /
                                                            [secure] => 1
                                                            [samesite] => None
                                                        )

                                                )

                                            [flags] => Array
                                                (
                                                    [creation] => 1586214340
                                                    [last-access] => 1586214340
                                                    [persistent] => 
                                                    [host-only] => 
                                                )

                                            [reference_time] => 1586214340
                                        )

                                )

                        )

                )

            [filename:protected] => 
            [data] => 
            [headers] => 
            [status] => 
        )

)

2020-04-06T23:05:40+00:00 INFO Received invalid response from PayPal IPN

有人可以帮帮我吗?谢谢!

【问题讨论】:

【参考方案1】:

您正在记录标头/cookie,这不是很有用。您应该记录收到的原始 IPN POST 正文,这应该与您在 PayPal 帐户 https://www.paypal.com/cgi-bin/webscr?cmd=_display-ipns-history 中的记录相同。同时,您应该立即使用cmd=notify-validate 将您发送内容的 GET/POST 字符串记录回 PayPal,并收到“无效”响应。然后你就可以着手确定出了什么问题。

【讨论】:

谢谢 - 我会试试那个。我刚刚通过使用另一个 PaypalPlugin for Woocommerce 解决了这个问题。不是最好的方法,但至少到目前为止工作。

以上是关于Paypal IPN 不适用于 woocommerce的主要内容,如果未能解决你的问题,请参考以下文章

PayPal IPN 适用于单个购物车项目,但不适用于多个购物车项目

IPN 适用于“客人”付款,但不适用于贝宝帐户持有人

Paypal IPN 在沙盒 ipn sinulator 中有效,但在交易中无效

用于取消计费协议的 Paypal IPN

用于电子支票的 PayPal IPN

用于 paypal ipn 的 curl 或 fsockopen