英文:
Paypal sandbox verify webhook always return FAILURE
问题
我在golang中运行它,使用沙箱,没有使用webhooks模拟器,并使用http.NewRequest POST /v1/notifications/verify-webhook-signature
进行验证。
头部已经使用access_token。
var verifyData struct {
AuthAlgo string `json:"auth_algo"`
CertUrl string `json:"cert_url"`
TransmissionId string `json:"transmission_id"`
TransmissionSig string `json:"transmission_sig"`
TransmissionTime string `json:"transmission_time"`
WebhookEvent map[string]interface{} `json:"webhook_event"`
WebhookId string `json:"webhook_id"`
}
但它总是返回{"verification_status":"FAILURE"}
,所有的webhook验证都是一样的。
我尝试打印日志。
但WebhookEvent
与webhook的http.Body()
数据相同。
其他数据与webhook的http.Header
数据相同。
来自webhook头部的数据
Paypal-Auth-Algo:SHA256withRSA
Paypal-Cert-Url:https://api.sandbox.paypal.com/v1/notifications/certs/CERT-360caa42-fca2a594-********
Paypal-Transmission-Id:422dea50-c3ac-****-****-b9f65296f9e3
Paypal-Transmission-Sig:Col8aQ2wP+qVt6Xe8XBXwWX6ANyFVlEfdTCgScqRD3mbCYZb0p5yh5uWNLQ8sPAbIXByuOrYs7+******+Ty+5UpFyj+x3CTTXlQgyAmWdiETlfE93tpjVY1OZhLDYDrdUVdF9PIT1snS0pmRX17vVcxN9GooqFd7BeZCJoPo83MWxV2V+0wcpGtxG2V5tw17xTF9XLiTIAsnNVZw/*********/NMvopi3P7EJUWteqtxrow/fmf27uUhTmLtF9sNFcOP2nBKIPDo0Wearf78P1Yr2gLDxfis3s8d/qNWqSs75Mk7wOm/YQrj2R74jikQFU46v3UD5tYrwIBh77Hg==
Paypal-Transmission-Time:2023-03-16T03:40:13Z
webhook_event
来自http.Body()
,它使用json.Unmarshal
转换为map[string]interface{}
。
webhook_id
来自应用程序,沙箱webhooks。
我尝试了各种方法来更改webhook_event
,但仍然不起作用。
我不知道如何在golang中使用<transmissionId>|<timeStamp>|<webhookId>|<crc32>
,所以我现在使用http.post,请帮忙。
英文:
I was run it in golang, sandbox, not use the webhooks simulator, and use http.NewRequest POST /v1/notifications/verify-webhook-signature
to verify
header are already use access_token
var verifyData struct {
AuthAlgo string `json:"auth_algo"`
CertUrl string `json:"cert_url"`
TransmissionId string `json:"transmission_id"`
TransmissionSig string `json:"transmission_sig"`
TransmissionTime string `json:"transmission_time"`
WebhookEvent map[string]interface{} `json:"webhook_event"`
WebhookId string `json:"webhook_id"`
}
but it always return {"verification_status":"FAILURE"}
, all webhook verify are the same
i try to Println logs
but the WebhookEvent
are the same as webhook http.Body()
data
other data are the same as webhook http.Header
data
data from webhook header
Paypal-Auth-Algo:SHA256withRSA
Paypal-Cert-Url:https://api.sandbox.paypal.com/v1/notifications/certs/CERT-360caa42-fca2a594-********
Paypal-Transmission-Id:422dea50-c3ac-****-****-b9f65296f9e3
Paypal-Transmission-Sig:Col8aQ2wP+qVt6Xe8XBXwWX6ANyFVlEfdTCgScqRD3mbCYZb0p5yh5uWNLQ8sPAbIXByuOrYs7+******+Ty+5UpFyj+x3CTTXlQgyAmWdiETlfE93tpjVY1OZhLDYDrdUVdF9PIT1snS0pmRX17vVcxN9GooqFd7BeZCJoPo83MWxV2V+0wcpGtxG2V5tw17xTF9XLiTIAsnNVZw/*********/NMvopi3P7EJUWteqtxrow/fmf27uUhTmLtF9sNFcOP2nBKIPDo0Wearf78P1Yr2gLDxfis3s8d/qNWqSs75Mk7wOm/YQrj2R74jikQFU46v3UD5tYrwIBh77Hg==
Paypal-Transmission-Time:2023-03-16T03:40:13Z
and webhook_event
are from http.Body()
, it's use json.Unmarshal
to map[string]interface{}
webhook_id
from apps,SANDBOX WEBHOOKS
i try any ways to change webhook_event, still not work
i don't know how to use <transmissionId>|<timeStamp>|<webhookId>|<crc32>
in golang, so i use http.post now, please help
答案1
得分: 1
我从头部中使用了Paypal-Auth-Algo
、Paypal-Cert-Url
、Paypal-Transmission-Id
、Paypal-Transmission-Sig
和Paypal-Transmission-Time
,以及所有的webhook body interface{}
和来自应用程序/ webhook的webhook_id。
英文:
my example from sandbox
--webhook request headers--
map[
Accept:*/* Content-Length:1142
Content-Type:application/json
Correlation-Id:f941618bd2165
Host:filepipe.dev
Paypal-Auth-Algo:SHA256withRSA
Paypal-Auth-Version:v2
Paypal-Cert-Url:https://api.sandbox.paypal.com/v1/notifications/certs/CERT-360caa42-fca2a594-5a29e601
Paypal-Transmission-Id:99d97fc0-c3ad-11ed-8ada-d722609ae478
Paypal-Transmission-Sig:PrZDo9fmpTshwt/JY6/HvJDceR5kCj3GhAxdiBSIdtsC7Y91+ww6hd8Qk5zpnJ3KN1itLYSxFnTQLOgtOYZtSzXsQaAeo7oSqxUAaV+jXtF3a63zR0zg9NRHfNjf4L7JuGJ0WDz2I4d4026GZ4yXjr3sNc3zN6dEwZBEQT0zc+bwZjariIC3WQv7uLCPKbvl6g49OhQC6xS5cJkB837D3svUIlT/9PEJ5mp1WCCijwOypUpCoP1lXGWHx1pVvtTPd4Q3ANSSASFJDs4ubJKgH5CPNiv+eT9GNs5JGXQv/1qlvCN+Ph2v/OKgz6yM5gbPS3XnldccXwnzeGcenPvl5w==
Paypal-Transmission-Time:2023-03-16T03:49:49Z
User-Agent:PayPal/AUHR-214.0-58031014
X-B3-Spanid:3d19edb457d98398
X-Forwarded-For:173.0.80.116
X-Forwarded-Host:filepipe.dev
X-Forwarded-Port:443
X-Forwarded-Proto:https
X-Forwarded-Scheme:https
X-Real-Ip:173.0.80.116
X-Request-Id:fd024917ba5320920ea36735f2460a47
X-Scheme:https
]
--webhook body json--
{
"id": "WH-47139463N7609432M-6FD472938E900521U",
"event_version": "1.0",
"create_time": "2023-03-16T03:49:46.098Z",
"resource_type": "subscription",
"resource_version": "2.0",
"event_type": "BILLING.SUBSCRIPTION.CREATED",
"summary": "Subscription created",
"resource": {
"start_time": "2023-03-16T03:49:45Z",
"quantity": "1",
"create_time": "2023-03-16T03:49:45Z",
"custom_id": "3",
"links": [
{
"href": "https://www.sandbox.paypal.com/webapps/billing/subscriptions?ba_token=BA-7RE73133KF159744D",
"rel": "approve",
"method": "GET"
},
{
"href": "https://api.sandbox.paypal.com/v1/billing/subscriptions/I-LMA62KG79TL5",
"rel": "edit",
"method": "PATCH"
},
{
"href": "https://api.sandbox.paypal.com/v1/billing/subscriptions/I-LMA62KG79TL5",
"rel": "self",
"method": "GET"
}
],
"id": "I-LMA62KG79TL5",
"plan_overridden": false,
"plan_id": "P-2M355934NH158234GMQIXO2Q",
"status": "APPROVAL_PENDING"
},
"links": [
{
"href": "https://api.sandbox.paypal.com/v1/notifications/webhooks-events/WH-47139463N7609432M-6FD472938E900521U",
"rel": "self",
"method": "GET"
},
{
"href": "https://api.sandbox.paypal.com/v1/notifications/webhooks-events/WH-47139463N7609432M-6FD472938E900521U/resend",
"rel": "resend",
"method": "POST"
}
]
}
--webhook body interface{}--
map[
create_time:2023-03-16T03:49:46.098Z
event_type:BILLING.SUBSCRIPTION.CREATED
event_version:1.0
id:WH-47139463N7609432M-6FD472938E900521U
links:[
map[
href:https://api.sandbox.paypal.com/v1/notifications/webhooks-events/WH-47139463N7609432M-6FD472938E900521U
method:GET
rel:self
]
map[
href:https://api.sandbox.paypal.com/v1/notifications/webhooks-events/WH-47139463N7609432M-6FD472938E900521U/resend
method:POST
rel:resend
]
]
resource:
map[
create_time:2023-03-16T03:49:45Z
custom_id:3
id:I-LMA62KG79TL5
links:[
map[
href:https://www.sandbox.paypal.com/webapps/billing/subscriptions?ba_token=BA-7RE73133KF159744D
method:GET
rel:approve
]
map[
href:https://api.sandbox.paypal.com/v1/billing/subscriptions/I-LMA62KG79TL5
method:PATCH
rel:edit
]
map[
href:https://api.sandbox.paypal.com/v1/billing/subscriptions/I-LMA62KG79TL5
method:GET
rel:self
]
]
plan_id:P-2M355934NH158234GMQIXO2Q
plan_overridden:false
quantity:1
start_time:2023-03-16T03:49:45Z
status:APPROVAL_PENDING
]
resource_type:subscription
resource_version:2.0
summary:Subscription created
]
--send verify data--
{
"auth_algo": "SHA256withRSA",
"cert_url": "https://api.sandbox.paypal.com/v1/notifications/certs/CERT-360caa42-fca2a594-5a29e601",
"transmission_id": "99d97fc0-c3ad-11ed-8ada-d722609ae478",
"transmission_sig": "PrZDo9fmpTshwt/JY6/HvJDceR5kCj3GhAxdiBSIdtsC7Y91+ww6hd8Qk5zpnJ3KN1itLYSxFnTQLOgtOYZtSzXsQaAeo7oSqxUAaV+jXtF3a63zR0zg9NRHfNjf4L7JuGJ0WDz2I4d4026GZ4yXjr3sNc3zN6dEwZBEQT0zc+bwZjariIC3WQv7uLCPKbvl6g49OhQC6xS5cJkB837D3svUIlT/9PEJ5mp1WCCijwOypUpCoP1lXGWHx1pVvtTPd4Q3ANSSASFJDs4ubJKgH5CPNiv+eT9GNs5JGXQv/1qlvCN+Ph2v/OKgz6yM5gbPS3XnldccXwnzeGcenPvl5w==",
"transmission_time": "2023-03-16T03:49:49Z",
"webhook_event": {
"create_time": "2023-03-16T03:49:46.098Z",
"event_type": "BILLING.SUBSCRIPTION.CREATED",
"event_version": "1.0",
"id": "WH-47139463N7609432M-6FD472938E900521U",
"links": [
{
"href": "https://api.sandbox.paypal.com/v1/notifications/webhooks-events/WH-47139463N7609432M-6FD472938E900521U",
"method": "GET",
"rel": "self"
},
{
"href": "https://api.sandbox.paypal.com/v1/notifications/webhooks-events/WH-47139463N7609432M-6FD472938E900521U/resend",
"method": "POST",
"rel": "resend"
}
],
"resource": {
"create_time": "2023-03-16T03:49:45Z",
"custom_id": "3",
"id": "I-LMA62KG79TL5",
"links": [
{
"href": "https://www.sandbox.paypal.com/webapps/billing/subscriptions?ba_token=BA-7RE73133KF159744D",
"method": "GET",
"rel": "approve"
},
{
"href": "https://api.sandbox.paypal.com/v1/billing/subscriptions/I-LMA62KG79TL5",
"method": "PATCH",
"rel": "edit"
},
{
"href": "https://api.sandbox.paypal.com/v1/billing/subscriptions/I-LMA62KG79TL5",
"method": "GET",
"rel": "self"
}
],
"plan_id": "P-2M355934NH158234GMQIXO2Q",
"plan_overridden": false,
"quantity": "1",
"start_time": "2023-03-16T03:49:45Z",
"status": "APPROVAL_PENDING"
},
"resource_type": "subscription",
"resource_version": "2.0",
"summary": "Subscription created"
},
"webhook_id": "9FU18601MK8788***" (webhook id)
}
--verify data--
{"verification_status":"FAILURE"}
i was use Paypal-Auth-Algo
Paypal-Cert-Url
Paypal-Transmission-Id
Paypal-Transmission-Sig
Paypal-Transmission-Time
from header, and all webhook body interface{}
, and the webhook_id from apps/webhook
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论