我正在使用PayPal PHP API设置订阅/定期付款流程。到目前为止,除了一件事-Webhooks之外,一切似乎都可以在沙箱中正常工作。即使Webhook事件显示为在线“发送”,我似乎也从未收到过它们。
我已经检查了webhook事件,并且其中的webhook URL(“传输”->“ webhook_url”)是正确的。如果我在浏览器中访问该URL,则在代码中设置的记录器将正确记录该URL。但是,当贝宝(PayPal)表示已发送Webhook时,我在日志中看不到任何内容(同样,即使它说它已在开发人员控制台中成功发送了Webhook)。
以下是PayPal所说的已发送的Webhook事件之一:
library(shiny)
library(tidyverse)
ui <- fluidPage(
mainPanel(
DT::dataTableOutput("flag"),
actionButton("exclude", "Exclude")
)
)
server <- function(input, output) {
df <- data.frame(id = 1:10, fu_score = 1:10,
stringsAsFactors = FALSE)
if (file.exists("data/prev_exclude.Rda")) {
load("data/prev_exclude.Rda")
} else {
prev_exclude <- data.frame(id = 0, fu_score = 0, stringsAsFactors = FALSE)
save(prev_exclude, file = "data/prev_exclude.Rda")
}
df_flag <- reactive({
df %>%
anti_join(., prev_exclude, by = c("id", "fu_score"))
})
output$flag <- DT::renderDataTable({
DT::datatable(df_flag(), options = list(paging = FALSE))
})
selected_prev <- eventReactive(input$flag_rows_selected, {
data.frame(id = df_flag()$id[c(input$flag_rows_selected)],
fu_score = df_flag()$fu_score[c(input$flag_rows_selected)])
})
observeEvent(input$exclude, {
prev_exclude <- isolate(bind_rows(selected_prev(), prev_exclude))
save(prev_exclude, file="data/prev_exclude.Rda")
load("data/prev_exclude.Rda")
})
}
# Run the application
shinyApp(ui = ui, server = server)
以及实际的Webhook脚本上的前几行代码(尽管我猜这无关紧要,因为我从一开始就进行日志记录,因此它至少应该记录某事当PayPal发送Webhook时):
{
"id": "WH-snip-",
"create_time": "2019-05-06T15:33:38.143Z",
"resource_type": "sale",
"event_type": "PAYMENT.SALE.COMPLETED",
"summary": "Payment completed for EUR 9.99 EUR",
"resource": {
"billing_agreement_id": "I-snip-",
"amount": {
"total": "9.99",
"currency": "EUR",
"details": {
"subtotal": "9.99"
}
},
"payment_mode": "INSTANT_TRANSFER",
"update_time": "2019-05-06T15:33:16Z",
"create_time": "2019-05-06T15:33:16Z",
"protection_eligibility_type": "ITEM_NOT_RECEIVED_ELIGIBLE,UNAUTHORIZED_PAYMENT_ELIGIBLE",
"transaction_fee": {
"value": "0.54",
"currency": "EUR"
},
"protection_eligibility": "ELIGIBLE",
"links": [
{
"href": "https://api.sandbox.paypal.com/v1/payments/sale/-snip-",
"rel": "self",
"method": "GET"
},
{
"href": "https://api.sandbox.paypal.com/v1/payments/sale/-snip-/refund",
"rel": "refund",
"method": "POST"
}
],
"id": "-snip-",
"state": "completed",
"invoice_number": ""
},
"status": "SUCCESS",
"transmissions": [
{
"webhook_url": "-snip- (the URL is 100% correct)",
"response_headers": {
"Transfer-Encoding": "chunked",
"Server": "nginx/1.10.3",
"Connection": "keep-alive",
"Date": "Mon, 06 May 2019 15:37:38 GMT",
"Content-Type": "text/html; charset=UTF-8"
},
"transmission_id": "-snip-",
"status": "SUCCESS",
"timestamp": "2019-05-06T15:37:25Z"
}
],
"links": [
{
"href": "https://api.sandbox.paypal.com/v1/notifications/webhooks-events/WH-snip-",
"rel": "self",
"method": "GET",
"encType": "application/json"
},
{
"href": "https://api.sandbox.paypal.com/v1/notifications/webhooks-events/WH-snip-/resend",
"rel": "resend",
"method": "POST",
"encType": "application/json"
}
],
"event_version": "1.0"
}