NoMethodError - #<Hash:... 的未定义方法“split”:
NoMethodError - undefined method `split' for #<Hash:...:
我正在创建一个 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)>'
我在源代码中找不到太多,想知道是否其他人也遇到过这个问题?
方法 Braintree::WebhookTesting.sample_notification
returns 一个散列,而 signature, payload =
语法需要一个数组。
您需要使用它们的密钥从返回的散列中提取签名和有效负载:
sample_notification = Braintree::WebhookTesting.sample_notification(
Braintree::WebhookNotification::Kind::SubMerchantAccountApproved,
rand(10000)
)
signature = sample_notification[:bt_signature]
payload = sample_notification[:bt_payload]
我正在创建一个 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)>'
我在源代码中找不到太多,想知道是否其他人也遇到过这个问题?
方法 Braintree::WebhookTesting.sample_notification
returns 一个散列,而 signature, payload =
语法需要一个数组。
您需要使用它们的密钥从返回的散列中提取签名和有效负载:
sample_notification = Braintree::WebhookTesting.sample_notification(
Braintree::WebhookNotification::Kind::SubMerchantAccountApproved,
rand(10000)
)
signature = sample_notification[:bt_signature]
payload = sample_notification[:bt_payload]