mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2024-12-01 12:24:28 +01:00
15 lines
431 B
Ruby
15 lines
431 B
Ruby
|
|
class StripeCardTokenValidator
|
|
def validate(record)
|
|
if options[:token]
|
|
begin
|
|
res = Stripe::Token.retrieve(options[:token])
|
|
if res[:id] != options[:token]
|
|
record.errors[:card_token] << "A problem occurred while retrieving the card with the specified token: #{res.id}"
|
|
end
|
|
rescue Stripe::InvalidRequestError => e
|
|
record.errors[:card_token] << e
|
|
end
|
|
end
|
|
end
|
|
end |