From ea4fa621654e5fba19e6cc554af798bff025569a Mon Sep 17 00:00:00 2001 From: autobot Date: Wed, 17 Jul 2024 13:37:58 +0000 Subject: [PATCH] Generated PR for Release: 37.1.1.20240717 --- doc/api/apple-pay.md | 7 +++++-- doc/api/invoices.md | 20 +++++++++++--------- doc/client.md | 9 +++++---- doc/models/update-invoice-request.md | 13 ++++++++----- pyproject.toml | 4 ++-- requirements.txt | 6 +++--- square/api/apple_pay_api.py | 18 +++++++++++------- square/api/base_api.py | 2 +- square/api/invoices_api.py | 15 +++++++-------- square/client.py | 6 +++--- square/configuration.py | 2 +- square/http/auth/o_auth_2.py | 4 ++-- tests/utilities/test_webhooks_helper.py | 13 +++++++++++++ 13 files changed, 72 insertions(+), 47 deletions(-) diff --git a/doc/api/apple-pay.md b/doc/api/apple-pay.md index c1c719a4..7f4074e6 100644 --- a/doc/api/apple-pay.md +++ b/doc/api/apple-pay.md @@ -18,8 +18,11 @@ 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](https://developer.squareup.com/docs/web-payments/migrate). +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 https://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](https://developer.squareup.com/docs/web-payments/apple-pay). diff --git a/doc/api/invoices.md b/doc/api/invoices.md index 28f65d62..e2967182 100644 --- a/doc/api/invoices.md +++ b/doc/api/invoices.md @@ -278,10 +278,10 @@ elif result.is_error(): # Update Invoice -Updates an invoice by modifying fields, clearing fields, or both. For most updates, you can use a sparse -`Invoice` object to add fields or change values and use the `fields_to_clear` field to specify fields to clear. -However, some restrictions apply. For example, you cannot change the `order_id` or `location_id` field and you -must provide the complete `custom_fields` list to update a custom field. Published invoices have additional restrictions. +Updates an invoice. This endpoint supports sparse updates, so you only need +to specify the fields you want to change along with the required `version` field. +Some restrictions apply to updating invoices. For example, you cannot change the +`order_id` or `location_id` field. ```python def update_invoice(self, @@ -311,14 +311,16 @@ body = { 'payment_requests': [ { 'uid': '2da7964f-f3d2-4f43-81e8-5aa220bf3355', - 'tipping_enabled': False + 'tipping_enabled': False, + 'reminders': [ + {}, + {}, + {} + ] } ] }, - 'idempotency_key': '4ee82288-0910-499e-ab4c-5d0071dad1be', - 'fields_to_clear': [ - 'payments_requests[2da7964f-f3d2-4f43-81e8-5aa220bf3355].reminders' - ] + 'idempotency_key': '4ee82288-0910-499e-ab4c-5d0071dad1be' } result = invoices_api.update_invoice( diff --git a/doc/client.md b/doc/client.md index a305f4f3..59d2c822 100644 --- a/doc/client.md +++ b/doc/client.md @@ -5,7 +5,7 @@ The following parameters are configurable for the API Client: | Parameter | Type | Description | | --- | --- | --- | -| `square_version` | `str` | Square Connect API versions
*Default*: `'2024-06-04'` | +| `square_version` | `str` | Square Connect API versions
*Default*: `'2024-07-17'` | | `custom_url` | `str` | Sets the base URL requests are made to. Defaults to `https://connect.squareup.com`
*Default*: `'https://connect.squareup.com'` | | `environment` | `string` | The API environment.
**Default: `production`** | | `http_client_instance` | `HttpClient` | The Http Client passed from the sdk user for making requests | @@ -24,10 +24,11 @@ The API client can be initialized as follows: ```python client = Client( - square_version='2024-06-04', + square_version='2024-07-17', bearer_auth_credentials=BearerAuthCredentials( access_token='AccessToken' - ) + ), + custom_url='https://connect.squareup.com' ) ``` @@ -51,7 +52,7 @@ from square.http.auth.o_auth_2 import BearerAuthCredentials from square.client import Client client = Client( - square_version='2024-06-04', + square_version='2024-07-17', bearer_auth_credentials=BearerAuthCredentials( access_token='AccessToken' ) diff --git a/doc/models/update-invoice-request.md b/doc/models/update-invoice-request.md index 765df694..fcf47733 100644 --- a/doc/models/update-invoice-request.md +++ b/doc/models/update-invoice-request.md @@ -13,19 +13,17 @@ Describes a `UpdateInvoice` request. | --- | --- | --- | --- | | `invoice` | [`Invoice`](../../doc/models/invoice.md) | Required | Stores information about an invoice. You use the Invoices API to create and manage
invoices. For more information, see [Invoices API Overview](https://developer.squareup.com/docs/invoices-api/overview). | | `idempotency_key` | `str` | Optional | A unique string that identifies the `UpdateInvoice` request. If you do not
provide `idempotency_key` (or provide an empty string as the value), the endpoint
treats each request as independent.

For more information, see [Idempotency](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency).
**Constraints**: *Maximum Length*: `128` | -| `fields_to_clear` | `List[str]` | Optional | The list of fields to clear.
For examples, see [Update an Invoice](https://developer.squareup.com/docs/invoices-api/update-invoices). | +| `fields_to_clear` | `List[str]` | Optional | The list of fields to clear. Although this field is currently supported, we
recommend using null values or the `remove` field when possible. For examples, see
[Update an Invoice](https://developer.squareup.com/docs/invoices-api/update-invoices). | ## Example (as JSON) ```json { - "fields_to_clear": [ - "payments_requests[2da7964f-f3d2-4f43-81e8-5aa220bf3355].reminders" - ], "idempotency_key": "4ee82288-0910-499e-ab4c-5d0071dad1be", "invoice": { "payment_requests": [ { + "reminders": null, "tipping_enabled": false, "uid": "2da7964f-f3d2-4f43-81e8-5aa220bf3355" } @@ -47,7 +45,12 @@ Describes a `UpdateInvoice` request. "sublocality": "sublocality6" } } - } + }, + "fields_to_clear": [ + "fields_to_clear1", + "fields_to_clear2", + "fields_to_clear3" + ] } ``` diff --git a/pyproject.toml b/pyproject.toml index 35bc7ebd..67e24c3e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,11 +4,11 @@ requires = ["setuptools>=61.0"] [project] name = "squareup" description = "Use Square APIs to manage and run business including payment, customer, product, inventory, and employee management." -version = "37.1.0.20240604" +version = "37.1.1.20240717" readme = "README.md" requires-python = ">=3.7" authors = [{name = "Square Developer Platform", email = "developers@squareup.com"}] -dependencies = ["apimatic-core~=0.2.0", "apimatic-core-interfaces~=0.1.0", "apimatic-requests-client-adapter~=0.1.0", "deprecation~=2.1"] +dependencies = ["apimatic-core~=0.2.0, >= 0.2.15", "apimatic-core-interfaces~=0.1.0, >= 0.1.5", "apimatic-requests-client-adapter~=0.1.0, >= 0.1.6", "deprecation~=2.1"] [project.optional-dependencies] testutils = ["pytest>=7.2.2"] [tool.setuptools.packages.find] diff --git a/requirements.txt b/requirements.txt index 26c48167..8efeeaca 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -apimatic-core~=0.2.0 -apimatic-core-interfaces~=0.1.0 -apimatic-requests-client-adapter~=0.1.0 +apimatic-core~=0.2.0, >= 0.2.15 +apimatic-core-interfaces~=0.1.0, >= 0.1.5 +apimatic-requests-client-adapter~=0.1.0, >= 0.1.6 deprecation~=2.1 diff --git a/square/api/apple_pay_api.py b/square/api/apple_pay_api.py index c18d1a27..be4d013a 100644 --- a/square/api/apple_pay_api.py +++ b/square/api/apple_pay_api.py @@ -28,13 +28,17 @@ def register_domain(self, 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](https://developer.squareup.com/docs/web-payments/migrate). + 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 + https://app.squareup.com/digital-wallets/apple-pay/apple-developer-merc + hantid-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](https://developer.squareup.com/docs/web-payments/apple-pay). diff --git a/square/api/base_api.py b/square/api/base_api.py index 82493acf..b419b93d 100644 --- a/square/api/base_api.py +++ b/square/api/base_api.py @@ -22,7 +22,7 @@ class BaseApi(object): @staticmethod def user_agent(): - return 'Square-Python-SDK/37.1.0.20240604 ({api-version}) {engine}/{engine-version} ({os-info}) {detail}' + return 'Square-Python-SDK/37.1.1.20240717 ({api-version}) {engine}/{engine-version} ({os-info}) {detail}' @staticmethod def user_agent_parameters(): diff --git a/square/api/invoices_api.py b/square/api/invoices_api.py index 7ed80150..6c64e94c 100644 --- a/square/api/invoices_api.py +++ b/square/api/invoices_api.py @@ -275,14 +275,13 @@ def update_invoice(self, body): """Does a PUT request to /v2/invoices/{invoice_id}. - Updates an invoice by modifying fields, clearing fields, or both. For - most updates, you can use a sparse - `Invoice` object to add fields or change values and use the - `fields_to_clear` field to specify fields to clear. - However, some restrictions apply. For example, you cannot change the - `order_id` or `location_id` field and you - must provide the complete `custom_fields` list to update a custom - field. Published invoices have additional restrictions. + Updates an invoice. This endpoint supports sparse updates, so you only + need + to specify the fields you want to change along with the required + `version` field. + Some restrictions apply to updating invoices. For example, you cannot + change the + `order_id` or `location_id` field. Args: invoice_id (str): The ID of the invoice to update. diff --git a/square/client.py b/square/client.py index 0a5ba5e5..7065f669 100644 --- a/square/client.py +++ b/square/client.py @@ -55,11 +55,11 @@ class Client(object): @staticmethod def sdk_version(): - return '37.1.0.20240604' + return '37.1.1.20240717' @staticmethod def square_version(): - return '2024-06-04' + return '2024-07-17' def user_agent_detail(self): return self.config.user_agent_detail @@ -238,7 +238,7 @@ def __init__(self, http_client_instance=None, retry_statuses=None, retry_methods=None, environment='production', custom_url='https://connect.squareup.com', access_token=None, - bearer_auth_credentials=None, square_version='2024-06-04', + bearer_auth_credentials=None, square_version='2024-07-17', additional_headers={}, user_agent_detail='', config=None): self.config = config or Configuration( http_client_instance=http_client_instance, diff --git a/square/configuration.py b/square/configuration.py index bfc0e8c2..50e1ee23 100644 --- a/square/configuration.py +++ b/square/configuration.py @@ -45,7 +45,7 @@ def __init__(self, http_client_instance=None, retry_statuses=None, retry_methods=None, environment='production', custom_url='https://connect.squareup.com', access_token=None, - bearer_auth_credentials=None, square_version='2024-06-04', + bearer_auth_credentials=None, square_version='2024-07-17', additional_headers={}, user_agent_detail=''): if retry_methods is None: retry_methods = ['GET', 'PUT'] diff --git a/square/http/auth/o_auth_2.py b/square/http/auth/o_auth_2.py index a589815e..ff5cdc76 100644 --- a/square/http/auth/o_auth_2.py +++ b/square/http/auth/o_auth_2.py @@ -14,11 +14,11 @@ def error_message(self): return "BearerAuth: AccessToken is undefined." def __init__(self, bearer_auth_credentials): - auth_params = {} self._access_token = bearer_auth_credentials.access_token \ if bearer_auth_credentials is not None else None + auth_params = {} if self._access_token: - auth_params["Authorization"] = "Bearer {}".format(self._access_token) + auth_params = {"Authorization": "Bearer {}".format(self._access_token)} super().__init__(auth_params=auth_params) diff --git a/tests/utilities/test_webhooks_helper.py b/tests/utilities/test_webhooks_helper.py index a76ff68d..388b003f 100644 --- a/tests/utilities/test_webhooks_helper.py +++ b/tests/utilities/test_webhooks_helper.py @@ -16,6 +16,19 @@ def test_signature_validation_pass(self): self.NOTIFICATION_URL) self.assertTrue(is_valid) + def test_signature_validation_escaped_pass(self): + + escpaedRequestBody = '{"data":{"type":"webhooks","id":">id<"}}' + newSignatureHeader = "Cxt7+aTi4rKgcA0bC4g9EHdVtLSDWdqccmL5MvihU4U=" + signatureKey = "signature-key" + url = "https://webhook.site/webhooks" + + is_valid = is_valid_webhook_event_signature(escpaedRequestBody, + newSignatureHeader, + signatureKey, + url) + self.assertTrue(is_valid) + def test_signature_validation_url_mismatch(self): is_valid = is_valid_webhook_event_signature(self.REQUEST_BODY, self.SIGNATURE_HEADER,