From 07d6164f53899c07e2f2e1d80629294283d2f1a0 Mon Sep 17 00:00:00 2001
From: Chad Whitacre
Date: Sun, 10 Sep 2017 17:04:23 -0700
Subject: [PATCH] Receipt -> Invoice
---
emails/paid-for-open-source.spt | 13 +-
gratipay/homepage.py | 6 +-
gratipay/models/payment_for_open_source.py | 4 +-
js/gratipay/homepage.js | 2 +-
tests/py/test_www_homepage.py | 12 +-
tests/ttw/test_homepage.py | 3 +
www/browse/payments/%uuid.html.spt | 120 ------------
www/browse/payments/%uuid/invoice.spt | 214 +++++++++++++++++++++
www/index.spt | 4 +-
9 files changed, 237 insertions(+), 141 deletions(-)
delete mode 100644 www/browse/payments/%uuid.html.spt
create mode 100644 www/browse/payments/%uuid/invoice.spt
diff --git a/emails/paid-for-open-source.spt b/emails/paid-for-open-source.spt
index 1ab6b73a48..5316449431 100644
--- a/emails/paid-for-open-source.spt
+++ b/emails/paid-for-open-source.spt
@@ -1,19 +1,18 @@
-{{ _("Payment for open source") }}
+{{ _("Invoice from Gratipay") }}
[---] text/html
-{{ _( "Congratulations! You now have a moral license to use community-built open source software, because you paid {amount} to the open source community through Gratipay. Thank you for your purchase!"
+{{ _( "Thank you for your payment of {amount} for open source!"
, amount=format_currency(amount, 'USD')
) }}
-{{ _("View Receipt") }}
+{{ _("View Invoice") }}
[---] text/plain
-{{ _( "Congratulations! You now have a moral license to use community-built open source software, because you paid {amount} to the open source community through Gratipay. Thank you for your purchase!"
+{{ _( "Thank you for your payment of {amount} for open source!"
, amount=format_currency(amount, 'USD')
) }}
-{{ _("Follow this link to view your receipt:") }}
+{{ _("Follow this link to view your invoice:") }}
-{{ receipt_url }}
+{{ invoice_url }}
diff --git a/gratipay/homepage.py b/gratipay/homepage.py
index 76cdc924c4..2241b3c57a 100644
--- a/gratipay/homepage.py
+++ b/gratipay/homepage.py
@@ -98,19 +98,19 @@ def _send(app, pfos):
, template='paid-for-open-source'
, email=pfos.email_address
, amount=pfos.amount
- , receipt_url=pfos.receipt_url
+ , invoice_url=pfos.invoice_url
)
def pay_for_open_source(app, raw):
parsed, errors = _parse(raw)
- out = {'errors': errors, 'receipt_url': None}
+ out = {'errors': errors, 'invoice_url': None}
if not errors:
payment_method_nonce = parsed.pop('payment_method_nonce')
pfos = _store(parsed)
_charge(app, pfos, payment_method_nonce)
if pfos.succeeded:
- out['receipt_url'] = pfos.receipt_url
+ out['invoice_url'] = pfos.invoice_url
if pfos.email_address:
_send(app, pfos)
else:
diff --git a/gratipay/models/payment_for_open_source.py b/gratipay/models/payment_for_open_source.py
index bd95cc60f5..1c34baf981 100644
--- a/gratipay/models/payment_for_open_source.py
+++ b/gratipay/models/payment_for_open_source.py
@@ -20,10 +20,10 @@ def succeeded(self):
@property
- def receipt_url(self):
+ def invoice_url(self):
if not self.succeeded:
return None
- return '{}/browse/payments/{}/receipt.html'.format(gratipay.base_url, self.uuid)
+ return '{}/browse/payments/{}/invoice.html'.format(gratipay.base_url, self.uuid)
@classmethod
diff --git a/js/gratipay/homepage.js b/js/gratipay/homepage.js
index d17da1f74f..43bb677eeb 100644
--- a/js/gratipay/homepage.js
+++ b/js/gratipay/homepage.js
@@ -67,7 +67,7 @@ Gratipay.homepage.submitFormWithNonce = function(nonce) {
$('.'+fieldName, self.$form).addClass('error');
}
} else {
- $('.payment-complete a.receipt').attr('href', data.receipt_url);
+ $('.payment-complete a.invoice').attr('href', data.invoice_url);
$('form').slideUp(500, function() {
$('.payment-complete').fadeIn(500);
});
diff --git a/tests/py/test_www_homepage.py b/tests/py/test_www_homepage.py
index c8be928d99..67c19d16d3 100644
--- a/tests/py/test_www_homepage.py
+++ b/tests/py/test_www_homepage.py
@@ -126,14 +126,14 @@ def test_stores_info(self):
class Send(QueuedEmailHarness):
- def test_sends_receipt_link(self):
+ def test_sends_invoice_link(self):
parsed, errors = _parse(GOOD)
parsed.pop('payment_method_nonce')
payment_for_open_source = _store(parsed)
_send(self.app, payment_for_open_source)
msg = self.get_last_email()
assert msg['to'] == 'alice@example.com'
- assert msg['subject'] == 'Payment for open source'
+ assert msg['subject'] == 'Invoice from Gratipay'
class PayForOpenSource(PayForOpenSourceHarness):
@@ -155,13 +155,13 @@ def test_pays_for_open_source(self):
assert self.fetch() is None
result = pay_for_open_source(self.app, self.good)
assert not result['errors']
- assert result['receipt_url'].endswith('receipt.html')
+ assert result['invoice_url'].endswith('invoice.html')
assert self.fetch().succeeded
def test_flags_errors_and_doesnt_store(self):
assert self.fetch() is None
result = pay_for_open_source(self.app, self.bad)
- assert result == {'errors': ALL, 'receipt_url': None}
+ assert result == {'errors': ALL, 'invoice_url': None}
assert self.fetch() is None
def test_flags_errors_with_no_transaction_id(self):
@@ -189,7 +189,7 @@ def test_post_gets_json(self):
assert response.headers['Content-Type'] == 'application/json'
result = json.loads(response.body)
assert not result['errors']
- assert result['receipt_url'].endswith('receipt.html')
+ assert result['invoice_url'].endswith('invoice.html')
assert self.fetch().succeeded
def test_bad_post_gets_400(self):
@@ -213,5 +213,5 @@ def test_partial_post_is_fine(self):
assert response.headers['Content-Type'] == 'application/json'
result = json.loads(response.body)
assert not result['errors']
- assert result['receipt_url'].endswith('receipt.html')
+ assert result['invoice_url'].endswith('invoice.html')
assert self.fetch().succeeded
diff --git a/tests/ttw/test_homepage.py b/tests/ttw/test_homepage.py
index 2add5e6269..e70edcc1c7 100644
--- a/tests/ttw/test_homepage.py
+++ b/tests/ttw/test_homepage.py
@@ -58,6 +58,9 @@ def test_anon_can_post(self):
'alice@example.com', 'Wonderland', 'http://www.example.com/',
'thebestbutter', 'Love me! Love me! Say that you love me!')
assert self.submit_succeeds()
+ self.wait_for('a.invoice').click()
+ self.wait_for('#txnid')
+ assert self.css('#items tbody tr').text == 'open source software $ 537.00'
def test_options_are_optional(self):
self.fill_form('537', '4242424242424242', '1020', '123')
diff --git a/www/browse/payments/%uuid.html.spt b/www/browse/payments/%uuid.html.spt
deleted file mode 100644
index 32b1defd0d..0000000000
--- a/www/browse/payments/%uuid.html.spt
+++ /dev/null
@@ -1,120 +0,0 @@
-from aspen import Response
-from gratipay.models.payment_for_open_source import PaymentForOpenSource
-
-[-------------------]
-
-try:
- uuid = request.path['uuid']
-except ValueError:
- raise Response(400)
-
-# pfos - payment_for_open_source
-pfos = PaymentForOpenSource.from_uuid(uuid)
-
-if pfos is None:
- raise Response(404)
-
-
-[-------------------]
-
-
-
-
- Gratipay, LLC
- 716 Park Road
- Ambridge, PA 15003
-
-
-
Receipt
-
-
- {{ pfos.name }}
-
-
-
-
-
-
-
-
- Amount: |
- $ |
- {{ pfos.amount }} |
-
-
- Tax: |
- $ |
- |
-
-
- Total: |
- $ |
- {{ pfos.amount }} |
-
-
-
-
-
- {{ pfos.ctime.strftime("%B %d, %Y").replace(' 0', ' ') }} |
- — |
- Transaction ID: {{ pfos.transaction_id }} |
-
-
-
-
diff --git a/www/browse/payments/%uuid/invoice.spt b/www/browse/payments/%uuid/invoice.spt
new file mode 100644
index 0000000000..975000c60d
--- /dev/null
+++ b/www/browse/payments/%uuid/invoice.spt
@@ -0,0 +1,214 @@
+from aspen import Response
+from gratipay.models.payment_for_open_source import PaymentForOpenSource
+
+[-------------------]
+
+try:
+ uuid = request.path['uuid']
+except ValueError:
+ raise Response(400)
+
+# pfos - payment_for_open_source
+pfos = PaymentForOpenSource.from_uuid(uuid)
+
+if pfos is None:
+ raise Response(404)
+
+
+[-------------------] text/html
+
+
+
+ Gratipay Invoice {{ pfos.uuid }}
+
+
+
+
+
Invoice
+
+
+
+
+ ID: {{ pfos.uuid }} |
+
+ Date: {{ pfos.ctime.strftime("%B %d, %Y").replace(' 0', ' ') }} |
+
+
+
+
+
From:
+
+ Gratipay, LLC
+ 716 Park Road
+ Ambridge, PA 15003
+ USA
+
+
+
To:
+
+ {{ pfos.name }}
+ {{ pfos.promotion_name }}
+ {{ pfos.email_address }}
+
+
+
+
+
+
Items
+
+
+
+ open source software |
+ $ |
+ {{ pfos.amount }}.00 |
+
+
+
+
+ Subtotal: |
+ $ |
+ {{ pfos.amount }}.00 |
+
+
+ Tax: |
+ $ |
+ 0.00 |
+
+
+ Total: |
+ $ |
+ {{ pfos.amount }}.00 |
+
+
+ Amount Paid: |
+ $ |
+ {{ pfos.amount }}.00 |
+
+
+ Amount Due: |
+ $ |
+ 0.00 |
+
+
+
+
+
+
Notes
+
+
Please contact support@gratipay.com with any questions. Thank
+ you for your business!
+
+
+
+
diff --git a/www/index.spt b/www/index.spt
index 125976f9f6..5e4dc8761c 100644
--- a/www/index.spt
+++ b/www/index.spt
@@ -56,7 +56,7 @@ $(document).ready(function() {
{{ _("Thank you for paying for open source!") }}
{{ _( "Email {support} with{br}any questions or feedback."
@@ -138,7 +138,7 @@ $(document).ready(function() {
{{ _("Please enter a valid email address shorter than 255 characters.") }}
- {{ _('You will get a link to a receipt for your payment.') }}
+ {{ _('You will get a link to an invoice for your payment.') }}