square.rb 7.0.0.20201118 → 9.1.1.20210317
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/README.md +10 -3
- data/lib/square.rb +0 -2
- data/lib/square/api/apple_pay_api.rb +8 -7
- data/lib/square/api/base_api.rb +1 -1
- data/lib/square/api/bookings_api.rb +42 -0
- data/lib/square/api/catalog_api.rb +21 -7
- data/lib/square/api/checkout_api.rb +2 -2
- data/lib/square/api/disputes_api.rb +33 -35
- data/lib/square/api/invoices_api.rb +13 -10
- data/lib/square/api/payments_api.rb +57 -18
- data/lib/square/api/refunds_api.rb +6 -1
- data/lib/square/api/terminal_api.rb +15 -14
- data/lib/square/api/v1_employees_api.rb +0 -394
- data/lib/square/api/v1_transactions_api.rb +2 -83
- data/lib/square/api_helper.rb +5 -5
- data/lib/square/client.rb +4 -14
- data/lib/square/configuration.rb +20 -5
- metadata +2 -4
- data/lib/square/api/v1_items_api.rb +0 -1766
- data/lib/square/api/v1_locations_api.rb +0 -69
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5daa9230376e0d7e260342e846b5118b92e12aa89fe226ad0df404c5aed13dfa
|
4
|
+
data.tar.gz: c0ba7b58ac6d2ae2d511344c66bdc4b670aef159e4a20045bfd8d8b160e00649
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f78aa71da656d92d0aee4afa1af82d7c783bdf37bead5ec7a8f007ea84131e6457c3d413d4cec15cee4b2f15de7a7afd399c32d8c8a331b82ec5902a610c823d
|
7
|
+
data.tar.gz: e9d14b674b48660e2b499e07e730fe818447aedad773fe063d2a40b28286a7f4296d93efd0a9e310dae4c56032c7f377809555c993979207e28e544466fd5503
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -78,7 +78,6 @@ gem 'square.rb'
|
|
78
78
|
* [O Auth]
|
79
79
|
|
80
80
|
### Deprecated APIs
|
81
|
-
* [V1 Locations]
|
82
81
|
* [V1 Employees]
|
83
82
|
* [V1 Transactions]
|
84
83
|
* [V1 Items]
|
@@ -197,6 +196,15 @@ client = Square::Client.new(
|
|
197
196
|
environment: 'production'
|
198
197
|
)
|
199
198
|
```
|
199
|
+
|
200
|
+
- To set a custom environment provide a `custom_url`, and set environment to `custom`:
|
201
|
+
|
202
|
+
```ruby
|
203
|
+
client = Square::Client.new(
|
204
|
+
access_token:'ACCESS TOKEN HERE',
|
205
|
+
environment: 'custom',
|
206
|
+
custom_url: 'https://your.customdomain.com'
|
207
|
+
)
|
200
208
|
|
201
209
|
### Get an Instance of an API object and call its methods
|
202
210
|
|
@@ -296,7 +304,7 @@ You can also use the Square API to create applications or services that work wit
|
|
296
304
|
[Cash Drawers]: doc/api/cash-drawers.md
|
297
305
|
[Customer Groups]: doc/api/customer-groups.md
|
298
306
|
[Customer Segments]: doc/api/customer-segments.md
|
299
|
-
[Bank Accounts]: doc/api/bank-accounts
|
307
|
+
[Bank Accounts]: doc/api/bank-accounts.md
|
300
308
|
[Payments]: doc/api/payments.md
|
301
309
|
[Checkout]: doc/api/checkout.md
|
302
310
|
[Catalog]: doc/api/catalog.md
|
@@ -315,7 +323,6 @@ You can also use the Square API to create applications or services that work wit
|
|
315
323
|
[Subscriptions]: doc/api/subscriptions.md
|
316
324
|
[Mobile Authorization]: doc/api/mobile-authorization.md
|
317
325
|
[O Auth]: doc/api/o-auth.md
|
318
|
-
[V1 Locations]: doc/api/v1-locations.md
|
319
326
|
[V1 Employees]: doc/api/v1-employees.md
|
320
327
|
[V1 Transactions]: doc/api/v1-transactions.md
|
321
328
|
[V1 Items]: doc/api/v1-items.md
|
data/lib/square.rb
CHANGED
@@ -31,10 +31,8 @@ require_relative 'square/configuration.rb'
|
|
31
31
|
require_relative 'square/api/base_api.rb'
|
32
32
|
require_relative 'square/api/mobile_authorization_api.rb'
|
33
33
|
require_relative 'square/api/o_auth_api.rb'
|
34
|
-
require_relative 'square/api/v1_locations_api.rb'
|
35
34
|
require_relative 'square/api/v1_employees_api.rb'
|
36
35
|
require_relative 'square/api/v1_transactions_api.rb'
|
37
|
-
require_relative 'square/api/v1_items_api.rb'
|
38
36
|
require_relative 'square/api/apple_pay_api.rb'
|
39
37
|
require_relative 'square/api/bank_accounts_api.rb'
|
40
38
|
require_relative 'square/api/bookings_api.rb'
|
@@ -5,17 +5,18 @@ module Square
|
|
5
5
|
super(config, http_call_back: http_call_back)
|
6
6
|
end
|
7
7
|
|
8
|
-
# Activates a domain for use with
|
9
|
-
#
|
8
|
+
# Activates a domain for use with Apple Pay on the Web and Square. A
|
9
|
+
# validation
|
10
|
+
# is performed on this domain by Apple to ensure that it is properly set up
|
10
11
|
# as
|
11
12
|
# an Apple Pay enabled domain.
|
12
13
|
# This endpoint provides an easy way for platform developers to bulk
|
13
14
|
# activate
|
14
|
-
#
|
15
|
-
# To learn more about
|
16
|
-
# [
|
17
|
-
#
|
18
|
-
# -
|
15
|
+
# Apple Pay on the Web with Square for merchants using their platform.
|
16
|
+
# To learn more about Web Apple Pay, see
|
17
|
+
# [Add the Apple Pay on the Web
|
18
|
+
# Button](https://developer.squareup.com/docs/payment-form/add-digital-walle
|
19
|
+
# ts/apple-pay).
|
19
20
|
# @param [RegisterDomainRequest] body Required parameter: An object
|
20
21
|
# containing the fields to POST for the request. See the corresponding
|
21
22
|
# object definition for field details.
|
data/lib/square/api/base_api.rb
CHANGED
@@ -262,5 +262,47 @@ module Square
|
|
262
262
|
_response, data: decoded, errors: _errors
|
263
263
|
)
|
264
264
|
end
|
265
|
+
|
266
|
+
# Cancels an existing booking.
|
267
|
+
# @param [String] booking_id Required parameter: The ID of the
|
268
|
+
# [Booking](#type-booking) object representing the to-be-cancelled
|
269
|
+
# booking.
|
270
|
+
# @param [CancelBookingRequest] body Required parameter: An object
|
271
|
+
# containing the fields to POST for the request. See the corresponding
|
272
|
+
# object definition for field details.
|
273
|
+
# @return [CancelBookingResponse Hash] response from the API call
|
274
|
+
def cancel_booking(booking_id:,
|
275
|
+
body:)
|
276
|
+
# Prepare query url.
|
277
|
+
_query_builder = config.get_base_uri
|
278
|
+
_query_builder << '/v2/bookings/{booking_id}/cancel'
|
279
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
280
|
+
_query_builder,
|
281
|
+
'booking_id' => { 'value' => booking_id, 'encode' => true }
|
282
|
+
)
|
283
|
+
_query_url = APIHelper.clean_url _query_builder
|
284
|
+
|
285
|
+
# Prepare headers.
|
286
|
+
_headers = {
|
287
|
+
'accept' => 'application/json',
|
288
|
+
'content-type' => 'application/json; charset=utf-8'
|
289
|
+
}
|
290
|
+
|
291
|
+
# Prepare and execute HttpRequest.
|
292
|
+
_request = config.http_client.post(
|
293
|
+
_query_url,
|
294
|
+
headers: _headers,
|
295
|
+
parameters: body.to_json
|
296
|
+
)
|
297
|
+
OAuth2.apply(config, _request)
|
298
|
+
_response = execute_request(_request)
|
299
|
+
|
300
|
+
# Return appropriate response type.
|
301
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
302
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
303
|
+
ApiResponse.new(
|
304
|
+
_response, data: decoded, errors: _errors
|
305
|
+
)
|
306
|
+
end
|
265
307
|
end
|
266
308
|
end
|
@@ -251,16 +251,23 @@ module Square
|
|
251
251
|
# `ITEM,ITEM_VARIATION,CATEGORY,IMAGE`. The legal values are taken from the
|
252
252
|
# CatalogObjectType enum: `ITEM`, `ITEM_VARIATION`, `CATEGORY`, `DISCOUNT`,
|
253
253
|
# `TAX`, `MODIFIER`, `MODIFIER_LIST`, or `IMAGE`.
|
254
|
+
# @param [Long] catalog_version Optional parameter: The specific version of
|
255
|
+
# the catalog objects to be included in the response. This allows you to
|
256
|
+
# retrieve historical versions of objects. The specified version value is
|
257
|
+
# matched against the [CatalogObject](#type-catalogobject)s' `version`
|
258
|
+
# attribute.
|
254
259
|
# @return [ListCatalogResponse Hash] response from the API call
|
255
260
|
def list_catalog(cursor: nil,
|
256
|
-
types: nil
|
261
|
+
types: nil,
|
262
|
+
catalog_version: nil)
|
257
263
|
# Prepare query url.
|
258
264
|
_query_builder = config.get_base_uri
|
259
265
|
_query_builder << '/v2/catalog/list'
|
260
266
|
_query_builder = APIHelper.append_url_with_query_parameters(
|
261
267
|
_query_builder,
|
262
268
|
'cursor' => cursor,
|
263
|
-
'types' => types
|
269
|
+
'types' => types,
|
270
|
+
'catalog_version' => catalog_version
|
264
271
|
)
|
265
272
|
_query_url = APIHelper.clean_url _query_builder
|
266
273
|
|
@@ -382,9 +389,15 @@ module Square
|
|
382
389
|
# response contains a `CatalogItemVariation`, its parent `CatalogItem` will
|
383
390
|
# be returned in the `related_objects` field of the response. Default
|
384
391
|
# value: `false`
|
392
|
+
# @param [Long] catalog_version Optional parameter: Requests objects as of a
|
393
|
+
# specific version of the catalog. This allows you to retrieve historical
|
394
|
+
# versions of objects. The value to retrieve a specific version of an object
|
395
|
+
# can be found in the version field of
|
396
|
+
# [CatalogObject](#type-catalogobject)s.
|
385
397
|
# @return [RetrieveCatalogObjectResponse Hash] response from the API call
|
386
398
|
def retrieve_catalog_object(object_id:,
|
387
|
-
include_related_objects: false
|
399
|
+
include_related_objects: false,
|
400
|
+
catalog_version: nil)
|
388
401
|
# Prepare query url.
|
389
402
|
_query_builder = config.get_base_uri
|
390
403
|
_query_builder << '/v2/catalog/object/{object_id}'
|
@@ -394,7 +407,8 @@ module Square
|
|
394
407
|
)
|
395
408
|
_query_builder = APIHelper.append_url_with_query_parameters(
|
396
409
|
_query_builder,
|
397
|
-
'include_related_objects' => include_related_objects
|
410
|
+
'include_related_objects' => include_related_objects,
|
411
|
+
'catalog_version' => catalog_version
|
398
412
|
)
|
399
413
|
_query_url = APIHelper.clean_url _query_builder
|
400
414
|
|
@@ -419,10 +433,10 @@ module Square
|
|
419
433
|
)
|
420
434
|
end
|
421
435
|
|
422
|
-
# Searches for [CatalogObject](#type-CatalogObject) of any
|
436
|
+
# Searches for [CatalogObject](#type-CatalogObject) of any type by matching
|
423
437
|
# supported search attribute values,
|
424
438
|
# excluding custom attribute values on items or item variations, against one
|
425
|
-
# or more of the specified query expressions
|
439
|
+
# or more of the specified query expressions.
|
426
440
|
# This (`SearchCatalogObjects`) endpoint differs from the
|
427
441
|
# [SearchCatalogItems](#endpoint-Catalog-SearchCatalogItems)
|
428
442
|
# endpoint in the following aspects:
|
@@ -472,7 +486,7 @@ module Square
|
|
472
486
|
# Searches for catalog items or item variations by matching supported search
|
473
487
|
# attribute values, including
|
474
488
|
# custom attribute values, against one or more of the specified query
|
475
|
-
# expressions
|
489
|
+
# expressions.
|
476
490
|
# This (`SearchCatalogItems`) endpoint differs from the
|
477
491
|
# [SearchCatalogObjects](#endpoint-Catalog-SearchCatalogObjects)
|
478
492
|
# endpoint in the following aspects:
|
@@ -5,8 +5,8 @@ module Square
|
|
5
5
|
super(config, http_call_back: http_call_back)
|
6
6
|
end
|
7
7
|
|
8
|
-
# Links a `checkoutId` to a `checkout_page_url` that customers
|
9
|
-
#
|
8
|
+
# Links a `checkoutId` to a `checkout_page_url` that customers are
|
9
|
+
# directed to in order to provide their payment information using a
|
10
10
|
# payment processing workflow hosted on connect.squareup.com.
|
11
11
|
# @param [String] location_id Required parameter: The ID of the business
|
12
12
|
# location to associate the checkout with.
|
@@ -5,20 +5,19 @@ module Square
|
|
5
5
|
super(config, http_call_back: http_call_back)
|
6
6
|
end
|
7
7
|
|
8
|
-
# Returns a list of disputes associated
|
9
|
-
# with a particular account.
|
8
|
+
# Returns a list of disputes associated with a particular account.
|
10
9
|
# @param [String] cursor Optional parameter: A pagination cursor returned by
|
11
|
-
# a previous call to this endpoint. Provide this to retrieve the next
|
12
|
-
# results for the original query. For more information, see
|
13
|
-
# [
|
10
|
+
# a previous call to this endpoint. Provide this cursor to retrieve the next
|
11
|
+
# set of results for the original query. For more information, see
|
12
|
+
# [Pagination](https://developer.squareup.com/docs/basics/api101/pagination)
|
14
13
|
# .
|
15
14
|
# @param [DisputeState] states Optional parameter: The dispute states to
|
16
15
|
# filter the result. If not specified, the endpoint returns all open
|
17
|
-
# disputes (dispute status is not `INQUIRY_CLOSED`, `WON`, or `LOST`).
|
16
|
+
# disputes (the dispute status is not `INQUIRY_CLOSED`, `WON`, or `LOST`).
|
18
17
|
# @param [String] location_id Optional parameter: The ID of the location for
|
19
|
-
# which to return
|
20
|
-
#
|
21
|
-
#
|
18
|
+
# which to return a list of disputes. If not specified, the endpoint returns
|
19
|
+
# all open disputes (the dispute status is not `INQUIRY_CLOSED`, `WON`, or
|
20
|
+
# `LOST`) associated with all locations.
|
22
21
|
# @return [ListDisputesResponse Hash] response from the API call
|
23
22
|
def list_disputes(cursor: nil,
|
24
23
|
states: nil,
|
@@ -55,7 +54,7 @@ module Square
|
|
55
54
|
)
|
56
55
|
end
|
57
56
|
|
58
|
-
# Returns details
|
57
|
+
# Returns details about a specific dispute.
|
59
58
|
# @param [String] dispute_id Required parameter: The ID of the dispute you
|
60
59
|
# want more details about.
|
61
60
|
# @return [RetrieveDisputeResponse Hash] response from the API call
|
@@ -90,14 +89,14 @@ module Square
|
|
90
89
|
)
|
91
90
|
end
|
92
91
|
|
93
|
-
# Accepts loss on a dispute. Square returns
|
94
|
-
#
|
95
|
-
# dispute state to ACCEPTED.
|
96
|
-
# Square debits the disputed amount from the seller’s Square
|
97
|
-
#
|
98
|
-
# sufficient funds, Square debits the associated bank account.
|
99
|
-
# @param [String] dispute_id Required parameter: ID of the dispute you
|
100
|
-
# to accept.
|
92
|
+
# Accepts the loss on a dispute. Square returns the disputed amount to the
|
93
|
+
# cardholder and
|
94
|
+
# updates the dispute state to ACCEPTED.
|
95
|
+
# Square debits the disputed amount from the seller’s Square account. If the
|
96
|
+
# Square account
|
97
|
+
# does not have sufficient funds, Square debits the associated bank account.
|
98
|
+
# @param [String] dispute_id Required parameter: The ID of the dispute you
|
99
|
+
# want to accept.
|
101
100
|
# @return [AcceptDisputeResponse Hash] response from the API call
|
102
101
|
def accept_dispute(dispute_id:)
|
103
102
|
# Prepare query url.
|
@@ -165,8 +164,8 @@ module Square
|
|
165
164
|
end
|
166
165
|
|
167
166
|
# Removes specified evidence from a dispute.
|
168
|
-
# Square does not send the bank any evidence that
|
169
|
-
#
|
167
|
+
# Square does not send the bank any evidence that is removed. Also, you
|
168
|
+
# cannot remove evidence after
|
170
169
|
# submitting it to the bank using
|
171
170
|
# [SubmitEvidence](https://developer.squareup.com/docs/reference/square/disp
|
172
171
|
# utes-api/submit-evidence).
|
@@ -210,8 +209,8 @@ module Square
|
|
210
209
|
|
211
210
|
# Returns the specific evidence metadata associated with a specific dispute.
|
212
211
|
# You must maintain a copy of the evidence you upload if you want to
|
213
|
-
# reference it later. You cannot
|
214
|
-
# after you upload it.
|
212
|
+
# reference it later. You cannot
|
213
|
+
# download the evidence after you upload it.
|
215
214
|
# @param [String] dispute_id Required parameter: The ID of the dispute that
|
216
215
|
# you want to retrieve evidence from.
|
217
216
|
# @param [String] evidence_id Required parameter: The ID of the evidence to
|
@@ -251,13 +250,13 @@ module Square
|
|
251
250
|
end
|
252
251
|
|
253
252
|
# Uploads a file to use as evidence in a dispute challenge. The endpoint
|
254
|
-
# accepts
|
255
|
-
#
|
256
|
-
#
|
257
|
-
# @param [String] dispute_id Required parameter: ID of the dispute you
|
258
|
-
# to upload evidence for.
|
253
|
+
# accepts HTTP
|
254
|
+
# multipart/form-data file uploads in HEIC, HEIF, JPEG, PDF, PNG, and TIFF
|
255
|
+
# formats.
|
256
|
+
# @param [String] dispute_id Required parameter: The ID of the dispute you
|
257
|
+
# want to upload evidence for.
|
259
258
|
# @param [CreateDisputeEvidenceFileRequest] request Optional parameter:
|
260
|
-
# Defines parameters for a CreateDisputeEvidenceFile request.
|
259
|
+
# Defines the parameters for a `CreateDisputeEvidenceFile` request.
|
261
260
|
# @param [File | UploadIO] image_file Optional parameter: Example:
|
262
261
|
# @return [CreateDisputeEvidenceFileResponse Hash] response from the API call
|
263
262
|
def create_dispute_evidence_file(dispute_id:,
|
@@ -358,16 +357,15 @@ module Square
|
|
358
357
|
|
359
358
|
# Submits evidence to the cardholder's bank.
|
360
359
|
# Before submitting evidence, Square compiles all available evidence. This
|
361
|
-
# includes
|
362
|
-
#
|
360
|
+
# includes evidence uploaded
|
361
|
+
# using the
|
363
362
|
# [CreateDisputeEvidenceFile](https://developer.squareup.com/docs/reference/
|
364
363
|
# square/disputes-api/create-dispute-evidence-file) and
|
365
364
|
# [CreateDisputeEvidenceText](https://developer.squareup.com/docs/reference/
|
366
|
-
# square/disputes-api/create-dispute-evidence-text) endpoints
|
367
|
-
#
|
368
|
-
#
|
369
|
-
#
|
370
|
-
# want to submit evidence for.
|
365
|
+
# square/disputes-api/create-dispute-evidence-text) endpoints and
|
366
|
+
# evidence automatically provided by Square, when available.
|
367
|
+
# @param [String] dispute_id Required parameter: The ID of the dispute that
|
368
|
+
# you want to submit evidence for.
|
371
369
|
# @return [SubmitEvidenceResponse Hash] response from the API call
|
372
370
|
def submit_evidence(dispute_id:)
|
373
371
|
# Prepare query url.
|
@@ -134,8 +134,8 @@ module Square
|
|
134
134
|
|
135
135
|
# Deletes the specified invoice. When an invoice is deleted, the
|
136
136
|
# associated Order status changes to CANCELED. You can only delete a draft
|
137
|
-
# invoice (you cannot delete
|
138
|
-
#
|
137
|
+
# invoice (you cannot delete a published invoice, including one that is
|
138
|
+
# scheduled for processing).
|
139
139
|
# @param [String] invoice_id Required parameter: The ID of the invoice to
|
140
140
|
# delete.
|
141
141
|
# @param [Integer] version Optional parameter: The version of the
|
@@ -214,12 +214,15 @@ module Square
|
|
214
214
|
)
|
215
215
|
end
|
216
216
|
|
217
|
-
# Updates an invoice by modifying
|
218
|
-
#
|
219
|
-
#
|
220
|
-
#
|
221
|
-
# However,
|
222
|
-
#
|
217
|
+
# Updates an invoice by modifying fields, clearing fields, or both. For most
|
218
|
+
# updates, you can use a sparse
|
219
|
+
# `Invoice` object to add fields or change values, and use the
|
220
|
+
# `fields_to_clear` field to specify fields to clear.
|
221
|
+
# However, some restrictions apply. For example, you cannot change the
|
222
|
+
# `order_id` or `location_id` field, and you
|
223
|
+
# must provide the complete `custom_fields` list to update a custom field.
|
224
|
+
# Published invoices have additional restrictions.
|
225
|
+
# @param [String] invoice_id Required parameter: The ID of the invoice to
|
223
226
|
# update.
|
224
227
|
# @param [UpdateInvoiceRequest] body Required parameter: An object
|
225
228
|
# containing the fields to POST for the request. See the corresponding
|
@@ -261,8 +264,8 @@ module Square
|
|
261
264
|
|
262
265
|
# Cancels an invoice. The seller cannot collect payments for
|
263
266
|
# the canceled invoice.
|
264
|
-
# You cannot cancel an invoice in a terminal state:
|
265
|
-
# `CANCELED`, or `FAILED`.
|
267
|
+
# You cannot cancel an invoice in the `DRAFT` state or in a terminal state:
|
268
|
+
# `PAID`, `REFUNDED`, `CANCELED`, or `FAILED`.
|
266
269
|
# @param [String] invoice_id Required parameter: The ID of the
|
267
270
|
# [invoice](#type-invoice) to cancel.
|
268
271
|
# @param [CancelInvoiceRequest] body Required parameter: An object
|
@@ -83,16 +83,14 @@ module Square
|
|
83
83
|
)
|
84
84
|
end
|
85
85
|
|
86
|
-
#
|
87
|
-
#
|
88
|
-
#
|
89
|
-
#
|
90
|
-
#
|
91
|
-
#
|
92
|
-
#
|
93
|
-
#
|
94
|
-
# The `PAYMENTS_WRITE_ADDITIONAL_RECIPIENTS` OAuth permission is required
|
95
|
-
# to enable application fees.
|
86
|
+
# Creates a payment using the provided source. You can use this endpoint
|
87
|
+
# to charge a card (credit/debit card or
|
88
|
+
# Square gift card) or record a payment that the seller received outside of
|
89
|
+
# Square
|
90
|
+
# (cash payment from a buyer or a payment that an external entity
|
91
|
+
# procesed on behalf of the seller).
|
92
|
+
# The endpoint creates a
|
93
|
+
# `Payment` object and returns it in the response.
|
96
94
|
# @param [CreatePaymentRequest] body Required parameter: An object
|
97
95
|
# containing the fields to POST for the request. See the corresponding
|
98
96
|
# object definition for field details.
|
@@ -209,11 +207,53 @@ module Square
|
|
209
207
|
)
|
210
208
|
end
|
211
209
|
|
212
|
-
#
|
213
|
-
#
|
214
|
-
#
|
215
|
-
#
|
216
|
-
#
|
210
|
+
# Updates a payment with the APPROVED status.
|
211
|
+
# You can update the `amount_money` and `tip_money` using this endpoint.
|
212
|
+
# @param [String] payment_id Required parameter: The ID of the payment to
|
213
|
+
# update.
|
214
|
+
# @param [UpdatePaymentRequest] body Required parameter: An object
|
215
|
+
# containing the fields to POST for the request. See the corresponding
|
216
|
+
# object definition for field details.
|
217
|
+
# @return [UpdatePaymentResponse Hash] response from the API call
|
218
|
+
def update_payment(payment_id:,
|
219
|
+
body:)
|
220
|
+
# Prepare query url.
|
221
|
+
_query_builder = config.get_base_uri
|
222
|
+
_query_builder << '/v2/payments/{payment_id}'
|
223
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
224
|
+
_query_builder,
|
225
|
+
'payment_id' => { 'value' => payment_id, 'encode' => true }
|
226
|
+
)
|
227
|
+
_query_url = APIHelper.clean_url _query_builder
|
228
|
+
|
229
|
+
# Prepare headers.
|
230
|
+
_headers = {
|
231
|
+
'accept' => 'application/json',
|
232
|
+
'content-type' => 'application/json; charset=utf-8'
|
233
|
+
}
|
234
|
+
|
235
|
+
# Prepare and execute HttpRequest.
|
236
|
+
_request = config.http_client.put(
|
237
|
+
_query_url,
|
238
|
+
headers: _headers,
|
239
|
+
parameters: body.to_json
|
240
|
+
)
|
241
|
+
OAuth2.apply(config, _request)
|
242
|
+
_response = execute_request(_request)
|
243
|
+
|
244
|
+
# Return appropriate response type.
|
245
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
246
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
247
|
+
ApiResponse.new(
|
248
|
+
_response, data: decoded, errors: _errors
|
249
|
+
)
|
250
|
+
end
|
251
|
+
|
252
|
+
# Cancels (voids) a payment. You can use this endpoint to cancel a payment
|
253
|
+
# with
|
254
|
+
# the APPROVED `status`.
|
255
|
+
# @param [String] payment_id Required parameter: The ID of the payment to
|
256
|
+
# cancel.
|
217
257
|
# @return [CancelPaymentResponse Hash] response from the API call
|
218
258
|
def cancel_payment(payment_id:)
|
219
259
|
# Prepare query url.
|
@@ -249,9 +289,8 @@ module Square
|
|
249
289
|
# Completes (captures) a payment.
|
250
290
|
# By default, payments are set to complete immediately after they are
|
251
291
|
# created.
|
252
|
-
#
|
253
|
-
#
|
254
|
-
# the payment using this endpoint.
|
292
|
+
# You can use this endpoint to complete a payment with the APPROVED
|
293
|
+
# `status`.
|
255
294
|
# @param [String] payment_id Required parameter: The unique ID identifying
|
256
295
|
# the payment to be completed.
|
257
296
|
# @return [CompletePaymentResponse Hash] response from the API call
|