Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes tests for Stripe 5.19.0 #133

Merged
merged 1 commit into from May 12, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 13 additions & 4 deletions spec/controllers/webhook_controller_spec.rb
Expand Up @@ -12,10 +12,19 @@ def stub_event(identifier)

def generate_signature(params, secret)
payload = params.to_json
timestamp = Time.now.to_i
signature = Stripe::Webhook::Signature.send(:compute_signature, "#{timestamp}.#{payload}", secret)

"t=#{timestamp},v1=#{signature}"
timestamp = Time.now

# compute_signature was private until version 5.19.0 when it was made
# public and had it's API changed to split timestamp to a separate field.
signer = Stripe::Webhook::Signature.method(:compute_signature)
signature =
if signer.arity == 3
signer.call(timestamp, payload, secret)
else
signer.call("#{timestamp.to_i}.#{payload}", secret)
end

"t=#{timestamp.to_i},v1=#{signature}"
end

def webhook(signature, params)
Expand Down