我正在创建一个 webhook 通知:
signature, payload = Braintree::WebhookTesting.sample_notification(
Braintree::WebhookNotification::Kind::SubMerchantAccountApproved,
rand(10000)
)
然后解析:
@message = Braintree::WebhookNotification.parse(signature, payload)
签名和有效负载响应:
{:bt_signature=>"gcsg95j47yvzpgrr|61350cd9c99cbac6a7905479a5fa061976114e51", :bt_payload=>"ICAgICAgICA8bm90aWZpY2F0aW9uPgogICAgICAgICAgPHRpbWVzdGFtcCB0
eXBlPSJkYXRldGltZSI+MjAxNS0wOS0wNFQwMjo1Nzo0NFo8L3RpbWVzdGFt
cD4KICAgICAgICAgIDxraW5kPnN1Yl9tZXJjaGFudF9hY2NvdW50X2FwcHJv
dmVkPC9raW5kPgogICAgICAgICAgPHN1YmplY3Q+CiAgICAgICAgICAgICAg
ICAgICAgPG1lcmNoYW50X2FjY291bnQ+CiAgICAgICAgICA8aWQ+MzEzNDwv
aWQ+CiAgICAgICAgICA8bWFzdGVyX21lcmNoYW50X2FjY291bnQ+CiAgICAg
ICAgICAgIDxpZD5tYXN0ZXJfbWFfZm9yXzMxMzQ8L2lkPgogICAgICAgICAg
ICA8c3RhdHVzPmFjdGl2ZTwvc3RhdHVzPgogICAgICAgICAgPC9tYXN0ZXJf
bWVyY2hhbnRfYWNjb3VudD4KICAgICAgICAgIDxzdGF0dXM+YWN0aXZlPC9z
dGF0dXM+CiAgICAgICAgPC9tZXJjaGFudF9hY2NvdW50PgoKICAgICAgICAg
IDwvc3ViamVjdD4KICAgICAgICA8L25vdGlmaWNhdGlvbj4K
"}
我不断收到错误:
NoMethodError - undefined method `split' for #<Hash:0x007fdb043e7b50>:
App backtrace
-------------
- () Users/johnmolina/Documents/Rails/Nyvur/app/controllers/webhooks_controller.rb:30:in `handle'
- () Users/johnmolina/Documents/Rails/Nyvur/bin/rails:8:in `<top (required)>'
- () Users/johnmolina/Documents/Rails/Nyvur/bin/spring:16:in `<top (required)>'
我在源代码中找不到太多内容,想知道其他人是否也遇到过这个问题?
这是Webhooks 控制器。