summaryrefslogtreecommitdiff
path: root/postgresqleu/adyen/util.py
AgeCommit message (Collapse)Author
2023-07-25BREAKING CHANGE: Allow the currency format to be configurable.Dave Page
This change allows the currency format to be configured in the instance. This allows us to use alternate symbols (e.g. £), and to format amounts using the format required in different jurisdictions. The currency format is set to Euro by default. Note that this change requires an update to any Jinja templates that use the currency_format tag. This must be changed to format_currency.
2022-01-05Make the originalReference field optional in Adyen notificationsMagnus Hagander
This field is empty on AUTHORIZATION notifications and on some newer notifications it appears to then simply not be included.
2020-07-13Remove unused importsMagnus Hagander
2020-03-29Remove date parameter to create_accounting_entryMagnus Hagander
This should always be set to todays date, so set it in the function instaed. This changes the behaviour of the paypal plugin to actually use todays date rather than a date parsed out from the notification. In theory this could change the accounting entry date in case the notification is so delayed it ends up on a different day, but either one could be argued to be equally correct in this case, and using the date of creation of the transaction makes tracking things a lot easier. While at it, clean up some imports that have been missed earlier.
2020-03-12Replace datetime.now() with timezone.now()Magnus Hagander
As a step on the way to better timezone support, use the django function timezone.now() instead of datetime.now(). As long as we haven't enabled timezones globally this becomes a no-op and does exactly what it did before, but once timezones are enabled it will generate datetimes that are aware of this. No functionality change but gets a lot of boiler-plate out of the way making the verification of the rest of the timezone work easier.
2020-01-31Fix typoDaniel Gustafsson
We dont want to lose things, but we dont mind loose things..
2020-01-08Style and minor fixes pointed out by newer version of pep8Magnus Hagander
2019-01-19Fix missing class prefixMagnus Hagander
2019-01-19Fix incorrect order of fields in status messageMagnus Hagander
2019-01-19Re-factor payment methods and move configuration to the databaseMagnus Hagander
This is a major refactoring of how the payment method integrates, with the intetion of making it more flexible and more easy to use. 1. Configuration now lives in the database instead of local_settings.py. 2. This configuration is edited through the /admin/ interface, which makes it a lot easier to add constraints (and instructions), thus preventing misconfiguration. 3. Invoice payment methods are now separate from invoice payment implementations. That means there can be multiple instances of the same payment method, such as multiple different paypal accounts, being managed. 4. All payment method implementations are now available in all installations, including Braintree and Trustly. This retires the x_ENABLED settings in local_settings.py. The code won't actually run unless there are any payment methods defined with them. 5. On migration, all payment methods that are marked as inactive and have never been used are removed. Any payment method that has been used is left around, since there are old invoices connected to it. Likewise, any payment method that is selected as available for any sponsorship level (past or future) is left in the system. XXXXXX manual action needed on production systems XXXXXX 1. Settings for payment methods should be migrated automatically, but should of course be verified! 2. The template for Manual Bank Transfer is *not* migrated, since it wasn't in settings.py, but in a template and overriden downstream. Migrate the contents of the template invoices/banktransfer.html to the database using the /admin/ interface. When this is done, the template can be removed. 3. Notification URLs in Adyen must be updated in the Adyen backoffice to include the payment method id in the url (adding a /n/ to the end of the URL, with n being the id of the payment method). 4. Notification URLs in Paypal must be updated the same way.
2019-01-10Generic changes for python3 from 2to3Magnus Hagander
2019-01-05Allow proper processing of Adyen notifications from test systemMagnus Hagander
Instead of never doing anything about them other than sending an email, add a setting for ADYEN_IS_TEST_SYSTEM. If this setting is True (default!) and the notification comes in from the adyen test environment, process it as normal. If it's False and the notification comes in frmo the live environment, process as normal. Only if there is a mismatch is the email generated. In passing, change the term "test system" to "test environment", to make it more clear.
2019-01-04Switch to using requests for http requestsMagnus Hagander
It's a lot cleaner API than urllib2, and will be easier once we port version. Hopefully this doesn't break something. Probably it does break encoding somewhere, because py2.
2019-01-04Fix sibling importsMagnus Hagander
Sibling imports should be prefixed with a period. Good idea in py2, will eventually become required in py3, so another small step.
2019-01-04Switch to new style try/except handlingMagnus Hagander
Python 2.6 introduced the better syntax, Python 3 removes the old one, so one small step towards py3.
2018-12-14Fix blankline related warningsMagnus Hagander
2018-12-14Fix comment warningsMagnus Hagander
In passing remove some comments that were pointless
2018-12-14Fix spaces before/after comma and colonMagnus Hagander
Mostly not important, but getting rid of the PIP warnings will help catch errors in the future.
2018-12-14Fix spacing around operatorsMagnus Hagander
2018-12-14Manual fix of further whitespace issuesMagnus Hagander
Many of these were masked with the using of tabs, but were basically incorrect all the time. It's all in places where whitespace doesn't actually matter, but let's try to match up to PEP8.
2018-12-14Replace tabs with spacesMagnus Hagander
In an effort to close up with PEP8, we should use spaces for indent rather than tabs... Time to update your editor config!
2018-11-27Remove hardcoded PGEU prefix from Adyen and Paypal refundsMagnus Hagander
We already had the payment references in a parameter, but for some reason not the refunds. In passing, add ORG_SHORT_NAME to the settings and org_short_name to the context on all pages, to make it easier to do this in the future.
2018-09-07Fix imports of django urlresolvesVik Fearing
Importing from django.core.urlresolvers is deprecated in favor of django.urls.
2018-03-30Attempt to better handle payment exceptions in adyen processingMagnus Hagander
The invoice API actually allows us to get the reason for why the processing failed, so use that instead of just throwing an exception. In particular this lets us track the case of invalid size payment in relation to invoice amount (never happened so far), and also payments that happen after the invoice has been deleted (theoretically possible with creditcard payments, but very much realistic with iban payments -- it's more surprising it hasn't happened before). In these cases create an empty accounting record that can be processed, instead of leaving things in incomplete state.
2017-01-31Implement support for VAT in refundsMagnus Hagander
The actual VAT calculation will have to be done manually when a partial refund is done, since we can mix VAT amounts. This is unlikely to happen though, and refunds in general are quite uncommon, so we'll live with it. In passing, implement a nicer looking refund notice since we need to have VAT on it, including adding to the refund notice that the payment was returned to the original form of payment, as well as a hint to what that method was (including the type of credit card when available). NOTE! This makes an incompatible change to the PDF refund API, the same way that 5c2989d did for invoices. If VAT is not used, nothing other than just accepting the parameters and ignoring them is required.
2017-01-02Use consistent spelling for Credit CardDaniel Gustafsson
The correct spelling is credit card and not creditcard as we had in various places. Correct all userfacing occurrences except the already published financial reports.
2016-11-27Handle fractional euros/dollars in Adyen paymentsMagnus Hagander
This reverts the workarounds in 6b382af and c3ae5ec as they are no longer necessary. Seems like the actual fix was a lot easier than the workarounds..
2016-11-02Apply similar Adyen workaround to refunds as done for authorizationsMagnus Hagander
2016-11-02Fix typoMagnus Hagander
2016-11-01Workaround manual Adyen paymesn of less than 1EURMagnus Hagander
Since we round such payments down to 0, the accounting system throws an exception because the record becomes invalid. Instead, special-case this and flag it as FIXME in the accounting system for manual processing.
2016-01-20Implement proper refund managementMagnus Hagander
This means a few things: 1. We track refunds properly. Each invoice can be refunded once, but we now also support partial refunds (which is important, as almost every refund we make on a conference registration ends up being a partial one - if nothing else it is deducted transaction fees). 2. We support API initiated refunds. That means that as long as the payment is done using a supported provider (today that means Adyen and Paypal), the complete invoice processing is done in the webapp, which means there is no risk of getting the wrong numbers into the accounting (which has happened more than once). 3. We now generate proper refund notices in PDF format for all refunds (both automated and manual). The user receives this one as well as status updates throughout the refund process. Actual API refunds are handled by a new cronjob, to ensure that we don't end up blocking the user if the API is slow. Initiating the refund puts it on the queue, the cronjob sends it to the provider, and the notification from the provider flags it as completed (and generates the refund notice).
2016-01-15Track which payment provider was used to pay an invoiceMagnus Hagander
It's a "lossy tracking", since we allow invoices that are not paid with an explicit payment method, to maintain some of the decoupling that existed. With this, we can now also show for each invoice how much the payment fees were, which will make it easier to deal with refunds.
2016-01-07Mechanical changes for new django versionMagnus Hagander
2015-09-25Fix spelling errorMagnus Hagander
2015-09-25Fix error message substitutionMagnus Hagander
2015-09-23Indicate which payment method was used in Adyen notification emailsMagnus Hagander
This will be visa/mc/amex, but also (and the reason for this addition) separates out banktransferIban for the new payment method.
2014-06-04Work around the fact that adyen report notifications are hardcoded to EURMagnus Hagander
There is no real currency on report notifications, but Adyen pass along a hardcoded value of EUR. This rejected the notification when the system was configured for a non-EUR currency. With this change, we accept all notifications that are for report availability, even if they're not in the primary currency, but still reject any other kind of notifications.
2014-05-07Make the Adyen merchant reference prefix configurableMagnus Hagander
2014-04-28Add initial support for non-EUR currenciesMagnus Hagander
Put the EUR abbreviation and the € symbol as settings in settings.py instead, with the default obviously being Euro. We still only support one currency per installation configured globally, to keep things simple. The paypal integration requries a separate setting for currency, as some of that code is not in django (yet). This is intended in particular to be able to run the confreg system for non-euro conferences, but the settnigs are made global for the site.
2014-03-22Include the merchant reference in accounting entry for POS paymentsMagnus Hagander
Instead of just including the payment reference, we also include whatever text was entered into the POS terminal. That makes it a bit more reasonable to understand what's going on. Suggested by Guillaume
2014-02-08Add partial accounting of Adyen refundsMagnus Hagander
It's not fully automated. When a refund is sent, an open entry is created, where the treasurer will have to match it to the original transaction(s), and make sure the money is taken out of the appropriate account and object. It's automatically booked against a short-term debt account. When the settlement batch completes, we now process the refunded entries automatically against the rest of that batch.
2013-12-16Include payment links invoice payments as wellMagnus Hagander
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.
2013-12-16Fix the sign on manual adyen payment accountsMagnus Hagander
2013-12-16Support assocating URLs with each accounting entryMagnus Hagander
This makes it possible to link to for example scanned invoices stored elsewhere. Automatically generate attachment URLs for invoices generated in our system, as well as for manual Adyen payments.
2013-12-14Revert "Temporarily disable creation of automatic accounting entries"Magnus Hagander
This reverts commit 693f93df9490f9a3121b51b0bb8ad1ea8ff38f6e. This means we are now auto-generating accounting entries, as intended.
2013-12-08Temporarily disable creation of automatic accounting entriesMagnus Hagander
To make sure we don't stop payments from working while working on setting up the base information.
2013-12-08Automatically generate accounting records on paymentsMagnus Hagander
This will automatically create as much as possible of accounting records when payments arrive that we already know about. This menas either automated payments through Paypal or Adyen, or manually flagged invoices. Transactions that are fully specified (typically those caused by an invoice being paid) will automatically be closed and no manual work is needed. Transactions that are not fully specified will be left with an open accounting entry for manual completion. For manually flagged invoices, there will be a single accounting entry, with the full cost. If any fees show up later, they will need to be processed later. For Paypal paid invoices, there will be a single accounting entry, containing both the payment entry and the cost (going to different accounts of course). Paypal has it's own balance account, from which we make manual transfers in and out - and those manual transfers have to be manually accounted as well. For Adyen paid invoices, multiple accounting entries will be made. When the payment is authorized, one entry turning it into a short-term receivable under "Adyen authorized payments" for the full amount. Once the settlement completes, the fee will be known and posted to the cost account, and the remaining amount is moved to the "Adyen payable balance". Once the payout happens, it will need to be manually moved from the payable balance account to the main bank account (this step could possibly be automated in the future). Refunds are currently not tracked automatically, they have to be fully manually processed. With this change we now track accounting accounts and objects on the invoices. These fields can be left empty for manual processing, and there's intentionally not a foreign key in the database between these systems to keep them loosely connected. Conferences in the registration system now also carry a field to keep track of which accounting object transactions should be posted to - but the actual account numbers are per system (e.g. confreg vs membership).
2013-11-05Send email on successful refunds, not just unsuccessful ones!Magnus Hagander
2013-11-04Track refunds in the Adyen platformMagnus Hagander
We don't really do anything with them, other than collect the information and link it to the original payment. In particular, we do NOT attmpt to cancel any existing registrations or invoices, or anything like that.
2013-10-20Store payment method and merchant reference in transaction status as wellMagnus Hagander