Class: ApplePay::Merchant
- Inherits:
-
Object
- Object
- ApplePay::Merchant
- Defined in:
- lib/apple_pay/merchant.rb
Defined Under Namespace
Classes: APIError
Instance Attribute Summary collapse
-
#client_cert ⇒ Object
Returns the value of attribute client_cert.
-
#display_name ⇒ Object
Returns the value of attribute display_name.
-
#domain ⇒ Object
Returns the value of attribute domain.
-
#identifier ⇒ Object
Returns the value of attribute identifier.
-
#private_key ⇒ Object
Returns the value of attribute private_key.
Instance Method Summary collapse
- #authenticate(client_cert, private_key) ⇒ Object
- #http_client ⇒ Object
-
#initialize(identifier, domain:, display_name:) ⇒ Merchant
constructor
A new instance of Merchant.
- #start_session!(validation_url) ⇒ Object
Constructor Details
#initialize(identifier, domain:, display_name:) ⇒ Merchant
Returns a new instance of Merchant.
7 8 9 10 11 |
# File 'lib/apple_pay/merchant.rb', line 7 def initialize(identifier, domain:, display_name:) self.identifier = identifier self.domain = domain self.display_name = display_name end |
Instance Attribute Details
#client_cert ⇒ Object
Returns the value of attribute client_cert.
5 6 7 |
# File 'lib/apple_pay/merchant.rb', line 5 def client_cert @client_cert end |
#display_name ⇒ Object
Returns the value of attribute display_name.
5 6 7 |
# File 'lib/apple_pay/merchant.rb', line 5 def display_name @display_name end |
#domain ⇒ Object
Returns the value of attribute domain.
5 6 7 |
# File 'lib/apple_pay/merchant.rb', line 5 def domain @domain end |
#identifier ⇒ Object
Returns the value of attribute identifier.
5 6 7 |
# File 'lib/apple_pay/merchant.rb', line 5 def identifier @identifier end |
#private_key ⇒ Object
Returns the value of attribute private_key.
5 6 7 |
# File 'lib/apple_pay/merchant.rb', line 5 def private_key @private_key end |
Instance Method Details
#authenticate(client_cert, private_key) ⇒ Object
13 14 15 16 17 |
# File 'lib/apple_pay/merchant.rb', line 13 def authenticate(client_cert, private_key) self.client_cert = client_cert # NOTE: Apple Pay Merchant Identity self.private_key = private_key self end |
#http_client ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/apple_pay/merchant.rb', line 19 def http_client client = HTTPClient.new( agent_name: "ApplePay Gem (v#{VERSION})" ) client.request_filter << RequestFilter::Debugger.new if ApplePay.debugging? client.ssl_config.client_cert = client_cert client.ssl_config.client_key = private_key client end |
#start_session!(validation_url) ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/apple_pay/merchant.rb', line 29 def start_session!(validation_url) handle_response do http_client.post validation_url, { merchantIdentifier: identifier, domainName: domain, displayName: display_name }.to_json, 'Content-Type': 'application/json' end end |