From 974b90676ee5438664050b0b988daa2f3bfed022 Mon Sep 17 00:00:00 2001 From: Thomas Steen Rasmussen Date: Tue, 11 Jul 2017 11:06:46 +0200 Subject: [PATCH] make coinify callback hostname configurable, so we can workaround old openssl in their callback engine --- src/bornhack/environment_settings.py.dist | 1 + src/shop/models.py | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/bornhack/environment_settings.py.dist b/src/bornhack/environment_settings.py.dist index 865c719a..e5f15046 100644 --- a/src/bornhack/environment_settings.py.dist +++ b/src/bornhack/environment_settings.py.dist @@ -57,6 +57,7 @@ EPAY_MD5_SECRET='{{ epay_md5_secret }}' COINIFY_API_KEY='{{ coinify_api_key }}' COINIFY_API_SECRET='{{ coinify_api_secret }}' COINIFY_IPN_SECRET='{{ coinify_ipn_secret }}' +COINIFY_CALLBACK_HOSTNAME='{{ coinify_callback_hostname }}' # leave empty or comment out to use hostname from request # shop settings PDF_LETTERHEAD_FILENAME='{{ pdf_letterhead_filename }}' diff --git a/src/shop/models.py b/src/shop/models.py index 1163e361..0053970d 100644 --- a/src/shop/models.py +++ b/src/shop/models.py @@ -144,7 +144,12 @@ class Order(CreatedUpdatedModel): return False def get_coinify_callback_url(self, request): - return 'https://' + request.get_host() + str(reverse_lazy('shop:coinify_callback', kwargs={'pk': self.pk})) + """ Check settings for an alternative COINIFY_CALLBACK_HOSTNAME otherwise use the one from the request """ + if 'COINIFY_CALLBACK_HOSTNAME' in settings and settings['COINIFY_CALLBACK_HOSTNAME']: + host = settings['COINIFY_CALLBACK_HOSTNAME'] + else: + host = request.get_host() + return 'https://' + host + str(reverse_lazy('shop:coinify_callback', kwargs={'pk': self.pk})) def get_coinify_thanks_url(self, request): return 'https://' + request.get_host() + str(reverse_lazy('shop:coinify_thanks', kwargs={'pk': self.pk}))