Class: Square::ApplePay::Client
- Inherits:
-
Object
- Object
- Square::ApplePay::Client
- Defined in:
- lib/square/apple_pay/client.rb
Instance Method Summary collapse
- #initialize(client:) ⇒ void constructor
-
#register_domain(request_options: {}, **params) ⇒ Square::Types::RegisterDomainResponse
Activates a domain for use with Apple Pay on the Web and Square.
Constructor Details
#initialize(client:) ⇒ void
9 10 11 |
# File 'lib/square/apple_pay/client.rb', line 9 def initialize(client:) @client = client end |
Instance Method Details
#register_domain(request_options: {}, **params) ⇒ Square::Types::RegisterDomainResponse
Activates a domain for use with Apple Pay on the Web and Square. A validation is performed on this domain by Apple to ensure that it is properly set up as an Apple Pay enabled domain.
This endpoint provides an easy way for platform developers to bulk activate Apple Pay on the Web with Square for merchants using their platform.
Note: You will need to host a valid domain verification file on your domain to support Apple Pay. The current version of this file is always available at app.squareup.com/digital-wallets/apple-pay/apple-developer-merchantid-domain-association, and should be hosted at ‘.well_known/apple-developer-merchantid-domain-association` on your domain. This file is subject to change; we strongly recommend checking for updates regularly and avoiding long-lived caches that might not keep in sync with the correct file version.
To learn more about the Web Payments SDK and how to add Apple Pay, see [Take an Apple Pay Payment](developer.squareup.com/docs/web-payments/apple-pay).
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/square/apple_pay/client.rb', line 39 def register_domain(request_options: {}, **params) params = Square::Internal::Types::Utils.normalize_keys(params) request = Square::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "v2/apple-pay/domains", body: Square::ApplePay::Types::RegisterDomainRequest.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Square::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Square::Types::RegisterDomainResponse.load(response.body) else error_class = Square::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |