Reputation: 979
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.
Upvotes: 2
Views: 1637
Reputation: 444
I was having the same problem, and the solution was to:
This is mentioned in the Stripe docs, here.
Upvotes: 4
Reputation: 1020
That is because you havent loaded the signing secrets to StripeEvent
Lest say you create 2 webhooks on the Stripe dashboard, one subscribed to invoices events, the other to customer events. You first need to copy each of the Signing secret (click on reveal) and then store them in the config/credentials.yml.enc
file
First, run the command EDITOR="atom --wait" rails credentials:edit
(using the editor of your choosing). Then, add the following values:
stripe:
development:
secret_key: MY_SECRET_KEY
publishable_key: MY_PUBLISHABLE_KEY
signing_secret_customer_endpoint: MY_SIGNING_SECRET_CUSTOMERS
signing_secrets_invoice_endpoint: MY_SIGNING_SECRET_INVOICES
Save the file. Now edit the initializer for stripeEvent. In my case, it was config/initializers/stripe.rb
and add:
StripeEvent.signing_secrets = [
Rails.application.credentials[:stripe][Rails.env.to_sym][:signing_secret_customer_endpoint],
Rails.application.credentials[:stripe][Rails.env.to_sym][:signing_secrets_invoice_endpoint]]
Now the signing secrets are loaded and the webhooks should work
Upvotes: 2