Class: CheckingDuplicateChargeWorker
- Inherits:
-
ApplicationWorker
- Object
- ApplicationWorker
- CheckingDuplicateChargeWorker
- Defined in:
- app/workers/checking_duplicate_charge_worker.rb
Overview
to check duplicate charge by transaction_id/omise_charge_id oci means omise_charge_id system will send an alert to operation team when there is a duplicate
Instance Method Summary collapse
Methods inherited from ApplicationWorker
Instance Method Details
#perform(oci) ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'app/workers/checking_duplicate_charge_worker.rb', line 5 def perform(oci) charges = Externals::Omise::Charge.success_scope.where(omise_charge_id: oci) if charges.count >= 2 send_email_alert(charges) true else false end end |
#send_email_alert(charges) ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'app/workers/checking_duplicate_charge_worker.rb', line 15 def send_email_alert(charges) booking_id = charges.first.reservation_id subject = 'Alert: there is a duplicate credit card transaction' = "Booking ID #{booking_id} has duplicate transaction. Open https://hungryhub.com/admin/credit_cards?credit_cards_grid%5Breservation_id%5D=#{booking_id} " StaffMailer.notify_error_staff(subject, ).deliver_later! end |