Class: Ipizza::Provider::Base
- Inherits:
-
Object
- Object
- Ipizza::Provider::Base
- Defined in:
- lib/ipizza/provider/base.rb
Constant Summary collapse
- DEFAULT_VK_VERSION =
'008'- SUPPORTED_ENCODINGS =
%w(UTF-8 ISO-8859-1 WINDOWS-1257)
Class Attribute Summary collapse
-
.cancel_url ⇒ Object
Returns the value of attribute cancel_url.
-
.encoding ⇒ Object
Returns the value of attribute encoding.
-
.file_cert ⇒ Object
Returns the value of attribute file_cert.
-
.file_key ⇒ Object
Returns the value of attribute file_key.
-
.key_secret ⇒ Object
Returns the value of attribute key_secret.
-
.lang ⇒ Object
Returns the value of attribute lang.
-
.rec_acc ⇒ Object
Returns the value of attribute rec_acc.
-
.rec_id ⇒ Object
Returns the value of attribute rec_id.
-
.rec_name ⇒ Object
Returns the value of attribute rec_name.
-
.return_url ⇒ Object
Returns the value of attribute return_url.
-
.service_url ⇒ Object
Returns the value of attribute service_url.
-
.sign_algorithm ⇒ Object
Returns the value of attribute sign_algorithm.
-
.snd_id ⇒ Object
Returns the value of attribute snd_id.
-
.verification_algorithm ⇒ Object
Returns the value of attribute verification_algorithm.
-
.vk_version ⇒ Object
Returns the value of attribute vk_version.
Instance Method Summary collapse
- #authentication_request(service_no = 4011, param = {}) ⇒ Object
- #authentication_response(params) ⇒ Object
- #payment_request(payment, service_no = 1012) ⇒ Object
- #payment_response(params) ⇒ Object
Class Attribute Details
.cancel_url ⇒ Object
Returns the value of attribute cancel_url.
8 9 10 |
# File 'lib/ipizza/provider/base.rb', line 8 def cancel_url @cancel_url end |
.encoding ⇒ Object
Returns the value of attribute encoding.
8 9 10 |
# File 'lib/ipizza/provider/base.rb', line 8 def encoding @encoding end |
.file_cert ⇒ Object
Returns the value of attribute file_cert.
8 9 10 |
# File 'lib/ipizza/provider/base.rb', line 8 def file_cert @file_cert end |
.file_key ⇒ Object
Returns the value of attribute file_key.
8 9 10 |
# File 'lib/ipizza/provider/base.rb', line 8 def file_key @file_key end |
.key_secret ⇒ Object
Returns the value of attribute key_secret.
8 9 10 |
# File 'lib/ipizza/provider/base.rb', line 8 def key_secret @key_secret end |
.lang ⇒ Object
Returns the value of attribute lang.
8 9 10 |
# File 'lib/ipizza/provider/base.rb', line 8 def lang @lang end |
.rec_acc ⇒ Object
Returns the value of attribute rec_acc.
8 9 10 |
# File 'lib/ipizza/provider/base.rb', line 8 def rec_acc @rec_acc end |
.rec_id ⇒ Object
Returns the value of attribute rec_id.
8 9 10 |
# File 'lib/ipizza/provider/base.rb', line 8 def rec_id @rec_id end |
.rec_name ⇒ Object
Returns the value of attribute rec_name.
8 9 10 |
# File 'lib/ipizza/provider/base.rb', line 8 def rec_name @rec_name end |
.return_url ⇒ Object
Returns the value of attribute return_url.
8 9 10 |
# File 'lib/ipizza/provider/base.rb', line 8 def return_url @return_url end |
.service_url ⇒ Object
Returns the value of attribute service_url.
8 9 10 |
# File 'lib/ipizza/provider/base.rb', line 8 def service_url @service_url end |
.sign_algorithm ⇒ Object
Returns the value of attribute sign_algorithm.
8 9 10 |
# File 'lib/ipizza/provider/base.rb', line 8 def sign_algorithm @sign_algorithm end |
.snd_id ⇒ Object
Returns the value of attribute snd_id.
8 9 10 |
# File 'lib/ipizza/provider/base.rb', line 8 def snd_id @snd_id end |
.verification_algorithm ⇒ Object
Returns the value of attribute verification_algorithm.
8 9 10 |
# File 'lib/ipizza/provider/base.rb', line 8 def verification_algorithm @verification_algorithm end |
.vk_version ⇒ Object
Returns the value of attribute vk_version.
8 9 10 |
# File 'lib/ipizza/provider/base.rb', line 8 def vk_version @vk_version end |
Instance Method Details
#authentication_request(service_no = 4011, param = {}) ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/ipizza/provider/base.rb', line 71 def authentication_request(service_no = 4011, param = {}) req = Ipizza::AuthenticationRequest.new req.service_url = self.class.service_url req.sign_params = { 'VK_SERVICE' => service_no, 'VK_VERSION' => vk_version, 'VK_SND_ID' => self.class.snd_id, 'VK_RETURN' => self.class.return_url, 'VK_DATETIME' => Ipizza::Util.time_to_iso8601(Time.now), 'VK_RID' => param[:vk_rid] } case service_no.to_s when '4011' req.sign_params['VK_REPLY'] = '3012' when '4012' req.sign_params.merge( 'VK_REC_ID' => self.class.rec_id, 'VK_NONCE' => param[:vk_nonce] ) end req.extra_params = { 'VK_ENCODING' => get_encoding(self.class.encoding), 'VK_LANG' => self.class.lang } req.sign( self.class.file_key, self.class.key_secret, Ipizza::Request::PARAM_ORDER[service_no.to_s], Ipizza::Request::DEFAULT_MAC_PARAM, self.class.sign_algorithm || Ipizza::Util::DEFAULT_HASH_ALGORITHM ) req end |
#authentication_response(params) ⇒ Object
108 109 110 111 112 113 114 115 |
# File 'lib/ipizza/provider/base.rb', line 108 def authentication_response(params) response = Ipizza::AuthenticationResponse.new(params) response.verify( self.class.file_cert, self.class.verification_algorithm || Ipizza::Util::DEFAULT_HASH_ALGORITHM ) response end |
#payment_request(payment, service_no = 1012) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/ipizza/provider/base.rb', line 25 def payment_request(payment, service_no = 1012) req = Ipizza::PaymentRequest.new req.service_url = self.class.service_url req.sign_params = { 'VK_SERVICE' => service_no, 'VK_VERSION' => vk_version, '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., 'VK_RETURN' => self.class.return_url, 'VK_CANCEL' => self.class.cancel_url, 'VK_DATETIME' => Ipizza::Util.time_to_iso8601(Time.now) } if service_no.to_s == '1011' req.sign_params['VK_ACC'] = self.class.rec_acc req.sign_params['VK_NAME'] = self.class.rec_name end req.extra_params = { 'VK_ENCODING' => get_encoding(self.class.encoding), 'VK_LANG' => self.class.lang } req.sign( self.class.file_key, self.class.key_secret, Ipizza::Request::PARAM_ORDER[service_no.to_s], Ipizza::Request::DEFAULT_MAC_PARAM, self.class.sign_algorithm || Ipizza::Util::DEFAULT_HASH_ALGORITHM ) req end |
#payment_response(params) ⇒ Object
62 63 64 65 66 67 68 69 |
# File 'lib/ipizza/provider/base.rb', line 62 def payment_response(params) response = Ipizza::PaymentResponse.new(params) response.verify( self.class.file_cert, self.class.verification_algorithm || Ipizza::Util::DEFAULT_HASH_ALGORITHM ) response end |