forked from CGM_Public/pretix_original
handle unknown gift cards
This commit is contained in:
@@ -1525,18 +1525,26 @@ class GiftCardPayment(BasePaymentProvider):
|
||||
def payment_control_render(self, request, payment) -> str:
|
||||
from .models import GiftCard
|
||||
|
||||
if 'gift_card' in payment.info_data:
|
||||
gc = GiftCard.objects.get(pk=payment.info_data.get('gift_card'))
|
||||
if any(key in payment.info_data for key in ('gift_card', 'error')):
|
||||
template = get_template('pretixcontrol/giftcards/payment.html')
|
||||
|
||||
ctx = {
|
||||
'request': request,
|
||||
'event': self.event,
|
||||
'gc': gc,
|
||||
**({'error': payment.info_data[
|
||||
'error']} if 'error' in payment.info_data else {})
|
||||
'error']} if 'error' in payment.info_data else {}),
|
||||
**({'gift_card_secret': payment.info_data[
|
||||
'gift_card_secret']} if 'gift_card_secret' in payment.info_data else {})
|
||||
}
|
||||
return template.render(ctx)
|
||||
|
||||
try:
|
||||
gc = GiftCard.objects.get(pk=payment.info_data.get('gift_card'))
|
||||
ctx = {
|
||||
'gc': gc,
|
||||
}
|
||||
except GiftCard.DoesNotExist:
|
||||
pass
|
||||
finally:
|
||||
return template.render(ctx)
|
||||
|
||||
def payment_control_render_short(self, payment: OrderPayment) -> str:
|
||||
d = payment.info_data
|
||||
@@ -1551,7 +1559,10 @@ class GiftCardPayment(BasePaymentProvider):
|
||||
try:
|
||||
gc = GiftCard.objects.get(pk=payment.info_data.get('gift_card'))
|
||||
except GiftCard.DoesNotExist:
|
||||
return {}
|
||||
return {
|
||||
**({'error': payment.info_data[
|
||||
'error']} if 'error' in payment.info_data else {})
|
||||
}
|
||||
return {
|
||||
'gift_card': {
|
||||
'id': gc.pk,
|
||||
|
||||
Reference in New Issue
Block a user