Class: Square::CheckoutApi
- Defined in:
- lib/square/api/checkout_api.rb
Overview
CheckoutApi
Instance Attribute Summary
Attributes inherited from BaseApi
Instance Method Summary collapse
-
#create_checkout(location_id:, body:) ⇒ CreateCheckoutResponse Hash
Links a `checkoutId` to a `checkout_page_url` that customers are directed to in order to provide their payment information using a payment processing workflow hosted on connect.squareup.com.
-
#initialize(config, http_call_back: nil) ⇒ CheckoutApi
constructor
A new instance of CheckoutApi.
Methods inherited from BaseApi
#execute_request, #get_user_agent, #validate_parameters
Constructor Details
#initialize(config, http_call_back: nil) ⇒ CheckoutApi
Returns a new instance of CheckoutApi.
4 5 6 |
# File 'lib/square/api/checkout_api.rb', line 4 def initialize(config, http_call_back: nil) super(config, http_call_back: http_call_back) end |
Instance Method Details
#create_checkout(location_id:, body:) ⇒ CreateCheckoutResponse Hash
Links a `checkoutId` to a `checkout_page_url` that customers are directed to in order to provide their payment information using a payment processing workflow hosted on connect.squareup.com. location to associate the checkout with. containing the fields to POST for the request. See the corresponding object definition for field details.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/square/api/checkout_api.rb', line 17 def create_checkout(location_id:, body:) # Prepare query url. _query_builder = config.get_base_uri _query_builder << '/v2/locations/{location_id}/checkouts' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, 'location_id' => { 'value' => location_id, 'encode' => true } ) _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 |