Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions app/controllers/api/v1/webhook_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@ def webhook
puts "🔵 Webhook Stripe reçu !"

payload = request.body.read
# sig_header = request.env['HTTP_STRIPE_SIGNATURE']
sig_header = request.env["HTTP_STRIPE_SIGNATURE"]

begin
# event = Stripe::Webhook.construct_event(
# payload, sig_header, ENV['STRIPE_WEBHOOK_SECRET']
# )
event = JSON.parse(payload, symbolize_names: true)
event = Stripe::Webhook.construct_event(
payload, sig_header, ENV["STRIPE_WEBHOOK_SECRET"]
)

puts "🟢 Event Stripe détecté : #{event[:type]}"

Expand All @@ -40,7 +39,7 @@ def webhook
puts "⚠️ Webhook ignoré : #{event[:type]}"
end

render json: { received: true }
render json: { received: true }, status: :ok
rescue JSON::ParserError => e
puts "❌ Erreur JSON : #{e.message}"
render json: { error: e.message }, status: :bad_request
Expand Down
2 changes: 1 addition & 1 deletion app/jobs/update_crypto_prices_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def perform
DataLab::CoinmarketcapService.update_crypto_prices

# Replanifier le job pour la prochaine exécution
interval = Rails.application.config.coinmarketcap.fetch(:update_interval, 20.minutes)
interval = Rails.application.config.coinmarketcap.fetch(:update_interval, 5.minutes)
self.class.set(wait: interval).perform_later
end
end
2 changes: 1 addition & 1 deletion config/initializers/coinmarketcap.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Rails.application.config.coinmarketcap = {
api_key: ENV["COINMARKETCAP_API_KEY"],
base_url: "https://pro-api.coinmarketcap.com/v1",
update_interval: 20.minutes,
update_interval: 5.minutes,
symbols_map: {
"$BFT" => "BFTOKEN" # Mapping du nom dans notre DB vers le symbole sur CoinMarketCap
# Ajoutez d'autres mappings si nécessaire
Expand Down
Loading