Sha256: b9cffe83c037ccdd180fb39c1a9df4e3e3cb3d02206c64e5d43e9a72dcd82c95
Contents?: true
Size: 655 Bytes
Versions: 61
Compression:
Stored size: 655 Bytes
Contents
module CatarsePagarme class SubscriptionTransaction < TransactionBase def charge! validate_subscription_id self.subscription = PagarMe::Subscription.find_by_id(self.attributes[:subscription_id]) self.subscription.charge(self.attributes[:amount], self.attributes[:installments]) self.transaction = subscription.current_transaction change_contribution_state self.transaction end def validate_subscription_id unless self.user.credit_cards.where(subscription_id: self.attributes[:subscription_id]).present? raise PagarMe::PagarMeError.new('invalid subscription') end end end end
Version data entries
61 entries across 61 versions & 1 rubygems