Skip to content
Snippets Groups Projects
Commit fe1ba0fc authored by bird's avatar bird
Browse files

chore: Remove obsolete squareconnect SDK

parent f7d95ec3
1 merge request!12Integrate new Square Payments API
......@@ -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
......@@ -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
......@@ -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>
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment