Class: Payola::Sale
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Payola::Sale
- Includes:
- AASM, GuidBehavior
- Defined in:
- app/models/payola/sale.rb
Instance Method Summary collapse
- #custom_fields ⇒ Object
- #redirector ⇒ Object
- #verifier ⇒ Object
- #verify_charge ⇒ Object
- #verify_charge! ⇒ Object
Methods included from GuidBehavior
Instance Method Details
#custom_fields ⇒ Object
67 68 69 70 71 72 73 |
# File 'app/models/payola/sale.rb', line 67 def custom_fields if self.signed_custom_fields.present? verifier.verify(self.signed_custom_fields) else nil end end |
#redirector ⇒ Object
75 76 77 |
# File 'app/models/payola/sale.rb', line 75 def redirector product end |
#verifier ⇒ Object
46 47 48 |
# File 'app/models/payola/sale.rb', line 46 def verifier @verifier ||= ActiveSupport::MessageVerifier.new(Payola.secret_key_for_sale(self), digest: 'SHA256') end |
#verify_charge ⇒ Object
50 51 52 53 54 55 56 57 |
# File 'app/models/payola/sale.rb', line 50 def verify_charge begin self.verify_charge! rescue RuntimeError => e self.error = e. self.fail! end end |
#verify_charge! ⇒ Object
59 60 61 62 63 64 65 |
# File 'app/models/payola/sale.rb', line 59 def verify_charge! if Payola.charge_verifier.arity > 1 Payola.charge_verifier.call(self, custom_fields) else Payola.charge_verifier.call(self) end end |