Class: PayCertify::ThreeDS

Inherits:
Object
  • Object
show all
Defined in:
lib/paycertify/three_ds.rb,
lib/paycertify/three_ds/form.rb,
lib/paycertify/three_ds/client.rb,
lib/paycertify/three_ds/callback.rb,
lib/paycertify/three_ds/payment_authentication.rb

Defined Under Namespace

Classes: Callback, Client, Form, NoCredentialsError, PaymentAuthentication

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ ThreeDS

Returns a new instance of ThreeDS.

Raises:



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/paycertify/three_ds.rb', line 20

def initialize(options)
  raise NoCredentialsError, 'No api_key provided.' unless api_key.present?
  raise NoCredentialsError, 'No api_secret provided.' unless api_secret.present?

  self.type = options[:type].to_sym.in?([:strict, :frictionless]) ? options[:type].to_sym : :strict
  
  self.card_number = options[:card_number]
  self.expiration_month = options[:expiration_month]
  self.expiration_year = options[:expiration_year]
  self.amount = options[:amount]
  self.transaction_id = options[:transaction_id]
  self.message_id = options[:message_id]
  self.return_url = options[:return_url]

  self.client = PayCertify::ThreeDS::Client.new(api_key: api_key, api_secret: api_secret, mode: mode)
end

Class Attribute Details

.api_keyObject

Returns the value of attribute api_key.



66
67
68
# File 'lib/paycertify/three_ds.rb', line 66

def api_key
  @api_key
end

.api_secretObject

Returns the value of attribute api_secret.



66
67
68
# File 'lib/paycertify/three_ds.rb', line 66

def api_secret
  @api_secret
end

.modeObject

Returns the value of attribute mode.



66
67
68
# File 'lib/paycertify/three_ds.rb', line 66

def mode
  @mode
end

Instance Attribute Details

#amountObject

Returns the value of attribute amount.



15
16
17
# File 'lib/paycertify/three_ds.rb', line 15

def amount
  @amount
end

#authenticationObject

Returns the value of attribute authentication.



14
15
16
# File 'lib/paycertify/three_ds.rb', line 14

def authentication
  @authentication
end

#card_numberObject

Returns the value of attribute card_number.



15
16
17
# File 'lib/paycertify/three_ds.rb', line 15

def card_number
  @card_number
end

#clientObject

Returns the value of attribute client.



14
15
16
# File 'lib/paycertify/three_ds.rb', line 14

def client
  @client
end

#expiration_monthObject

Returns the value of attribute expiration_month.



15
16
17
# File 'lib/paycertify/three_ds.rb', line 15

def expiration_month
  @expiration_month
end

#expiration_yearObject

Returns the value of attribute expiration_year.



15
16
17
# File 'lib/paycertify/three_ds.rb', line 15

def expiration_year
  @expiration_year
end

#message_idObject

Returns the value of attribute message_id.



15
16
17
# File 'lib/paycertify/three_ds.rb', line 15

def message_id
  @message_id
end

#modeObject

Returns the value of attribute mode.



16
17
18
# File 'lib/paycertify/three_ds.rb', line 16

def mode
  @mode
end

#return_urlObject

Returns the value of attribute return_url.



15
16
17
# File 'lib/paycertify/three_ds.rb', line 15

def return_url
  @return_url
end

#settingsObject

Returns the value of attribute settings.



14
15
16
# File 'lib/paycertify/three_ds.rb', line 14

def settings
  @settings
end

#transaction_idObject

Returns the value of attribute transaction_id.



15
16
17
# File 'lib/paycertify/three_ds.rb', line 15

def transaction_id
  @transaction_id
end

#typeObject

Returns the value of attribute type.



14
15
16
# File 'lib/paycertify/three_ds.rb', line 14

def type
  @type
end

Class Method Details

.authenticate!(settings:, callback_params:) ⇒ Object

Raises:



72
73
74
75
76
77
78
# File 'lib/paycertify/three_ds.rb', line 72

def authenticate!(settings:, callback_params:)
  raise NoCredentialsError, 'No api_key provided.' unless api_key.present?
  raise NoCredentialsError, 'No api_secret provided.' unless api_secret.present?

  client = PayCertify::ThreeDS::Client.new(api_key: api_key, api_secret: api_secret, mode: mode)
  PayCertify::ThreeDS::PaymentAuthentication.new(client, settings).authenticate!(callback_params)
end

.configure {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



68
69
70
# File 'lib/paycertify/three_ds.rb', line 68

def configure(&block)
  yield self if block_given?
end

Instance Method Details

#card_enrolled?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/paycertify/three_ds.rb', line 53

def card_enrolled?
  @card_enrolled ||= payment_authentication.card_enrolled?
end

#payment_authenticationObject



49
50
51
# File 'lib/paycertify/three_ds.rb', line 49

def payment_authentication
  @payment_authentication ||= PayCertify::ThreeDS::PaymentAuthentication.new(client, settings)
end

#render!Object



61
62
63
# File 'lib/paycertify/three_ds.rb', line 61

def render!
  PayCertify::ThreeDS::Form.new(authentication).render_html_for(settings, type)
end

#start!Object



57
58
59
# File 'lib/paycertify/three_ds.rb', line 57

def start!
  self.authentication = payment_authentication.prepare!
end