Skip to content
This repository was archived by the owner on Mar 15, 2018. It is now read-only.

Commit 0890b4b

Browse files
author
Andy McKay
committed
add in some CEF logging (bug 707288)
1 parent 654f89d commit 0890b4b

File tree

3 files changed

+39
-2
lines changed

3 files changed

+39
-2
lines changed

apps/addons/views.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,9 @@ def purchase(request, addon):
526526
slug=slug,
527527
uuid=uuid_))
528528
except:
529+
paypal.paypal_log_cef(request, addon, uuid_,
530+
'PayKey Failure', 'PAYKEYFAIL',
531+
'There was an error getting the paykey')
529532
log.error('Error getting paykey, purchase of addon: %s' % addon.pk,
530533
exc_info=True)
531534
error = _('There was an error communicating with PayPal.')
@@ -540,6 +543,10 @@ def purchase(request, addon):
540543
# If this was a pre-approval, it's completed already, we'll
541544
# double check this with PayPal, just to be sure nothing went wrong.
542545
if status == 'COMPLETED':
546+
paypal.paypal_log_cef(request, addon, uuid_,
547+
'Purchase', 'PURCHASE',
548+
'A user purchased using pre-approval')
549+
543550
log.debug('Status is completed for uuid: %s' % uuid_)
544551
if paypal.check_purchase(paykey) == 'COMPLETED':
545552
log.debug('Check purchase is completed for uuid: %s' % uuid_)
@@ -596,8 +603,14 @@ def purchase_complete(request, addon, status):
596603
try:
597604
result = paypal.check_purchase(con.paykey)
598605
if result == 'ERROR':
606+
paypal.paypal_log_cef(request, addon, uuid_,
607+
'Purchase Fail', 'PURCHASEFAIL',
608+
'Checking purchase state returned error')
599609
raise
600610
except:
611+
paypal.paypal_log_cef(request, addon, uuid_,
612+
'Purchase Fail', 'PURCHASEFAIL',
613+
'There was an error checking purchase state')
601614
log.error('Check purchase paypal addon: %s, user: %s, paykey: %s'
602615
% (addon.pk, request.amo_user.pk, con.paykey[:10]),
603616
exc_info=True)
@@ -684,6 +697,9 @@ def contribute(request, addon):
684697
slug=addon.slug,
685698
uuid=contribution_uuid))
686699
except:
700+
paypal.paypal_log_cef(request, addon, contribution_uuid,
701+
'PayKey Failure', 'PAYKEYFAIL',
702+
'There was an error getting the paykey')
687703
log.error('Error getting paykey, contribution for addon: %s'
688704
% addon.pk, exc_info=True)
689705
error = _('There was an error communicating with PayPal.')
@@ -702,8 +718,6 @@ def contribute(request, addon):
702718
paykey=paykey)
703719
contrib.save()
704720

705-
assert settings.PAYPAL_FLOW_URL, 'settings.PAYPAL_FLOW_URL is not defined'
706-
707721
url = '%s?paykey=%s' % (settings.PAYPAL_FLOW_URL, paykey)
708722
if request.GET.get('result_type') == 'json' or request.is_ajax():
709723
# If there was an error getting the paykey, then JSON will

apps/paypal/__init__.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
from amo.helpers import absolutify, urlparams
1616
from amo.urlresolvers import reverse
17+
from amo.utils import log_cef
1718

1819

1920
class PaypalError(Exception):
@@ -384,3 +385,11 @@ def socket_timeout(timeout):
384385
yield
385386
finally:
386387
socket.setdefaulttimeout(old)
388+
389+
390+
def paypal_log_cef(request, addon, uuid, msg, caps, longer):
391+
log_cef('Paypal %s' % msg, 5, request,
392+
username=request.amo_user,
393+
signature='PAYPAL%s' % caps,
394+
msg=longer, cs2=addon.name, cs2Label='PaypalTransaction',
395+
cs4=uuid, cs4Label='TxID')

apps/paypal/views.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
import amo
1616
from amo.decorators import no_login_required, post_required, write
17+
from paypal import paypal_log_cef
1718
from stats.db import StatsDictField
1819
from stats.models import Contribution, ContributionError, SubscriptionEvent
1920

@@ -208,6 +209,11 @@ def paypal_refunded(request, post, transaction):
208209
post_data=php.serialize(post)
209210
)
210211
paypal_log.info('Refund successfully processed')
212+
213+
paypal_log_cef(request, original.addon, post['txn_id'],
214+
'Refund', 'REFUND',
215+
'A paypal refund was processed')
216+
211217
return http.HttpResponse('Success!')
212218

213219

@@ -235,6 +241,11 @@ def paypal_reversal(request, post, transaction):
235241
post_data=php.serialize(post)
236242
)
237243
refund.mail_chargeback()
244+
245+
paypal_log_cef(request, original.addon, post['txn_id'],
246+
'Chargeback', 'CHARGEBACK',
247+
'A paypal chargeback was processed')
248+
238249
return http.HttpResponse('Success!')
239250

240251

@@ -271,5 +282,8 @@ def paypal_completed(request, post, transaction):
271282
# A failed thankyou email is not a show stopper, but is good to know.
272283
paypal_log.error('Thankyou note email failed with error: %s' % e)
273284

285+
paypal_log_cef(request, original.addon, post['txn_id'],
286+
'Purchase', 'PURCHASE',
287+
'A user purchased or contributed to an addon')
274288
paypal_log.info('Completed successfully processed')
275289
return http.HttpResponse('Success!')

0 commit comments

Comments
 (0)