Class: PaymillOnRails::Subscription
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- PaymillOnRails::Subscription
- Defined in:
- app/models/paymill_on_rails/subscription.rb
Instance Attribute Summary collapse
-
#paymill_card_token ⇒ Object
paymill_card_token is one-time used token and is not stored into DB, but is used by Paymill::Payment.create to get payment, then just payment.id is stored ( see: github.com/dkd/paymill-ruby ).
Instance Method Summary collapse
Instance Attribute Details
#paymill_card_token ⇒ Object
paymill_card_token is one-time used token and is not stored into DB, but is used by Paymill::Payment.create to get payment, then just payment.id is stored ( see: github.com/dkd/paymill-ruby )
9 10 11 |
# File 'app/models/paymill_on_rails/subscription.rb', line 9 def paymill_card_token @paymill_card_token end |
Instance Method Details
#save_with_payment ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/models/paymill_on_rails/subscription.rb', line 15 def save_with_payment if valid? client = Paymill::Client.create email: email, description: name payment = Paymill::Payment.create token: paymill_card_token, client: client.id subscription = Paymill::Subscription.create offer: plan.paymill_id, client: client.id, payment: payment.id self.paymill_id = subscription.id save! end rescue Paymill::PaymillError => e logger.error "Paymill error while creating customer: #{e.}" errors.add :base, "There was a problem with your credit card. Please try again." false end |