Skip to content

Commit

Permalink
New ability to edit billing details including address, zip, and the e…
Browse files Browse the repository at this point in the history
…mail for receipts. Closes #195
  • Loading branch information
jsayles committed Jun 21, 2017
1 parent 01b2b0d commit 386cc50
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 4 deletions.
7 changes: 7 additions & 0 deletions nadine/utils/payment_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ def get_transaction(self, transaction_id, clean=True):
return clean_transaction(transaction)
return transaction

def update_billing_details(self, customer_id, address, zipcode, email):
customer_object = self.entry_point.getCustomer(customer_id)
customer_object.BillingAddress.Street = address
customer_object.BillingAddress.Zip = zipcode
customer_object.BillingAddress.Email = email
return self.entry_point.updateCustomer(customer_object)

def update_recurring(self, customer_id, enabled, next_date, description, comment, amount):
customer_object = self.entry_point.getCustomer(customer_id)
customer_object.Enabled = enabled
Expand Down
32 changes: 29 additions & 3 deletions staff/templates/staff/billing/usaepay.html
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,41 @@ <h5 style="display:inline;">Actions:</h5>
<div id="billing_detail_{{ customer.CustNum }}">
<h5>Billing Detail ({{ customer.CustNum }})</h5>
<div style="padding: 12px;">
<strong>Address: </strong>{{ customer.BillingAddress.Street }}
<strong>Zip: </strong>{{ customer.BillingAddress.Zip }}
<strong>Email: </strong>{{ customer.BillingAddress.Email }}
<form action="." method="POST">
<input type="hidden" name="customer_id" value="">
<input type="hidden" name="action" value="edit_billing_details">
<table>
<tr>
<th>Billing Address</th>
<th>Zipcode</th>
<th>Email for Receipts</th>
<th></th>
</tr>
<tr>
<td>
<input name="address" size="60" value="{{ customer.BillingAddress.Street }}"/>
</td>
<td>
<input name="zipcode" size="10" value="{{ customer.BillingAddress.Zip }}"/>
</td>
<td>
<input name="email" size="60" value="{{ customer.BillingAddress.Email }}"/>
</td>
<td>
<input type="submit" value="Edit">
</td>
</tr>
</table>
{% csrf_token %}
</form>
</div>

<h5>Billing History</h5>
<table>
<tr>
<th>Date</th>
<th>Description</th>

<th>Status</th>
<th>Type</th>
<th style="text-align:right;">Amount</th>
Expand Down
8 changes: 7 additions & 1 deletion staff/views/payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ def usaepay_user(request, username):
enabled = request.POST.get("enabled", "") == "on"
api.update_recurring(customer_id, enabled, next_date, description,comment, amount)
messages.add_message(request, messages.INFO, "Recurring billing updated for %s" % username)
elif action == "edit_billing_details":
address = request.POST.get("address")
zipcode = request.POST.get("zipcode")
email = request.POST.get("email")
api.update_billing_details(customer_id, address, zipcode, email)
messages.add_message(request, messages.INFO, "Billing detail updated for %s" % username)
elif action == "email_receipt":
transaction_id = request.POST.get("transaction_id")
api.email_receipt(transaction_id, user.email)
Expand Down Expand Up @@ -133,7 +139,7 @@ def usaepay_transactions(request, year, month, day):
except Exception:
# Xero not integrated
pass

try:
api = PaymentAPI()

Expand Down

0 comments on commit 386cc50

Please sign in to comment.