Class: CloudPayments::Transaction

Inherits:
Model
  • Object
show all
Defined in:
lib/cloud_payments/models/transaction.rb

Constant Summary collapse

AWAITING_AUTHENTICATION =
'AwaitingAuthentication'
COMPLECTED =
'Completed'
AUTHORIZED =
'Authorized'
CANCELLED =
'Cancelled'
DECLINED =
'Declined'

Constants inherited from Model

Model::BooleanTransform, Model::DateTimeTransform, Model::DecimalTransform, Model::IntegralTransform

Instance Method Summary collapse

Instance Method Details

#authorized?Boolean

Returns:

  • (Boolean)


76
77
78
# File 'lib/cloud_payments/models/transaction.rb', line 76

def authorized?
  status == AUTHORIZED
end

#awaiting_authentication?Boolean

Returns:

  • (Boolean)


68
69
70
# File 'lib/cloud_payments/models/transaction.rb', line 68

def awaiting_authentication?
  status == AWAITING_AUTHENTICATION
end

#cancelled?Boolean

Returns:

  • (Boolean)


80
81
82
# File 'lib/cloud_payments/models/transaction.rb', line 80

def cancelled?
  status == CANCELLED
end

#card_numberObject



60
61
62
# File 'lib/cloud_payments/models/transaction.rb', line 60

def card_number
  @card_number ||= "#{card_first_six}XXXXXX#{card_last_four}".gsub(/(.{4})/, '\1 ').rstrip
end

#completed?Boolean

Returns:

  • (Boolean)


72
73
74
# File 'lib/cloud_payments/models/transaction.rb', line 72

def completed?
  status == COMPLECTED
end

#declined?Boolean

Returns:

  • (Boolean)


84
85
86
# File 'lib/cloud_payments/models/transaction.rb', line 84

def declined?
  status == DECLINED
end

#ip_locationObject



64
65
66
# File 'lib/cloud_payments/models/transaction.rb', line 64

def ip_location
  [ip_lat, ip_lng] if ip_lng && ip_lat
end

#refunded?Boolean

Returns:

  • (Boolean)


88
89
90
# File 'lib/cloud_payments/models/transaction.rb', line 88

def refunded?
  refunded
end

#required_secure3d?Boolean

Returns:

  • (Boolean)


52
53
54
# File 'lib/cloud_payments/models/transaction.rb', line 52

def required_secure3d?
  false
end

#subscriptionObject



56
57
58
# File 'lib/cloud_payments/models/transaction.rb', line 56

def subscription
  @subscription ||= CloudPayments.client.subscriptions.find(subscription_id) if subscription_id
end