Class: Ipizza::Provider::Krediidipank

Inherits:
Object
  • Object
show all
Defined in:
lib/ipizza/provider/krediidipank.rb

Class Attribute Summary collapse

Instance Method Summary collapse

Class Attribute Details

.encodingObject

Returns the value of attribute encoding.



5
6
7
# File 'lib/ipizza/provider/krediidipank.rb', line 5

def encoding
  @encoding
end

.file_certObject

Returns the value of attribute file_cert.



5
6
7
# File 'lib/ipizza/provider/krediidipank.rb', line 5

def file_cert
  @file_cert
end

.file_keyObject

Returns the value of attribute file_key.



5
6
7
# File 'lib/ipizza/provider/krediidipank.rb', line 5

def file_key
  @file_key
end

.key_secretObject

Returns the value of attribute key_secret.



5
6
7
# File 'lib/ipizza/provider/krediidipank.rb', line 5

def key_secret
  @key_secret
end

.langObject

Returns the value of attribute lang.



5
6
7
# File 'lib/ipizza/provider/krediidipank.rb', line 5

def lang
  @lang
end

.rec_accObject

Returns the value of attribute rec_acc.



5
6
7
# File 'lib/ipizza/provider/krediidipank.rb', line 5

def rec_acc
  @rec_acc
end

.rec_nameObject

Returns the value of attribute rec_name.



5
6
7
# File 'lib/ipizza/provider/krediidipank.rb', line 5

def rec_name
  @rec_name
end

.return_urlObject

Returns the value of attribute return_url.



5
6
7
# File 'lib/ipizza/provider/krediidipank.rb', line 5

def return_url
  @return_url
end

.service_urlObject

Returns the value of attribute service_url.



5
6
7
# File 'lib/ipizza/provider/krediidipank.rb', line 5

def service_url
  @service_url
end

.snd_idObject

Returns the value of attribute snd_id.



5
6
7
# File 'lib/ipizza/provider/krediidipank.rb', line 5

def snd_id
  @snd_id
end

Instance Method Details

#payment_request(payment, service = 1002) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/ipizza/provider/krediidipank.rb', line 8

def payment_request(payment, service = 1002)
  req = Ipizza::PaymentRequest.new
  req.service_url = self.class.service_url
  req.sign_params = {
    'VK_SERVICE' => service.to_s,
    'VK_VERSION' => '008',
    'VK_SND_ID' => self.class.snd_id,
    'VK_STAMP' => payment.stamp,
    'VK_AMOUNT' => sprintf('%.2f', payment.amount),
    'VK_CURR' => payment.currency,
    'VK_REF' => Ipizza::Util.sign_731(payment.refnum),
    'VK_MSG' => payment.message
  }

  if service == 1001
    req.sign_params['VK_ACC'] = self.class.rec_acc
    req.sign_params['VK_NAME'] = self.class.rec_name
  end

  req.extra_params = {
    'VK_CHARSET' => self.class.encoding,
    'VK_RETURN' => self.class.return_url,
    'VK_LANG' => self.class.lang
  }

  if service == 1001
    param_order = ['VK_SERVICE', 'VK_VERSION', 'VK_SND_ID', 'VK_STAMP', 'VK_AMOUNT', 'VK_CURR', 'VK_ACC', 'VK_NAME', 'VK_REF', 'VK_MSG']
  else
    param_order = ['VK_SERVICE', 'VK_VERSION', 'VK_SND_ID', 'VK_STAMP', 'VK_AMOUNT', 'VK_CURR', 'VK_REF', 'VK_MSG']
  end

  req.sign(self.class.file_key, self.class.key_secret, param_order)
  req
end

#payment_response(params) ⇒ Object



43
44
45
46
47
48
# File 'lib/ipizza/provider/krediidipank.rb', line 43

def payment_response(params)
  response = Ipizza::PaymentResponse.new(params)
  response.verify(self.class.file_cert)

  return response
end