Module: GimmeGimme::CreditCard::InstanceMethods

Defined in:
lib/gimme_gimme/credit_card.rb

Instance Method Summary collapse

Instance Method Details

#authorize(opts) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/gimme_gimme/credit_card.rb', line 25

def authorize(opts)
  amount = opts[:amount]
  amount = amount.round(2) unless amount.kind_of?(Integer)
  response = self.class.gateway.create_customer_profile_transaction(
      :transaction => {
      :customer_profile_id         => self.user.remote_customer_profile_id,
      :customer_payment_profile_id => self.remote_customer_payment_profile_id,
      :type                        => :auth_only,
      :amount                      => amount
    }
  )

  if response.success?
    response.params['direct_response']['approval_code']
  else
    raise AuthorizationError
  end
end

#charge(opts) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/gimme_gimme/credit_card.rb', line 44

def charge(opts)
  amount = opts[:amount]
  amount = amount.round(2) unless amount.kind_of?(Integer)
  opts[:amount] = amount
  response = self.class.gateway.create_customer_profile_transaction(
      :transaction => {
      :customer_profile_id         => self.user.remote_customer_profile_id,
      :customer_payment_profile_id => self.remote_customer_payment_profile_id,
      :type                        => :capture_only
    }.merge(opts)
  )

  if response.success?
    response.params['direct_response']['transaction_id']
  else
    raise ChargeError
  end
end

#store_card?Boolean

Returns:

  • (Boolean)


63
64
65
# File 'lib/gimme_gimme/credit_card.rb', line 63

def store_card?
  !!store_card
end