Class: Ipizza::Provider::Base
- Inherits:
-
Object
- Object
- Ipizza::Provider::Base
- Defined in:
- lib/ipizza/provider/base.rb
Constant Summary collapse
- 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.
-
.snd_id ⇒ Object
Returns the value of attribute snd_id.
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.
7 8 9 |
# File 'lib/ipizza/provider/base.rb', line 7 def cancel_url @cancel_url end |
.encoding ⇒ Object
Returns the value of attribute encoding.
7 8 9 |
# File 'lib/ipizza/provider/base.rb', line 7 def encoding @encoding end |
.file_cert ⇒ Object
Returns the value of attribute file_cert.
7 8 9 |
# File 'lib/ipizza/provider/base.rb', line 7 def file_cert @file_cert end |
.file_key ⇒ Object
Returns the value of attribute file_key.
7 8 9 |
# File 'lib/ipizza/provider/base.rb', line 7 def file_key @file_key end |
.key_secret ⇒ Object
Returns the value of attribute key_secret.
7 8 9 |
# File 'lib/ipizza/provider/base.rb', line 7 def key_secret @key_secret end |
.lang ⇒ Object
Returns the value of attribute lang.
7 8 9 |
# File 'lib/ipizza/provider/base.rb', line 7 def lang @lang end |
.rec_acc ⇒ Object
Returns the value of attribute rec_acc.
7 8 9 |
# File 'lib/ipizza/provider/base.rb', line 7 def rec_acc @rec_acc end |
.rec_id ⇒ Object
Returns the value of attribute rec_id.
7 8 9 |
# File 'lib/ipizza/provider/base.rb', line 7 def rec_id @rec_id end |
.rec_name ⇒ Object
Returns the value of attribute rec_name.
7 8 9 |
# File 'lib/ipizza/provider/base.rb', line 7 def rec_name @rec_name end |
.return_url ⇒ Object
Returns the value of attribute return_url.
7 8 9 |
# File 'lib/ipizza/provider/base.rb', line 7 def return_url @return_url end |
.service_url ⇒ Object
Returns the value of attribute service_url.
7 8 9 |
# File 'lib/ipizza/provider/base.rb', line 7 def service_url @service_url end |
.snd_id ⇒ Object
Returns the value of attribute snd_id.
7 8 9 |
# File 'lib/ipizza/provider/base.rb', line 7 def snd_id @snd_id end |
Instance Method Details
#authentication_request(service_no = 4011, param = {}) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/ipizza/provider/base.rb', line 47 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' => '008', '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]) req end |
#authentication_response(params) ⇒ Object
78 79 80 81 82 |
# File 'lib/ipizza/provider/base.rb', line 78 def authentication_response(params) response = Ipizza::AuthenticationResponse.new(params) response.verify(self.class.file_cert) response end |
#payment_request(payment, service_no = 1012) ⇒ Object
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 |
# File 'lib/ipizza/provider/base.rb', line 10 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' => '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., '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]) req end |
#payment_response(params) ⇒ Object
41 42 43 44 45 |
# File 'lib/ipizza/provider/base.rb', line 41 def payment_response(params) response = Ipizza::PaymentResponse.new(params) response.verify(self.class.file_cert) response end |