diff --git a/pip-packages.txt b/pip-packages.txt index 05556a40ea3c2457489cba3d7433b217584455d0..445f377d76cfda7f5b2412d1f12c9871595e00c4 100644 --- a/pip-packages.txt +++ b/pip-packages.txt @@ -25,6 +25,5 @@ pytz==2019.1 requests==2.28.2 six==1.12.0 sqlparse==0.3.0 -squareconnect==2.20190410.0 squareup==26.0.0.20230419 urllib3==1.25 diff --git a/src/squarepay/payments.py b/src/squarepay/payments.py index 74c15cfeab1de39a5c9d68e0f6d5cfb63c870493..b41885e6c80bd7bd356fd5c2dd961f0b8b038dcc 100644 --- a/src/squarepay/payments.py +++ b/src/squarepay/payments.py @@ -6,12 +6,6 @@ import logging from django.conf import settings from django.core.exceptions import ImproperlyConfigured -import squareconnect -from squareconnect.rest import ApiException -from squareconnect.apis.transactions_api import TransactionsApi - -log = logging.getLogger('squarepay') - # load the configuration values app_id = getattr(settings, 'SQUARE_APP_ID', None) loc_id = getattr(settings, 'SQUARE_LOCATION', None) @@ -21,13 +15,6 @@ access_key = getattr(settings, 'SQUARE_ACCESS_TOKEN', None) if (app_id is None) or (loc_id is None) or (access_key is None): raise ImproperlyConfigured("Please define SQUARE_APP_ID, SQUARE_LOCATION and SQUARE_ACCESS_TOKEN in settings.py") -# instantiate the global squareconnect ApiClient instance (only needs to be done once) -_sqapi_inst = squareconnect.ApiClient() -_sqapi_inst.configuration.access_token = access_key - -def get_transactions_api(): - return TransactionsApi(_sqapi_inst) - def try_capture_payment(card_payment, nonce): """ attempt to charge the customer associated with the given card nonce (created by the PaymentForm in JS) @@ -35,8 +22,6 @@ def try_capture_payment(card_payment, nonce): be charged multiple times (using the Square idempotency key feature) Returns either True on success or False on failure. """ - api_inst = get_transactions_api() - request_body = { 'idempotency_key': card_payment.idempotency_key, 'card_nonce': nonce, @@ -46,12 +31,3 @@ def try_capture_payment(card_payment, nonce): } } - try: - api_response = api_inst.charge(loc_id, request_body) - card_payment.set_paid() - log.info("TransactionApi response without error, charge $%1.2f" % (float(card_payment.amount) / 100.0)) - return True - except ApiException as e: - log.error("Exception while calling TransactionApi::charge: %s" % e) - return False - diff --git a/src/templates/payment_form.html b/src/templates/payment_form.html index 5962a9698e732da17f6a1039df4b4b3cd5c3c897..90aa360d3d9760fb15accfcad78db44869be6054 100644 --- a/src/templates/payment_form.html +++ b/src/templates/payment_form.html @@ -4,8 +4,6 @@ {% block title %}UCC Payment Gateway{% endblock %} {% block extrahead %} -<!-- link to the SqPaymentForm library --> -<script type="text/javascript" src="https://js.squareup.com/v2/paymentform"></script> {# bring the location IDs into javascript so the next bits know about them #} <script type="text/javascript"> @@ -14,7 +12,6 @@ var locationId = "{{ loc_id }}"; var amount = "{{ payment.amount }}"; </script> -<script type="text/javascript" src="{% static 'squarepay.js' %}"></script> <link rel="stylesheet" type="text/css" href="{% static 'squarepay.css' %}"> {% endblock %} @@ -51,35 +48,6 @@ var amount = "{{ payment.amount }}"; </div> <!-- the element #form-container is used to create the Square payment form (hardcoded) --> <div id="form-container" class="payment-info"> - <div id="sq-ccbox"> - <form id="nonce-form" novalidate action="#" method="post"> - {% csrf_token %} - <div id="error"></div> - - <fieldset> - <div class="form-row"> - <span class="label">Card Number</span> - <div id="sq-card-number"></div> - </div> - - <div class="form-row"> - <div class="half"> - <span class="label">Expiration</span> - <div id="sq-expiration-date"></div> - </div> - - <div class="half"> - <span class="label">CVV</span> - <div id="sq-cvv"></div> - </div> - </div> - </fieldset> - <button id="sq-creditcard" class="button-credit-card" onclick="requestCardNonce(event)" disabled>Pay {{ amount }}</button> - - <!-- after a nonce is generated it will be assigned to this hidden input field --> - <input type="hidden" id="card-nonce" name="nonce"> - </form> - </div> <!-- end #sq-ccbox --> </div> <!-- end #form-container --> </div> </div>