Class: Pay::AppConfig

Inherits:
AppUtils::BaseConfig show all
Defined in:
lib/ruby/pay.rb

Overview

AppConfig class

Instance Attribute Summary collapse

Attributes inherited from AppUtils::BaseConfig

#connection, #is_sandbox

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from AppUtils::BaseConfig

#toggle_base_url

Constructor Details

#initialize(provider: DarajaAuthProvider.create, short_code: nil, confirmation_url: nil, validation_url: nil, b2c_result_url: nil, initiator_name: nil, initiator_password: nil, ssl_certificate: nil, balance_result_url: nil) ⇒ AppConfig

Returns a new instance of AppConfig.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/ruby/pay.rb', line 20

def initialize(
  provider: DarajaAuthProvider.create,
  short_code: nil,
  confirmation_url: nil,
  validation_url: nil,
  b2c_result_url: nil,
  initiator_name: nil,
  initiator_password: nil,
  ssl_certificate: nil,
  balance_result_url: nil
)
  super(is_sandbox: provider.is_sandbox)
  @short_code = short_code
  @confirmation_url = confirmation_url
  @validation_url = validation_url
  @provider = provider
  @b2c_result_url = b2c_result_url
  @initiator_name = initiator_name
  @initiator_password = initiator_password
  @ssl_certificate = ssl_certificate
  @balance_result_url = balance_result_url
end

Instance Attribute Details

#b2c_result_urlObject

Returns the value of attribute b2c_result_url.



10
11
12
# File 'lib/ruby/pay.rb', line 10

def b2c_result_url
  @b2c_result_url
end

#balance_result_urlObject

Returns the value of attribute balance_result_url.



10
11
12
# File 'lib/ruby/pay.rb', line 10

def balance_result_url
  @balance_result_url
end

#confirmation_urlObject

Returns the value of attribute confirmation_url.



10
11
12
# File 'lib/ruby/pay.rb', line 10

def confirmation_url
  @confirmation_url
end

#initiator_nameObject

Returns the value of attribute initiator_name.



10
11
12
# File 'lib/ruby/pay.rb', line 10

def initiator_name
  @initiator_name
end

#initiator_passwordObject

Returns the value of attribute initiator_password.



10
11
12
# File 'lib/ruby/pay.rb', line 10

def initiator_password
  @initiator_password
end

#providerObject (readonly)

Returns the value of attribute provider.



18
19
20
# File 'lib/ruby/pay.rb', line 18

def provider
  @provider
end

#short_codeObject

Returns the value of attribute short_code.



10
11
12
# File 'lib/ruby/pay.rb', line 10

def short_code
  @short_code
end

#ssl_certificateObject

Returns the value of attribute ssl_certificate.



10
11
12
# File 'lib/ruby/pay.rb', line 10

def ssl_certificate
  @ssl_certificate
end

#validation_urlObject

Returns the value of attribute validation_url.



10
11
12
# File 'lib/ruby/pay.rb', line 10

def validation_url
  @validation_url
end

Class Method Details

.setup(provider: DarajaAuthProvider.create, short_code: nil, confirmation_url: nil, validation_url: nil, b2c_result_url: nil, initiator_name: nil, initiator_password: nil, ssl_certificate: nil, balance_result_url: nil) ⇒ Object

receive all inputs for payment setup



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/ruby/pay.rb', line 44

def self.setup(
  provider: DarajaAuthProvider.create,
  short_code: nil,
  confirmation_url: nil,
  validation_url: nil,
  b2c_result_url: nil,
  initiator_name: nil,
  initiator_password: nil,
  ssl_certificate: nil,
  balance_result_url: nil
)
  AppConfig.new(provider: provider,
                short_code: short_code,
                confirmation_url: confirmation_url,
                validation_url: validation_url,
                b2c_result_url: b2c_result_url,
                initiator_name: initiator_name,
                initiator_password: initiator_password,
                ssl_certificate: ssl_certificate,
                balance_result_url: balance_result_url)
end

Instance Method Details

#register_urlsArray

register all request types (fail / success) urls

Returns:

  • (Array)

    response



68
69
70
# File 'lib/ruby/pay.rb', line 68

def register_urls
  %w[Completed Cancelled].map { |status| setup_status(status) }
end