Class: DkPaymentGateway::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/dk_payment_gateway/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config = nil) ⇒ Client

Returns a new instance of Client.



10
11
12
13
14
15
# File 'lib/dk_payment_gateway/client.rb', line 10

def initialize(config = nil)
  @config = config || DkPaymentGateway.configuration
  validate_configuration!
  @access_token = nil
  @private_key = nil
end

Instance Attribute Details

#access_tokenObject (readonly)

Returns the value of attribute access_token.



8
9
10
# File 'lib/dk_payment_gateway/client.rb', line 8

def access_token
  @access_token
end

#configObject (readonly)

Returns the value of attribute config.



8
9
10
# File 'lib/dk_payment_gateway/client.rb', line 8

def config
  @config
end

#private_keyObject (readonly)

Returns the value of attribute private_key.



8
9
10
# File 'lib/dk_payment_gateway/client.rb', line 8

def private_key
  @private_key
end

Instance Method Details

#authenticate!Object

Authentication methods



18
19
20
21
22
23
# File 'lib/dk_payment_gateway/client.rb', line 18

def authenticate!
  auth = Authentication.new(self)
  @access_token ||= auth.fetch_token
  @private_key ||= auth.fetch_private_key
  self
end

#get(path, params: {}, headers: {}, skip_auth: false) ⇒ Object



50
51
52
# File 'lib/dk_payment_gateway/client.rb', line 50

def get(path, params: {}, headers: {}, skip_auth: false)
  request(:get, path, params: params, headers: headers, skip_auth: skip_auth)
end

#intra_transactionObject

Intra Transaction methods



31
32
33
# File 'lib/dk_payment_gateway/client.rb', line 31

def intra_transaction
  @intra_transaction ||= IntraTransaction.new(self)
end

#post(path, body: {}, headers: {}, skip_auth: false) ⇒ Object

HTTP request methods



46
47
48
# File 'lib/dk_payment_gateway/client.rb', line 46

def post(path, body: {}, headers: {}, skip_auth: false)
  request(:post, path, body: body, headers: headers, skip_auth: skip_auth)
end

#pull_paymentObject

Pull Payment methods



26
27
28
# File 'lib/dk_payment_gateway/client.rb', line 26

def pull_payment
  @pull_payment ||= PullPayment.new(self)
end

#qr_paymentObject

QR Payment methods



36
37
38
# File 'lib/dk_payment_gateway/client.rb', line 36

def qr_payment
  @qr_payment ||= QrPayment.new(self)
end

#transaction_statusObject

Transaction Status methods



41
42
43
# File 'lib/dk_payment_gateway/client.rb', line 41

def transaction_status
  @transaction_status ||= TransactionStatus.new(self)
end