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.
-
#create_payment_link(body:) ⇒ CreatePaymentLinkResponse Hash
Creates a Square-hosted checkout page.
-
#delete_payment_link(id:) ⇒ DeletePaymentLinkResponse Hash
Deletes a payment link.
-
#list_payment_links(cursor: nil, limit: nil) ⇒ ListPaymentLinksResponse Hash
Lists all payment links.
-
#retrieve_payment_link(id:) ⇒ RetrievePaymentLinkResponse Hash
Retrieves a payment link.
-
#update_payment_link(id:, body:) ⇒ UpdatePaymentLinkResponse Hash
Updates a payment link.
Methods inherited from BaseApi
#initialize, #new_api_call_builder, #new_parameter, #new_request_builder, #new_response_handler, user_agent, user_agent_parameters
Constructor Details
This class inherits a constructor from Square::BaseApi
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. NOTE: The Checkout API has been updated with new features. For more information, see [Checkout API highlights](developer.squareup.com/docs/checkout-api#checkout-api- highlights). We recommend that you use the new ($e/Checkout/CreatePaymentLink) endpoint in place of this previously released endpoint. location to associate the checkout with. containing the fields to POST for the request. See the corresponding object definition for field details.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/square/api/checkout_api.rb', line 20 def create_checkout(location_id:, body:) warn 'Endpoint create_checkout in CheckoutApi is deprecated' new_api_call_builder .request(new_request_builder(HttpMethodEnum::POST, '/v2/locations/{location_id}/checkouts', 'default') .template_param(new_parameter(location_id, key: 'location_id') .should_encode(true)) .header_param(new_parameter('application/json', key: 'Content-Type')) .body_param(new_parameter(body)) .header_param(new_parameter('application/json', key: 'accept')) .body_serializer(proc do |param| param.to_json unless param.nil? end) .auth(Single.new('global'))) .response(new_response_handler .deserializer(APIHelper.method(:json_deserialize)) .is_api_response(true) .convertor(ApiResponse.method(:create))) .execute end |
#create_payment_link(body:) ⇒ CreatePaymentLinkResponse Hash
Creates a Square-hosted checkout page. Applications can share the resulting payment link with their buyer to pay for goods and services. containing the fields to POST for the request. See the corresponding object definition for field details.
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/square/api/checkout_api.rb', line 77 def create_payment_link(body:) new_api_call_builder .request(new_request_builder(HttpMethodEnum::POST, '/v2/online-checkout/payment-links', 'default') .header_param(new_parameter('application/json', key: 'Content-Type')) .body_param(new_parameter(body)) .header_param(new_parameter('application/json', key: 'accept')) .body_serializer(proc do |param| param.to_json unless param.nil? end) .auth(Single.new('global'))) .response(new_response_handler .deserializer(APIHelper.method(:json_deserialize)) .is_api_response(true) .convertor(ApiResponse.method(:create))) .execute end |
#delete_payment_link(id:) ⇒ DeletePaymentLinkResponse Hash
Deletes a payment link. delete.
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/square/api/checkout_api.rb', line 98 def delete_payment_link(id:) new_api_call_builder .request(new_request_builder(HttpMethodEnum::DELETE, '/v2/online-checkout/payment-links/{id}', 'default') .template_param(new_parameter(id, key: 'id') .should_encode(true)) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('global'))) .response(new_response_handler .deserializer(APIHelper.method(:json_deserialize)) .is_api_response(true) .convertor(ApiResponse.method(:create))) .execute end |
#list_payment_links(cursor: nil, limit: nil) ⇒ ListPaymentLinksResponse Hash
Lists all payment links. a previous call to this endpoint. Provide this cursor to retrieve the next set of results for the original query. If a cursor is not provided, the endpoint returns the first page of the results. For more information, see [Pagination](developer.squareup.com/docs/basics/api101/pagination) . results to return per page. The limit is advisory and the implementation might return more or less results. If the supplied limit is negative, zero, or greater than the maximum limit of 1000, it is ignored. Default value: ‘100`
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/square/api/checkout_api.rb', line 54 def list_payment_links(cursor: nil, limit: nil) new_api_call_builder .request(new_request_builder(HttpMethodEnum::GET, '/v2/online-checkout/payment-links', 'default') .query_param(new_parameter(cursor, key: 'cursor')) .query_param(new_parameter(limit, key: 'limit')) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('global'))) .response(new_response_handler .deserializer(APIHelper.method(:json_deserialize)) .is_api_response(true) .convertor(ApiResponse.method(:create))) .execute end |
#retrieve_payment_link(id:) ⇒ RetrievePaymentLinkResponse Hash
Retrieves a payment link.
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/square/api/checkout_api.rb', line 117 def retrieve_payment_link(id:) new_api_call_builder .request(new_request_builder(HttpMethodEnum::GET, '/v2/online-checkout/payment-links/{id}', 'default') .template_param(new_parameter(id, key: 'id') .should_encode(true)) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('global'))) .response(new_response_handler .deserializer(APIHelper.method(:json_deserialize)) .is_api_response(true) .convertor(ApiResponse.method(:create))) .execute end |
#update_payment_link(id:, body:) ⇒ UpdatePaymentLinkResponse Hash
Updates a payment link. You can update the ‘payment_link` fields such as `description`, `checkout_options`, and `pre_populated_data`. You cannot update other fields such as the `order_id`, `version`, `URL`, or `timestamp` field. update. containing the fields to POST for the request. See the corresponding object definition for field details.
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
# File 'lib/square/api/checkout_api.rb', line 143 def update_payment_link(id:, body:) new_api_call_builder .request(new_request_builder(HttpMethodEnum::PUT, '/v2/online-checkout/payment-links/{id}', 'default') .template_param(new_parameter(id, key: 'id') .should_encode(true)) .header_param(new_parameter('application/json', key: 'Content-Type')) .body_param(new_parameter(body)) .header_param(new_parameter('application/json', key: 'accept')) .body_serializer(proc do |param| param.to_json unless param.nil? end) .auth(Single.new('global'))) .response(new_response_handler .deserializer(APIHelper.method(:json_deserialize)) .is_api_response(true) .convertor(ApiResponse.method(:create))) .execute end |