Class: Square::ApplePayApi

Inherits:
BaseApi
  • Object
show all
Defined in:
lib/square/api/apple_pay_api.rb

Overview

ApplePayApi

Instance Attribute Summary

Attributes inherited from BaseApi

#config, #http_call_back

Instance Method Summary collapse

Methods inherited from BaseApi

#execute_request, #get_user_agent, #validate_parameters, #validate_parameters_types

Constructor Details

#initialize(config, http_call_back: nil) ⇒ ApplePayApi

Returns a new instance of ApplePayApi.



4
5
6
# File 'lib/square/api/apple_pay_api.rb', line 4

def initialize(config, http_call_back: nil)
  super(config, http_call_back: http_call_back)
end

Instance Method Details

#register_domain(body:) ⇒ RegisterDomainResponse Hash

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: The SqPaymentForm library is deprecated as of May 13, 2021, and will only receive critical security updates until it is retired on October 31, 2022. You must migrate your payment form code to the Web Payments SDK to continue using your domain for Apple Pay. For more information on migrating to the Web Payments SDK, see [Migrate to the Web Payments SDK](developer.squareup.com/docs/web-payments/migrate). 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). containing the fields to POST for the request. See the corresponding object definition for field details.

Parameters:

  • body (RegisterDomainRequest)

    Required parameter: An object

Returns:

  • (RegisterDomainResponse Hash)

    response from the API call



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/square/api/apple_pay_api.rb', line 30

def register_domain(body:)
  # Prepare query url.
  _query_builder = config.get_base_uri
  _query_builder << '/v2/apple-pay/domains'
  _query_url = APIHelper.clean_url _query_builder

  # Prepare headers.
  _headers = {
    'accept' => 'application/json',
    'Content-Type' => 'application/json'
  }

  # Prepare and execute HttpRequest.
  _request = config.http_client.post(
    _query_url,
    headers: _headers,
    parameters: body.to_json
  )
  OAuth2.apply(config, _request)
  _response = execute_request(_request)

  # Return appropriate response type.
  decoded = APIHelper.json_deserialize(_response.raw_body)
  _errors = APIHelper.map_response(decoded, ['errors'])
  ApiResponse.new(
    _response, data: decoded, errors: _errors
  )
end