From 79463b2efa12295769d19e3cf2f8fd6a552424c6 Mon Sep 17 00:00:00 2001 From: Paul Padier Date: Tue, 22 Aug 2023 10:14:56 +0900 Subject: [PATCH] Explicitly format timestamp in SignatureVerificationError message (#1262) When interpolating a Time object in a String, Ruby calls `to_s` under the hood. For Rails applications defining a `default` string format, this triggers deprecation warnings as of v7.0.7: https://github.com/rails/rails/pull/48555 This change fixes that by explicitly formatting the timestamp (using the same `YYYY-MM-DD HH:mm:ss` format currently implicitly used). --- lib/stripe/webhook.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/stripe/webhook.rb b/lib/stripe/webhook.rb index df1ed65d..63b2f0c8 100644 --- a/lib/stripe/webhook.rb +++ b/lib/stripe/webhook.rb @@ -108,8 +108,9 @@ module Stripe end if tolerance && timestamp < Time.now - tolerance + formatted_timestamp = Time.at(timestamp).strftime("%F %T") raise SignatureVerificationError.new( - "Timestamp outside the tolerance zone (#{Time.at(timestamp)})", + "Timestamp outside the tolerance zone (#{formatted_timestamp})", header, http_body: payload ) end