gpt4 book ai didi

php - 如何链接 PayPal webhook 和用户?

转载 作者:太空宇宙 更新时间:2023-11-03 15:47:06 26 4
gpt4 key购买 nike

我想我在这里看的东西非常简单。

当我通过 PayPal PHP SDK 创建新的计费协议(protocol)时,我通过以下 URL 返回到我的商店..

/paypal-success?success=true&token=EC-3K353628LH3197445  

我已经为 Subscription Created 事件创建了一个 WebHook,它按如下方式发布 JSON

{
"id": "WH-5UR49681MC703253M-3S161814MB664705V",
"event_version": "1.0",
"create_time": "2018-03-17T17:21:47.120Z",
"resource_type": "Agreement",
"event_type": "BILLING.SUBSCRIPTION.CREATED",
"summary": "A billing subscription was created",
"resource": {
"agreement_details": {
"outstanding_balance": {
"value": "0.00"
},
"num_cycles_remaining": "0",
"num_cycles_completed": "0",
"next_billing_date": "2018-03-17T10:00:00Z",
"last_payment_date": "2018-03-17T17:21:44Z",
"last_payment_amount": {
"value": "1.00"
},
"final_payment_due_date": "1970-01-01T00:00:00Z",
"failed_payment_count": "0"
},
"description": "x",
"links": [{
"href": "api.sandbox.paypal.com/v1/payments/billing-agreements/I-55KA5N9GPPJW",
"rel": "self",
"method": "GET"
}],
"shipping_address": {
"recipient_name": "test buyer",
"line1": "Spitalfields Arts Market, 112 Brick Lane,",
"city": "London",
"state": "London",
"postal_code": "E1 6RL",
"country_code": "GB"
},
"id": "I-55KA5N9GPPJW",
"state": "Active",
"payer": {
"payment_method": "paypal",
"status": "verified",
"payer_info": {
"email": "jamie-buyer@x.com",
"first_name": "test",
"last_name": "buyer",
"payer_id": "Q3TZFN4F7NHJ6",
"shipping_address": {
"recipient_name": "test buyer",
"line1": "Spitalfields Arts Market, 112 Brick Lane,",
"city": "London",
"state": "London",
"postal_code": "E1 6RL",
"country_code": "GB"
}
}
},
"plan": {
"curr_code": "USD",
"links": [],
"payment_definitions": [{
"type": "REGULAR",
"frequency": "Month",
"frequency_interval": "1",
"amount": {
"value": "49.99"
},
"cycles": "0",
"charge_models": [{
"type": "TAX",
"amount": {
"value": "0.00"
}
},
{
"type": "SHIPPING",
"amount": {
"value": "0.00"
}
}]
}],
"merchant_preferences": {
"setup_fee": {
"value": "1.00"
},
"auto_bill_amount": "YES",
"max_fail_attempts": "0"
}
},
"start_date": "2018-03-17T00:00:00Z"
},
"links": [{
"href": "https://api.sandbox.paypal.com/v1/notifications/webhooks-events/WH-5UR49681MC703253M-3S161814MB664705V",
"rel": "self",
"method": "GET"
},
{
"href": "https://api.sandbox.paypal.com/v1/notifications/webhooks-events/WH-5UR49681MC703253M-3S161814MB664705V/resend",
"rel": "resend",
"method": "POST"
}]
}

当用户被重定向回我的商店时生成的 token 似乎不在 WebHooks JSON 中。

一旦您的 PayPal 用户被重定向回您的商店,您如何将他们链接到传入的 WebHooks

最佳答案

您成功url中返回的token用于用户在PayPal上接受协议(protocol)后激活协议(protocol)。激活协议(protocol)后,您可以检索协议(protocol) ID。该 id 位于资源/id 下的网络 Hook 中。 “id”:“I-55KA5N9GPPJW”。可能有更好的方法来处理这个问题,但我创建了一个将协议(protocol) ID 与用户 ID 相关联的订阅表,以及一个包含协议(protocol) ID 和关联的 webhook 信息的交易表。

关于php - 如何链接 PayPal webhook 和用户?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49340065/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com