42 lines
1.4 KiB
Ruby
Executable File
42 lines
1.4 KiB
Ruby
Executable File
#!/usr/bin/env ruby
|
|
|
|
# Test script to verify Stripe configuration and initialization
|
|
require 'stripe'
|
|
|
|
# Get Stripe keys from environment variables
|
|
stripe_secret_key = ENV["STRIPE_SECRET_KEY"]
|
|
|
|
if stripe_secret_key.nil? || stripe_secret_key.empty?
|
|
puts "❌ Stripe secret key is not set in environment variables"
|
|
exit 1
|
|
end
|
|
|
|
puts "✅ Stripe secret key is set"
|
|
puts "✅ Length of secret key: #{stripe_secret_key.length} characters"
|
|
|
|
# Test that Stripe is NOT initialized at this point
|
|
if Stripe.api_key.nil? || Stripe.api_key.empty?
|
|
puts "✅ Stripe is not yet initialized (as expected for lazy initialization)"
|
|
else
|
|
puts "⚠️ Stripe appears to be pre-initialized (not expected for lazy initialization)"
|
|
end
|
|
|
|
# Now test initializing Stripe during "checkout"
|
|
puts "🔄 Initializing Stripe during checkout process..."
|
|
Stripe.api_key = stripe_secret_key
|
|
|
|
# Test the API key by retrieving the account information
|
|
begin
|
|
account = Stripe::Account.retrieve("self")
|
|
puts "✅ Stripe API key is properly configured and authenticated"
|
|
puts "✅ Account ID: #{account.id}"
|
|
rescue Stripe::AuthenticationError => e
|
|
puts "❌ Stripe API key authentication failed: #{e.message}"
|
|
exit 1
|
|
rescue Stripe::PermissionError => e
|
|
# This means the key is valid but doesn't have permission to retrieve account
|
|
puts "✅ Stripe API key is properly configured (limited permissions)"
|
|
rescue => e
|
|
puts "❌ Error testing Stripe API key: #{e.message}"
|
|
exit 1
|
|
end |