5
6
7
8
9
10
11
12
13
14
15
|
# File 'app/workers/catarse_pagarme/verify_pagarme_worker.rb', line 5
def perform key
source = find_source_by_key key
payment = PaymentEngines.find_payment({ key: key })
raise "payment not found" unless payment.present?
raise "source not found" unless source.present? && source.try(:[], "metadata").try(:[], "key") == key
payment.update(gateway_id: source["id"])
payment.pagarme_delegator.update_transaction
payment.pagarme_delegator.change_status_by_transaction source["status"]
end
|