summaryrefslogtreecommitdiff
path: root/postgresqleu
diff options
context:
space:
mode:
authorMagnus Hagander2013-12-16 16:40:43 +0000
committerMagnus Hagander2013-12-16 16:40:43 +0000
commita4c59328f1dca33e43bea0eb1f1c4470b69c32e4 (patch)
tree0b48813d3c6f77c5765f6faa12ea193bf9240a40 /postgresqleu
parent8794557c04d75453f50d5e3c5bfb047fdbccb99d (diff)
Include payment links invoice payments as well
It never hurts to have a linkback to Adyen and Paypal as well as the link directly to the invoice - since we have the info.
Diffstat (limited to 'postgresqleu')
-rw-r--r--postgresqleu/adyen/util.py7
-rw-r--r--postgresqleu/invoices/util.py8
-rw-r--r--postgresqleu/paypal/views.py8
3 files changed, 17 insertions, 6 deletions
diff --git a/postgresqleu/adyen/util.py b/postgresqleu/adyen/util.py
index 75631918..af8d2964 100644
--- a/postgresqleu/adyen/util.py
+++ b/postgresqleu/adyen/util.py
@@ -34,6 +34,10 @@ def process_authorization(notification):
capturedat=None)
trans.save()
+ # Generate urls pointing back to this entry in the Adyen online
+ # system, for inclusion in accounting records.
+ urls = ["https://ca-live.adyen.com/ca/ca/accounts/showTx.shtml?pspReference=%s&txType=Payment&accountKey=MerchantAccount.%s" % (notification.pspReference, notification.merchantAccountCode),]
+
# We can receive authorizations on non-primary Adyen merchant
# accounts. This happens for example with payments from POS
# terminals. In those cases, just send an email, and don't
@@ -53,7 +57,6 @@ def process_authorization(notification):
accrows = [
(settings.ACCOUNTING_ADYEN_AUTHORIZED_ACCOUNT, accstr, trans.amount, None),
]
- urls = ["https://ca-live.adyen.com/ca/ca/accounts/showTx.shtml?pspReference=%s&txType=Payment&accountKey=MerchantAccount.%s" % (notification.pspReference, notification.merchantAccountCode),]
create_accounting_entry(date.today(), accrows, True, urls)
return
@@ -74,7 +77,7 @@ def process_authorization(notification):
def invoice_logger(msg):
raise AdyenProcessingException('Invoice processing failed: %s', msg)
- manager.process_incoming_payment_for_invoice(invoice, notification.amount, 'Adyen id %s' % notification.pspReference, 0, settings.ACCOUNTING_ADYEN_AUTHORIZED_ACCOUNT, 0, invoice_logger)
+ manager.process_incoming_payment_for_invoice(invoice, notification.amount, 'Adyen id %s' % notification.pspReference, 0, settings.ACCOUNTING_ADYEN_AUTHORIZED_ACCOUNT, 0, urls, invoice_logger)
if invoice.accounting_object:
# Store the accounting object so we can properly tag the
diff --git a/postgresqleu/invoices/util.py b/postgresqleu/invoices/util.py
index 1476e15d..e2f8a1fd 100644
--- a/postgresqleu/invoices/util.py
+++ b/postgresqleu/invoices/util.py
@@ -172,7 +172,7 @@ class InvoiceManager(object):
RESULT_DELETED = 4
RESULT_INVALIDAMOUNT = 5
RESULT_PROCESSORFAIL = 6
- def process_incoming_payment(self, transtext, transamount, transdetails, transcost, incomeaccount, costaccount, logger=None):
+ def process_incoming_payment(self, transtext, transamount, transdetails, transcost, incomeaccount, costaccount, extraurls=None, logger=None):
# If there is no logger specified, just log with print statement
if not logger:
logger = _standard_logger
@@ -211,10 +211,10 @@ class InvoiceManager(object):
logger("Could not find invoice with id '%s'" % invoiceid)
return (self.RESULT_NOTFOUND, None, None)
- return self.process_incoming_payment_for_invoice(invoice, transamount, transdetails, transcost, incomeaccount, costaccount, logger)
+ return self.process_incoming_payment_for_invoice(invoice, transamount, transdetails, transcost, incomeaccount, costaccount, extraurls, logger)
- def process_incoming_payment_for_invoice(self, invoice, transamount, transdetails, transcost, incomeaccount, costaccount, logger):
+ def process_incoming_payment_for_invoice(self, invoice, transamount, transdetails, transcost, incomeaccount, costaccount, extraurls, logger):
# Do the same as process_incoming_payment, but assume that the
# invoice has already been matched by other means.
invoiceid = invoice.pk
@@ -282,6 +282,8 @@ class InvoiceManager(object):
else:
leaveopen = True
urls = ['%s/invoices/%s/' % (settings.SITEBASE_SSL, invoice.pk),]
+ if extraurls:
+ urls.extend(extraurls)
create_accounting_entry(date.today(), accrows, leaveopen, urls)
diff --git a/postgresqleu/paypal/views.py b/postgresqleu/paypal/views.py
index bcde2ede..eedeadaf 100644
--- a/postgresqleu/paypal/views.py
+++ b/postgresqleu/paypal/views.py
@@ -123,6 +123,12 @@ def paypal_return_handler(request):
matched = False)
ti.save()
+ # Generate URLs that link back to paypal in a way that we can use
+ # from the accounting system. Note that this is an undocumented
+ # URL format for paypal, so it may stop working at some point in
+ # the future.
+ urls = ["https://www.paypal.com/cgi-bin/webscr?cmd=_view-a-trans&id=%s" % ti.paypaltransid,]
+
# Separate out donations made through our website
if ti.transtext == "PostgreSQL Europe donation":
ti.matched = True
@@ -137,7 +143,6 @@ def paypal_return_handler(request):
(settings.ACCOUNTING_PAYPAL_FEE_ACCOUNT, accstr, ti.fee),
(settings.ACCOUNTING_DONATIONS_ACCOUNT, accstr, -ti.amount),
]
- urls = ["https://www.paypal.com/cgi-bin/webscr?cmd=_view-a-trans&id=%s" % ti.paypaltransid,]
create_accounting_entry(date.today(), accrows, True, urls)
return render_to_response('paypal/noinvoice.html', {
@@ -150,6 +155,7 @@ def paypal_return_handler(request):
ti.fee,
settings.ACCOUNTING_PAYPAL_INCOME_ACCOUNT,
settings.ACCOUNTING_PAYPAL_FEE_ACCOUNT,
+ urls,
payment_logger)
if r == invoicemanager.RESULT_OK:
# Matched it!