Class: Jackpot::Payment

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/jackpot/payment.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#credit_cardObject

Returns the value of attribute credit_card.



5
6
7
# File 'app/models/jackpot/payment.rb', line 5

def credit_card
  @credit_card
end

#credit_card_tokenObject

Returns the value of attribute credit_card_token.



6
7
8
# File 'app/models/jackpot/payment.rb', line 6

def credit_card_token
  @credit_card_token
end

Instance Method Details

#customer_emailObject



29
30
31
# File 'app/models/jackpot/payment.rb', line 29

def customer_email
  customer.email
end

#perform_paymentObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/models/jackpot/payment.rb', line 13

def perform_payment
  credit_card_token = customer.credit_card_token
  if credit_card_token
    self.amount = self.subscription.price
    response = Jackpot::Payment.gateway.authorize       self.amount, credit_card_token
    if response.success?
      billing_response = Jackpot::Payment.gateway.capture(self.amount, 
                                                           response.authorization) 

      self.payment_transaction_token = billing_response.params['transactionid']
    else
      raise Jackpot::Errors::UnauthorizedPayment.new
    end
  end 
end