Class: Twoctwop::Request
- Inherits:
-
Object
- Object
- Twoctwop::Request
- Defined in:
- lib/twoctwop/request.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#digest ⇒ Object
Returns the value of attribute digest.
-
#token ⇒ Object
Returns the value of attribute token.
Instance Method Summary collapse
- #endpoint ⇒ Object
-
#initialize(data: {}, token: nil) ⇒ Request
constructor
A new instance of Request.
- #make_non_3ds_payment! ⇒ Object
- #payload ⇒ Object
Constructor Details
#initialize(data: {}, token: nil) ⇒ Request
Returns a new instance of Request.
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/twoctwop/request.rb', line 13 def initialize(data: {}, token: nil) raise "Set end point" if Twoctwop::Config.endpoint.nil? raise "Merchant ID is nil" if Twoctwop::Config.merchant_id.nil? raise "Secret key is nil" if Twoctwop::Config.secret_key.nil? @token = token @digest = OpenSSL::Digest.new('sha1') @data = data end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
10 11 12 |
# File 'lib/twoctwop/request.rb', line 10 def data @data end |
#digest ⇒ Object
Returns the value of attribute digest.
10 11 12 |
# File 'lib/twoctwop/request.rb', line 10 def digest @digest end |
#token ⇒ Object
Returns the value of attribute token.
10 11 12 |
# File 'lib/twoctwop/request.rb', line 10 def token @token end |
Instance Method Details
#endpoint ⇒ Object
24 25 26 |
# File 'lib/twoctwop/request.rb', line 24 def endpoint Twoctwop::Config.endpoint end |
#make_non_3ds_payment! ⇒ Object
32 33 34 35 |
# File 'lib/twoctwop/request.rb', line 32 def make_non_3ds_payment! body = RestClient.post endpoint, :paymentRequest => payload Response.new(body).decrypt_body end |
#payload ⇒ Object
28 29 30 |
# File 'lib/twoctwop/request.rb', line 28 def payload Base64.strict_encode64(build_request) end |