Search code examples
ruby-on-railsstripe-paymentsngrok

No signatures found matching the expected signature for payload


I'm working on the marketplace application. When payout to a connect account from the platform, I want to update account's balance information and add receipt model on my application. But No signatures found matching the expected signature for payload error occurs and I can't get payout.paid event.

stripe.rb

StripeEvent.configure do |events|
  # The case transfer created
  events.subscribe(
    'payout.paid',
    Events::PayoutPaid.new
  )
end

apps/services/events/payout_paid.rb

class Events::PayoutPaid
  def call(event)
    source = event.data.object

    # Fetch balence information
    account = source.destination
    balance = Stripe::Balance.retrieve(
        {stripe_account: account}
      )

    @user = User.find_by({
      stripe_account_id: account
    })
    @user.balance = balance["available"][0]["amount"]
    @user.save

    # create receipt
    @receipt = Receipt.new
    @receipt.user = @user
    @receipt.amount = source.amount
    @receipt.save
  end
end

Although other stripe webhook would work.


Solution

  • I was having the same problem, and the solution was to:

    1. log into Stripe
    2. go to the page for the webhook that was failing
    3. get the Signing secret from the middle of that page
    4. and set an env VAR called STRIPE_SIGNING_SECRET with the Signing secret as its value.

    This is mentioned in the Stripe docs, here.