From 18f104c2106ee7ef5fb467b4874bb32c3cd38f40 Mon Sep 17 00:00:00 2001 From: eric Date: Sun, 24 Nov 2013 18:44:40 -0500 Subject: [PATCH 1/4] latent spelling error --- payment/stripelib.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/payment/stripelib.py b/payment/stripelib.py index 5f140199..34f25c0c 100644 --- a/payment/stripelib.py +++ b/payment/stripelib.py @@ -716,7 +716,7 @@ class Processor(baseprocessor.Processor): return # make sure we are dealing with a stripe transaction if transaction.host <> PAYMENT_HOST_STRIPE: - raise StripeLibError("transaction.host {0} is not the expected {1}".format(transaction.host, PAYMENT_HOST_STRIPE)) + raise StripelibError("transaction.host {0} is not the expected {1}".format(transaction.host, PAYMENT_HOST_STRIPE)) sc = StripeClient() @@ -771,7 +771,7 @@ class Processor(baseprocessor.Processor): else: # nothing to charge - raise StripeLibError("No customer id available to charge for transaction {0}".format(transaction.id), None) + raise StripelibError("No customer id available to charge for transaction {0}".format(transaction.id), None) def api(self): From dd8343428291ec85d967d71b9858b882c3df0be9 Mon Sep 17 00:00:00 2001 From: eric Date: Mon, 25 Nov 2013 13:01:16 -0500 Subject: [PATCH 2/4] Fix error handling in Pay --- frontend/templates/pledge_card_error.html | 8 +++++--- payment/stripelib.py | 8 ++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/frontend/templates/pledge_card_error.html b/frontend/templates/pledge_card_error.html index b23c0612..832b2c39 100644 --- a/frontend/templates/pledge_card_error.html +++ b/frontend/templates/pledge_card_error.html @@ -1,7 +1,7 @@ {% extends "basepledge.html" %} {% load humanize %} -{% block title %}Credit card processing Error{% endblock %} +{% block title %}Credit card processing Issue{% endblock %} {% block doccontent %}
@@ -9,9 +9,11 @@
-

Error: Card authorization

+

Credit Card not Authorized

-

Unglue.it would like to accept your credit card, but we encountered the following problem: {{exception.message}}. Please try again, or contact unglue.it support. +

Unglue.it would like to accept your credit card, but we encountered a problem: {{transaction.error}} {% if request.user.account_set %}Please Update your credit card, + {% else %}Please try again,{% endif %} + or contact unglue.it support.

diff --git a/payment/stripelib.py b/payment/stripelib.py index 34f25c0c..4c3c014c 100644 --- a/payment/stripelib.py +++ b/payment/stripelib.py @@ -689,8 +689,7 @@ class Processor(baseprocessor.Processor): transaction.pay_key = p.key() transaction.save() else: - transaction.error = p.error_string() - transaction.save() + self.errorMessage = p.errorMessage #pass error message up logger.info("execute_transaction Error: " + p.error_string()) def amount( self ): @@ -709,6 +708,7 @@ class Processor(baseprocessor.Processor): ''' def __init__(self, transaction=None): + self.transaction = transaction # make sure transaction hasn't already been executed @@ -744,7 +744,7 @@ class Processor(baseprocessor.Processor): status=TRANSACTION_STATUS_ERROR, transaction=transaction) transaction.status = TRANSACTION_STATUS_ERROR - transaction.error = e.message + self.errorMessage = e.message # manager puts this on transaction transaction.save() # fire off the fact that transaction failed -- should actually do so only if not a transient error @@ -755,7 +755,7 @@ class Processor(baseprocessor.Processor): else: logger.exception("transaction id {0}, exception: {1}".format(transaction.id, e.message)) - raise StripelibError(e.message, e) + # raise StripelibError(e.message, e) else: self.charge = charge From af553056e8b59b9dadade3e20b9425e3133813ad Mon Sep 17 00:00:00 2001 From: eric Date: Mon, 25 Nov 2013 13:29:31 -0500 Subject: [PATCH 3/4] update pledge_failed notices --- .../templates/notification/pledge_failed/full.txt | 10 +++++++--- .../notification/pledge_failed/notice.html | 14 +++++++++++--- .../templates/notification/pledge_failed/short.txt | 2 +- frontend/templates/notification/pledge_summary.txt | 6 +++++- 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/frontend/templates/notification/pledge_failed/full.txt b/frontend/templates/notification/pledge_failed/full.txt index f9568b8c..ca1a3139 100644 --- a/frontend/templates/notification/pledge_failed/full.txt +++ b/frontend/templates/notification/pledge_failed/full.txt @@ -1,9 +1,13 @@ -{% load humanize %}Thanks to you and other ungluers, {{ transaction.campaign.work.title }} will be released to the world in an unglued ebook edition. +{% load humanize %}{{ transaction.campaign.work.title }} will be released to the world in an unglued ebook edition. -However, our attempt to charge your credit card in the amount of ${{ transaction.amount|intcomma }} failed ({{transaction.error}}). Don't worry -- typically this means the card on file for you is expired, and once you update your card information we'll be able to collect your pledge on behalf of {{ transaction.campaign.rightsholder }}. Please update your credit card information at +However, our attempt to charge your credit card in the amount of ${{ transaction.amount|intcomma }} failed ({{transaction.error}}). +{% ifequal transaction.campaign.type 1 %}Don't worry -- typically this means the card on file for you is expired, and once you update your card information we'll be able to collect your pledge on behalf of {{ transaction.campaign.rightsholder }}. Please update your credit card information at https://{{ current_site.domain }}{% url manage_account %} by {{ recharge_deadline }} so that you can fulfill your pledge. Thank you! -Pledge summary +Pledge summary {% else %}Don't worry -- typically this means the card on file for you is expired, and once you update your card information you'll be able to complete your purchase. Please update your credit card information at +https://{{ current_site.domain }}{% url manage_account %}. Thank you! + +Transaction summary {% endifequal %} {% include "notification/pledge_summary.txt" %} If you'd like to visit the campaign page, click here: diff --git a/frontend/templates/notification/pledge_failed/notice.html b/frontend/templates/notification/pledge_failed/notice.html index b4476174..78680529 100644 --- a/frontend/templates/notification/pledge_failed/notice.html +++ b/frontend/templates/notification/pledge_failed/notice.html @@ -6,7 +6,7 @@ {% endblock %} {% block comments_graphical %} - The campaign for {{ transaction.campaign.work.title }} has succeeded. However, our attempt to charge your pledge for ${{ transaction.amount|intcomma }} to your credit card failed ({{transaction.error}}). Will you help us fix that? + {% ifequal transaction.campaign.type 1 %}The campaign for {{ transaction.campaign.work.title }} has succeeded. However, our attempt to charge your pledge for ${{ transaction.amount|intcomma }} to your credit card failed ({{transaction.error}}). Will you help us fix that?{% else %}Our attempt to charge a purchase of ${{ transaction.amount|intcomma }} to your credit card failed ({{transaction.error}}).{% endifequal %} {% endblock %} {% block comments_textual %} @@ -14,9 +14,9 @@

Thanks to you and other ungluers, {{ transaction.campaign.work.title }} will be released to the world in an unglued ebook edition. However, our attempt to charge your credit card for ${{ transaction.amount|intcomma }} failed.

- + {% ifequal transaction.campaign.type 1 %}

Don't worry - normally this just means the card we have on file for you is expired. Once you've updated your card information we'll be able to collect your pledge on behalf of {{ transaction.campaign.rightsholder }}. Please update your credit card information at - https://{{ current_site.domain }}{% url manage_account %} by {{ recharge_deadline }} so that you can fulfill your pledge. Thank you!

+ your account management page by {{ recharge_deadline }} so that you can fulfill your pledge. Thank you!

Pledge Summary
Amount pledged: {{ transaction.amount|intcomma }}
@@ -24,6 +24,14 @@

We will notify you when the unglued ebook is available for you to read. If you've requested special premiums, the campaign manager, {{ transaction.campaign.rightsholder }}, will be in touch with you via email to request any information needed to deliver your premium.

+ {% else %} +

Don't worry - normally this just means the card we have on file for you is expired. Once you've updated your card information You'll be able to complete your purchase. Please update your credit card information at + your account management page. Thank you!

+ +

Transaction Summary
+ Amount of purchase: {{ transaction.amount|intcomma }}
+

+ {% endifequal %}

For more information, visit the campaign page.

diff --git a/frontend/templates/notification/pledge_failed/short.txt b/frontend/templates/notification/pledge_failed/short.txt index 3e9e1646..07680752 100644 --- a/frontend/templates/notification/pledge_failed/short.txt +++ b/frontend/templates/notification/pledge_failed/short.txt @@ -1 +1 @@ -Attention needed: your pledge to unglue {{transaction.campaign.work.title}} \ No newline at end of file +Attention needed: your {% ifequal transaction.campaign.type 1 %}pledge to unglue{% else %}purchase of{% endifequal %} {{transaction.campaign.work.title}} \ No newline at end of file diff --git a/frontend/templates/notification/pledge_summary.txt b/frontend/templates/notification/pledge_summary.txt index f7b1b48f..3cd5fafb 100644 --- a/frontend/templates/notification/pledge_summary.txt +++ b/frontend/templates/notification/pledge_summary.txt @@ -1,4 +1,5 @@ {% load humanize %} +{% ifequal transaction.campaign.type 1 %} Amount pledged: ${{ transaction.amount|intcomma }} Premium: {{ transaction.premium.description }} @@ -10,4 +11,7 @@ You will also be acknowledged as follows: - The following dedication will be included in the ebook: {{ transaction.extra.ack_dedication }}{% else %} - You were eligible to include a dedication in the unglued ebook, but did not choose to do so. If you like, you can change this at https://{{ current_site.domain }}{% url pledge_modify work_id=transaction.campaign.work.id %}. -{% endif %}{% endifequal %} +{% endif %}{% endifequal %}{% else %} +Amount charged: ${{ transaction.amount|intcomma }} + +{% endifequal %} From 6539370e37c81f93846d5f28aa3ae118c0e4a5f4 Mon Sep 17 00:00:00 2001 From: eric Date: Mon, 25 Nov 2013 13:37:15 -0500 Subject: [PATCH 4/4] remove commented code --- payment/manager.py | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/payment/manager.py b/payment/manager.py index 1edf97fe..7e0b4a15 100644 --- a/payment/manager.py +++ b/payment/manager.py @@ -637,26 +637,8 @@ class PaymentManager( object ): # we might want to not allow for a return_url to be passed in but calculated # here because we have immediate access to the Transaction object. - #if return_url is None: - # - # #return_path = "{0}?{1}".format(reverse('charge_complete'), - # # urllib.urlencode({'tid':transaction.id})) - # return_path = "{0}?{1}".format(reverse('pledge_complete'), - # urllib.urlencode({'tid':transaction.id})) - # return_url = urlparse.urljoin(settings.BASE_URL_SECURE, return_path) - - # Question: do I need to set transaction.amount = transaction.max_amount ? p = transaction.get_payment_class().Pay(transaction, amount=transaction.max_amount, return_url=return_url, paymentReason=paymentReason) - # Create a response for this - #envelope = p.envelope() - # - #if envelope: - # r = PaymentResponse.objects.create(api=p.url, - # correlation_id = p.correlation_id(), - # timestamp = p.timestamp(), - # info = p.raw_response, - # transaction=transaction) if p.success() and not p.error(): transaction.preapproval_key = p.key()