Skip to content
Merged
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
7 changes: 4 additions & 3 deletions app/controllers/monzo_transactions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,10 @@ def webhook

sweepstake = "world-cup-2026"
emojis = ["⚽️".downcase, "⚽".downcase, "football"]
amount = 200

begin
if @webhook["type"] == "transaction.created" and emojis.include? @webhook["data"]["notes"].strip.downcase and @webhook["data"]["amount"] == 200
if @webhook["type"] == "transaction.created" and emojis.include? @webhook["data"]["notes"].strip.downcase and @webhook["data"]["amount"] == amount
logger.info "This is a #{sweepstake} payment"
payee = @webhook["data"]["counterparty"]["name"]
logger.info "from #{payee}"
Expand Down Expand Up @@ -142,7 +143,7 @@ def webhook
logger.info response.body
data = {
"fields": {
"pot": { "doubleValue": current_pot + 2 },
"pot": { "doubleValue": current_pot + (amount / 100) },
}
}
response = RestClient.patch("#{base_url}/sweepstakes/#{sweepstake}?updateMask.fieldPaths=pot", data.to_json, content_type: :json)
Expand All @@ -154,7 +155,7 @@ def webhook
logger.info "This is not a #{sweepstake} payment"
logger.info "#{@webhook["type"]} (#{@webhook["type"] == "transaction.created"})"
logger.info "#{@webhook["data"]["notes"].strip.downcase} (#{emojis.include? @webhook["data"]["notes"].strip.downcase})"
logger.info "#{@webhook["data"]["amount"]} (#{@webhook["data"]["amount"] == 100})"
logger.info "#{@webhook["data"]["amount"]} (#{@webhook["data"]["amount"] == amount})"
end
rescue => e
logger.info "Error: #{e.message}"
Expand Down
Loading