Skip to content

Commit

Permalink
Merge pull request #134 from square/release/37.1.1.20240717
Browse files Browse the repository at this point in the history
Generated PR for Release: 37.1.1.20240717
  • Loading branch information
jessdelacruzsantos authored Jul 17, 2024
2 parents 3933f81 + ea4fa62 commit eef03e3
Show file tree
Hide file tree
Showing 13 changed files with 72 additions and 47 deletions.
7 changes: 5 additions & 2 deletions doc/api/apple-pay.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

Expand Down
20 changes: 11 additions & 9 deletions doc/api/invoices.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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(
Expand Down
9 changes: 5 additions & 4 deletions doc/client.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ The following parameters are configurable for the API Client:

| Parameter | Type | Description |
| --- | --- | --- |
| `square_version` | `str` | Square Connect API versions<br>*Default*: `'2024-06-04'` |
| `square_version` | `str` | Square Connect API versions<br>*Default*: `'2024-07-17'` |
| `custom_url` | `str` | Sets the base URL requests are made to. Defaults to `https://connect.squareup.com`<br>*Default*: `'https://connect.squareup.com'` |
| `environment` | `string` | The API environment. <br> **Default: `production`** |
| `http_client_instance` | `HttpClient` | The Http Client passed from the sdk user for making requests |
Expand All @@ -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'
)
```

Expand All @@ -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'
)
Expand Down
13 changes: 8 additions & 5 deletions doc/models/update-invoice-request.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<br>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<br>provide `idempotency_key` (or provide an empty string as the value), the endpoint<br>treats each request as independent.<br><br>For more information, see [Idempotency](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency).<br>**Constraints**: *Maximum Length*: `128` |
| `fields_to_clear` | `List[str]` | Optional | The list of fields to clear.<br>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<br>recommend using null values or the `remove` field when possible. For examples, see<br>[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"
}
Expand All @@ -47,7 +45,12 @@ Describes a `UpdateInvoice` request.
"sublocality": "sublocality6"
}
}
}
},
"fields_to_clear": [
"fields_to_clear1",
"fields_to_clear2",
"fields_to_clear3"
]
}
```

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -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
18 changes: 11 additions & 7 deletions square/api/apple_pay_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
2 changes: 1 addition & 1 deletion square/api/base_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
15 changes: 7 additions & 8 deletions square/api/invoices_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions square/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion square/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down
4 changes: 2 additions & 2 deletions square/http/auth/o_auth_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down
13 changes: 13 additions & 0 deletions tests/utilities/test_webhooks_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit eef03e3

Please sign in to comment.