Class: Ipizza::Provider::Swedbank

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

Class Attribute Summary collapse

Instance Method Summary collapse

Class Attribute Details

.cancel_urlObject

Returns the value of attribute cancel_url.



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

def cancel_url
  @cancel_url
end

.encodingObject

Returns the value of attribute encoding.



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

def encoding
  @encoding
end

.file_certObject

Returns the value of attribute file_cert.



5
6
7
# File 'lib/ipizza/provider/swedbank.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/swedbank.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/swedbank.rb', line 5

def key_secret
  @key_secret
end

.return_urlObject

Returns the value of attribute return_url.



5
6
7
# File 'lib/ipizza/provider/swedbank.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/swedbank.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/swedbank.rb', line 5

def snd_id
  @snd_id
end

Instance Method Details

#authentication_request(service_no = 4001) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/ipizza/provider/swedbank.rb', line 40

def authentication_request(service_no = 4001)
  req = Ipizza::AuthenticationRequest.new
  req.service_url = self.class.service_url
  req.sign_params = {
    'VK_SERVICE' => service_no,
    'VK_VERSION' => '008',
    'VK_SND_ID' => self.class.snd_id,
    'VK_REPLY' => '3002',
    'VK_RETURN' => self.class.return_url,
    'VK_DATE' => Date.today.strftime('%d.%m.%Y'),
    'VK_TIME' => Time.now.strftime('%H:%M:%S')
  }

  req.extra_params = {
    'VK_ENCODING' => self.class.encoding
  }

  param_order = ['VK_SERVICE', 'VK_VERSION', 'VK_SND_ID', 'VK_REPLY', 'VK_RETURN', 'VK_DATE', 'VK_TIME']

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

#authentication_response(params) ⇒ Object



63
64
65
66
67
# File 'lib/ipizza/provider/swedbank.rb', line 63

def authentication_response(params)
  response = Ipizza::AuthenticationResponse.new(params)
  response.verify(self.class.file_cert, self.class.encoding)
  return response
end

#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
# File 'lib/ipizza/provider/swedbank.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' => '1002',
    '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
  }

  req.extra_params = {
    'VK_CHARSET' => self.class.encoding,
    'VK_RETURN' => self.class.return_url,
    'VK_CANCEL' => self.class.cancel_url
  }

  param_order = ['VK_SERVICE', 'VK_VERSION', 'VK_SND_ID', 'VK_STAMP', 'VK_AMOUNT', 'VK_CURR', 'VK_REF', 'VK_MSG']

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

#payment_response(params) ⇒ Object



34
35
36
37
38
# File 'lib/ipizza/provider/swedbank.rb', line 34

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