This repository has been archived by the owner on Feb 8, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 308
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3301 from gratipay/charge-notifications
notify users of card charges
- Loading branch information
Showing
12 changed files
with
188 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{{ _("Oh no! A problem supporting {0}!", top_tippee) }} | ||
|
||
[---] text/html | ||
{{ _("We tried to charge your credit card {0} today, to fund your ongoing support for {1}, but the charge failed with this message:", | ||
format_currency(exchange.amount + exchange.fee, 'USD'), | ||
('<b><a href="{0}">{1}</a></b>'|safe).format( | ||
participant.profile_url+'giving/', | ||
top_tippee if ntippees == 1 else ngettext('{0} and {n} other', | ||
'{0} and {n} others', | ||
ntippees - 1, | ||
top_tippee))) }} | ||
|
||
<pre>{{ exchange.note }}</pre> | ||
|
||
<a href="{{ participant.profile_url+'routes/credit-card.html' }}" | ||
style="{{ button_style }}">{{ _("Fix Credit Card") }}</a> | ||
|
||
[---] text/plain | ||
{{ _("We tried to charge your credit card {0} today, to fund your ongoing support for {1}, but the charge failed with this message:", | ||
format_currency(exchange.amount + exchange.fee, 'USD'), | ||
top_tippee if ntippees == 1 else ngettext('{0} and {n} other', | ||
'{0} and {n} others', | ||
ntippees - 1, | ||
top_tippee)) }} | ||
|
||
{{ exchange.note }} | ||
|
||
{{ _("Follow this link to fix your credit card:") }} {{ participant.profile_url+'routes/credit-card.html' }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{{ _("Thanks for supporting {0}!", top_tippee) }} | ||
|
||
[---] text/html | ||
{{ _("We charged your credit card {0} today, to fund your ongoing support for {1}. Thanks for using Gratipay!", | ||
format_currency(exchange.amount + exchange.fee, 'USD'), | ||
('<b><a href="{0}">{1}</a></b>'|safe).format( | ||
participant.profile_url+'giving/', | ||
top_tippee if ntippees == 1 else ngettext('{0} and {n} other', | ||
'{0} and {n} others', | ||
ntippees - 1, | ||
top_tippee))) }} | ||
<br> | ||
<br> | ||
<a href="{{ '{}receipts/{}.html'.format(participant.profile_url, exchange.id) }}" | ||
style="{{ button_style }}">{{ _("View Receipt") }}</a> | ||
|
||
[---] text/plain | ||
{{ _("We charged your credit card {0} today, to fund your ongoing support for {1}. Thanks for using Gratipay!", | ||
format_currency(exchange.amount + exchange.fee, 'USD'), | ||
top_tippee if ntippees == 1 else ngettext('{0} and {n} other', | ||
'{0} and {n} others', | ||
ntippees - 1, | ||
top_tippee)) }} | ||
|
||
{{ _("Follow this link to view your receipt:") }} {{ '{}receipts/{}.html'.format(participant.profile_url, exchange.id) }} | ||
|
||
{{ _("Follow this link if you want to view or modify your payments:") }} {{ participant.profile_url+'giving/' }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
BEGIN; | ||
ALTER TABLE participants ADD COLUMN notify_charge int DEFAULT 3; | ||
ALTER TABLE participants | ||
ALTER COLUMN notify_on_opt_in DROP DEFAULT, | ||
ALTER COLUMN notify_on_opt_in TYPE int USING notify_on_opt_in::int, | ||
ALTER COLUMN notify_on_opt_in SET DEFAULT 1; | ||
END; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ | |
from gratipay.models.participant import Participant | ||
from gratipay.testing import Foobar, Harness | ||
from gratipay.testing.balanced import BalancedHarness | ||
from gratipay.testing.emails import EmailHarness | ||
|
||
|
||
class TestPayday(BalancedHarness): | ||
|
@@ -245,13 +246,11 @@ def test_end_raises_NoPayday(self): | |
|
||
@mock.patch('gratipay.billing.payday.log') | ||
@mock.patch('gratipay.billing.payday.Payday.payin') | ||
@mock.patch('gratipay.billing.payday.Payday.end') | ||
def test_payday(self, end, payin, log): | ||
def test_payday(self, payin, log): | ||
greeting = 'Greetings, program! It\'s PAYDAY!!!!' | ||
Payday.start().run() | ||
log.assert_any_call(greeting) | ||
assert payin.call_count == 1 | ||
assert end.call_count == 1 | ||
|
||
|
||
class TestPayin(BalancedHarness): | ||
|
@@ -529,3 +528,24 @@ def test_payout_ach_error(self, ach_credit): | |
Payday.start().payout() | ||
payday = self.fetch_payday() | ||
assert payday['nach_failing'] == 1 | ||
|
||
|
||
class TestNotifyParticipants(EmailHarness): | ||
|
||
def test_it_notifies_participants(self): | ||
kalel = self.make_participant('kalel', claimed_time='now', is_suspicious=False, | ||
email_address='[email protected]', notify_charge=3) | ||
lily = self.make_participant('lily', claimed_time='now', is_suspicious=False) | ||
kalel.set_tip_to(lily, 10) | ||
|
||
for status in ('failed', 'succeeded'): | ||
payday = Payday.start() | ||
self.make_exchange('balanced-cc', 10, 0, kalel, status) | ||
payday.end() | ||
payday.notify_participants() | ||
|
||
emails = self.db.one('SELECT * FROM email_queue') | ||
assert emails.spt_name == 'charge_'+status | ||
|
||
Participant.dequeue_emails() | ||
assert self.get_last_email()['to'][0]['email'] == '[email protected]' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,7 +49,7 @@ def test_take_over_sends_notifications_to_patrons(self): | |
|
||
def test_opt_in_notification_includes_unsubscribe(self): | ||
carl_twitter = self.make_elsewhere('twitter', 1, 'carl') | ||
roy = self.make_participant('roy', claimed_time='now', email_address='[email protected]', notify_on_opt_in=True) | ||
roy = self.make_participant('roy', claimed_time='now', email_address='[email protected]', notify_on_opt_in=1) | ||
roy.set_tip_to(carl_twitter.participant.username, '100') | ||
|
||
AccountElsewhere.from_user_name('twitter', 'carl').opt_in('carl') | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters