0

我正在创建一个 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 控制器


VBA 在 Visio 中更改圆角矩形的颜色

我正在使用以下代码将圆角矩形添加到 Visio 中的页面...

        Dim t As Visio.Master
        Set t = Application.Documents.Item("BASIC_U.VSS").Masters.ItemU("Rounded rectangle")

        Application.ActiveWindow.Page.Drop t, 0, 0

        ActiveWindow.DeselectAll
        ActiveWindow.Select Application.ActiveWindow.Page.Shapes.ItemU("Rounded rectangle"), visSelect
        ActiveWindow.Selection.Group

        Dim vsoShps As Visio.Shapes

        Set vsoShps = pg.Shapes
        Dim totalShapes As Integer
        totalShapes = vsoShps.count

        Set vsoShape1 = vsoShps.Item(totalShapes)

        ' move the shapes to random positions
        Application.ActiveWindow.Selection.Move x + 1 / 2 * (lowRight_X_SysShapeCoord - upLeft_X_SysShapeCoord), y + 1 / 2 * (upLeft_Y_SysShapeCoord - lowRight_Y_SysShapeCoord)

        vsoShape1.Cells("Char.Size").Formula = getFontSize(1)

        vsoShape1.Cells("Width") = lowRight_X_SysShapeCoord - upLeft_X_SysShapeCoord
        vsoShape1.Cells("Height") = upLeft_Y_SysShapeCoord - lowRight_Y_SysShapeCoord

        vsoShape1.Text = xlWsh.Range("A" & r)


        ' place text at top center of box
        vsoShape1.CellsU("TxtHeight").FormulaForceU = "Height / 2"


        Dim shp As Visio.Shape
        Set shp = ActiveWindow.Page.Shapes.ItemU("Rounded rectangle")

        ActiveWindow.DeselectAll
        ActiveWindow.Select shp, visSelect

        Dim shpGrp As Visio.Shape
        Set shpGrp = ActiveWindow.Selection.Group

        'Set fill on child shape
        shpGrp.Shapes(1).CellsU("Fillforegnd").FormulaU = "RGB(18, 247, 41)"

注意:矩形前面有5个按钮

我可以设置文本和其他文本属性,但我不知道如何更改圆角矩形的填充颜色。我知道如何更改常规矩形的填充颜色...

Set vsoShape1 = ActivePage.DrawRectangle(upLeft_X_SysShapeCoord, _
                                         upLeft_Y_SysShapeCoord, _
                                         lowRight_X_SysShapeCoord, _
                                         lowRight_Y_SysShapeCoord)

' change color
vsoShape1.Cells("Fillforegnd").Formula = "RGB(18, 247, 41)"

但这不适用于圆角矩形。我一直在寻找几个小时试图找到解决方案,但我找不到答案。有人可以帮忙吗?


解决方案

分组...

        Application.ActiveWindow.Page.Drop Application.Documents.Item("BASIC_U.VSS").Masters.ItemU("Rounded rectangle"), 0, 0

        Dim vsoShps As Visio.Shapes

        Set vsoShps = pg.Shapes
        Dim totalShapes As Integer
        totalShapes = vsoShps.count

        Set vsoShape1 = vsoShps.Item(totalShapes)  

        Dim shp As Visio.Shape
        Set shp = ActiveWindow.Page.Shapes.ItemU("Rounded rectangle")

        ActiveWindow.DeselectAll
        ActiveWindow.Select shp, visSelect

        Dim shpGrp As Visio.Shape
        Set shpGrp = ActiveWindow.Selection.Group

        'Set fill on child shape
        shpGrp.Shapes(1).CellsU("Fillforegnd").FormulaU = "RGB(18, 247, 41)"

单一形状...

        Application.ActiveWindow.Page.Drop Application.Documents.Item("BASIC_U.VSS").Masters.ItemU("Rounded rectangle"), 0, 0

        Dim vsoShps As Visio.Shapes

        Set vsoShps = pg.Shapes
        Dim totalShapes As Integer
        totalShapes = vsoShps.count

        Set vsoShape1 = vsoShps.Item(totalShapes) 

        vsoShape1.CellsU("Fillforegnd").FormulaU = "RGB(18, 247, 41)"
4

1 回答 1

3

该方法Braintree::WebhookTesting.sample_notification返回一个散列,而signature, payload =语法需要一个数组。

您需要使用它们的密钥从返回的哈希中提取签名和有效负载:

sample_notification = Braintree::WebhookTesting.sample_notification(
  Braintree::WebhookNotification::Kind::SubMerchantAccountApproved,
  rand(10000)
)

signature = sample_notification[:bt_signature]
payload = sample_notification[:bt_payload]
于 2015-09-04T21:19:48.387 回答