Class: Ipizza::Provider::Nordea

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

Overview

TODO: configure whether use sha-1 or md5 for signing and verification

Defined Under Namespace

Classes: AuthenticationRequest, AuthenticationResponse, PaymentRequest, PaymentResponse

Class Attribute Summary collapse

Instance Method Summary collapse

Class Attribute Details

.auth_cancel_urlObject

Returns the value of attribute auth_cancel_url.



14
15
16
# File 'lib/ipizza/provider/nordea.rb', line 14

def auth_cancel_url
  @auth_cancel_url
end

.auth_languageObject

Returns the value of attribute auth_language.



14
15
16
# File 'lib/ipizza/provider/nordea.rb', line 14

def auth_language
  @auth_language
end

.auth_rcv_idObject

Returns the value of attribute auth_rcv_id.



15
16
17
# File 'lib/ipizza/provider/nordea.rb', line 15

def auth_rcv_id
  @auth_rcv_id
end

.auth_reject_urlObject

Returns the value of attribute auth_reject_url.



14
15
16
# File 'lib/ipizza/provider/nordea.rb', line 14

def auth_reject_url
  @auth_reject_url
end

.auth_return_urlObject

Returns the value of attribute auth_return_url.



14
15
16
# File 'lib/ipizza/provider/nordea.rb', line 14

def auth_return_url
  @auth_return_url
end

.auth_service_urlObject

Returns the value of attribute auth_service_url.



14
15
16
# File 'lib/ipizza/provider/nordea.rb', line 14

def auth_service_url
  @auth_service_url
end

.confirmObject

Returns the value of attribute confirm.



16
17
18
# File 'lib/ipizza/provider/nordea.rb', line 16

def confirm
  @confirm
end

.file_keyObject

Returns the value of attribute file_key.



16
17
18
# File 'lib/ipizza/provider/nordea.rb', line 16

def file_key
  @file_key
end

.keyversObject

Returns the value of attribute keyvers.



16
17
18
# File 'lib/ipizza/provider/nordea.rb', line 16

def keyvers
  @keyvers
end

.payments_cancel_urlObject

Returns the value of attribute payments_cancel_url.



12
13
14
# File 'lib/ipizza/provider/nordea.rb', line 12

def payments_cancel_url
  @payments_cancel_url
end

.payments_languageObject

Returns the value of attribute payments_language.



13
14
15
# File 'lib/ipizza/provider/nordea.rb', line 13

def payments_language
  @payments_language
end

.payments_rcv_idObject

Returns the value of attribute payments_rcv_id.



13
14
15
# File 'lib/ipizza/provider/nordea.rb', line 13

def payments_rcv_id
  @payments_rcv_id
end

.payments_reject_urlObject

Returns the value of attribute payments_reject_url.



12
13
14
# File 'lib/ipizza/provider/nordea.rb', line 12

def payments_reject_url
  @payments_reject_url
end

.payments_return_urlObject

Returns the value of attribute payments_return_url.



12
13
14
# File 'lib/ipizza/provider/nordea.rb', line 12

def payments_return_url
  @payments_return_url
end

.payments_service_urlObject

Returns the value of attribute payments_service_url.



12
13
14
# File 'lib/ipizza/provider/nordea.rb', line 12

def payments_service_url
  @payments_service_url
end

.rcv_accountObject

Returns the value of attribute rcv_account.



16
17
18
# File 'lib/ipizza/provider/nordea.rb', line 16

def 
  @rcv_account
end

.rcv_nameObject

Returns the value of attribute rcv_name.



16
17
18
# File 'lib/ipizza/provider/nordea.rb', line 16

def rcv_name
  @rcv_name
end

Instance Method Details

#authentication_requestObject



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/ipizza/provider/nordea.rb', line 51

def authentication_request
  req = Ipizza::Provider::Nordea::AuthenticationRequest.new
  req.service_url = self.class.auth_service_url
  req.params = {
    'ACTION_ID' => '701',
    'VERS' => '0002',
    'RCVID' => self.class.auth_rcv_id,
    'LANGCODE' => self.class.auth_language,
    'STAMP' => Time.now.strftime('%Y%m%d%H%M%S'),
    'IDTYPE' => '02',
    'KEYVERS' => self.class.keyvers,
    'RETLINK' => self.class.auth_return_url,
    'CANLINK' => self.class.auth_cancel_url,
    'REJLINK' => self.class.auth_reject_url,
    'ALG' => '01'
  }
  req.sign(self.class.file_key)
  req
end

#authentication_response(params) ⇒ Object



71
72
73
74
75
# File 'lib/ipizza/provider/nordea.rb', line 71

def authentication_response(params)
  response = Ipizza::Provider::Nordea::AuthenticationResponse.new(params)
  response.verify(self.class.file_key)
  return response
end

#payment_request(payment, service = 1002) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/ipizza/provider/nordea.rb', line 19

def payment_request(payment, service = 1002)
  req = Ipizza::Provider::Nordea::PaymentRequest.new
  req.service_url = self.class.payments_service_url
  req.params = {
    'VERSION' => '0003',
    'STAMP' => payment.stamp,
    'RCV_ID' => self.class.payments_rcv_id,
    # 'RCV_ACCOUNT' => self.rcv_account,
    # 'RCV_NAME' => self.rcv_name,
    'LANGUAGE' => self.class.payments_language,
    'AMOUNT' => sprintf('%.2f', payment.amount),
    'REF' => Ipizza::Util.sign_731(payment.refnum),
    'DATE' => 'EXPRESS',
    'MSG' => payment.message,
    'CONFIRM' => self.class.confirm,
    'CUR' => payment.currency,
    'KEYVERS' => self.class.keyvers,
    'REJECT' => self.class.payments_reject_url,
    'RETURN' => self.class.payments_return_url,
    'CANCEL' => self.class.payments_cancel_url
  }

  req.sign(self.class.file_key)
  req
end

#payment_response(params) ⇒ Object



45
46
47
48
49
# File 'lib/ipizza/provider/nordea.rb', line 45

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