Class: NetRegistry::Client
- Inherits:
-
Object
- Object
- NetRegistry::Client
- Defined in:
- lib/net_registry/client.rb
Instance Attribute Summary collapse
-
#base_url ⇒ Object
Returns the value of attribute base_url.
-
#factory ⇒ Object
Returns the value of attribute factory.
-
#login ⇒ Object
Returns the value of attribute login.
-
#merchant_id ⇒ Object
Returns the value of attribute merchant_id.
-
#password ⇒ Object
Returns the value of attribute password.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(merchant_id: ENV["NET_REGISTRY_MERCHANT"], password: ENV["NET_REGISTRY_PASSWORD"]) ⇒ Client
constructor
A new instance of Client.
-
#preauth(params = {}) ⇒ Object
Alias for request(COMMAND: “preauth”, AMOUNT: 100 … etc).
-
#purchase(params = {}) ⇒ Object
Alias for request(COMMAND: “purchase”, AMOUNT: 100 … etc).
-
#refund(params = {}) ⇒ Object
Alias for request(COMMAND: “refund”, AMOUNT: 100 … etc).
- #request(params = {}) ⇒ Object
-
#status(params = {}) ⇒ Object
Alias for request(COMMAND: “status”, AMOUNT: 100 … etc).
Constructor Details
#initialize(merchant_id: ENV["NET_REGISTRY_MERCHANT"], password: ENV["NET_REGISTRY_PASSWORD"]) ⇒ Client
Returns a new instance of Client.
32 33 34 35 36 37 38 39 |
# File 'lib/net_registry/client.rb', line 32 def initialize(merchant_id: ENV["NET_REGISTRY_MERCHANT"], password: ENV["NET_REGISTRY_PASSWORD"]) @merchant_id, @password = merchant_id, password @login = "#{@merchant_id}/#{@password}" @base_url = "https://paygate.ssllock.net/external2.pl" @uri = URI(@base_url) @factory = NetRegistry::ResponseBuilder.new end |
Instance Attribute Details
#base_url ⇒ Object
Returns the value of attribute base_url.
30 31 32 |
# File 'lib/net_registry/client.rb', line 30 def base_url @base_url end |
#factory ⇒ Object
Returns the value of attribute factory.
30 31 32 |
# File 'lib/net_registry/client.rb', line 30 def factory @factory end |
#login ⇒ Object
Returns the value of attribute login.
30 31 32 |
# File 'lib/net_registry/client.rb', line 30 def login @login end |
#merchant_id ⇒ Object
Returns the value of attribute merchant_id.
30 31 32 |
# File 'lib/net_registry/client.rb', line 30 def merchant_id @merchant_id end |
#password ⇒ Object
Returns the value of attribute password.
30 31 32 |
# File 'lib/net_registry/client.rb', line 30 def password @password end |
#url ⇒ Object
Returns the value of attribute url.
30 31 32 |
# File 'lib/net_registry/client.rb', line 30 def url @url end |
Instance Method Details
#preauth(params = {}) ⇒ Object
Alias for request(COMMAND: “preauth”, AMOUNT: 100 … etc)
64 65 66 67 |
# File 'lib/net_registry/client.rb', line 64 def preauth(params = {}) raise TypeError, "params is not a hash" if !params.is_a?(Hash) request(params.merge!(COMMAND: "preauth")) end |
#purchase(params = {}) ⇒ Object
Alias for request(COMMAND: “purchase”, AMOUNT: 100 … etc)
43 44 45 46 |
# File 'lib/net_registry/client.rb', line 43 def purchase(params = {}) raise TypeError, "params is not a hash" if !params.is_a?(Hash) request(params.merge!(COMMAND: "purchase")) end |
#refund(params = {}) ⇒ Object
Alias for request(COMMAND: “refund”, AMOUNT: 100 … etc)
50 51 52 53 |
# File 'lib/net_registry/client.rb', line 50 def refund(params = {}) raise TypeError, "params is not a hash" if !params.is_a?(Hash) request(params.merge!(COMMAND: "refund")) end |
#request(params = {}) ⇒ Object
69 70 71 72 73 |
# File 'lib/net_registry/client.rb', line 69 def request(params = {}) raise TypeError, "params is not a hash" if !params.is_a?(Hash) params.merge!(LOGIN: @login) @factory.verify_params(params) ? send_request(params) : @factory.create end |
#status(params = {}) ⇒ Object
Alias for request(COMMAND: “status”, AMOUNT: 100 … etc)
57 58 59 60 |
# File 'lib/net_registry/client.rb', line 57 def status(params = {}) raise TypeError, "params is not a hash" if !params.is_a?(Hash) request(params.merge!(COMMAND: "status")) end |