forked from CGM_Public/pretix_original
NREI export: Fix parsing of stripe data
This commit is contained in:
@@ -116,15 +116,29 @@ class DekodiNREIExporter(BaseExporter):
|
|||||||
'PTNo15': p.full_id or '',
|
'PTNo15': p.full_id or '',
|
||||||
})
|
})
|
||||||
elif p.provider and p.provider.startswith('stripe'):
|
elif p.provider and p.provider.startswith('stripe'):
|
||||||
src = p.info_data.get("source", p.info_data)
|
pi = p.info_data or {}
|
||||||
|
try:
|
||||||
|
if "latest_charge" in pi and isinstance(pi.get("latest_charge"), dict):
|
||||||
|
details = pi["latest_charge"]["payment_method_details"]
|
||||||
|
card = details.get("card", {})
|
||||||
|
elif pi.get("charges") and pi["charges"]["data"]:
|
||||||
|
details = pi["charges"]["data"][0].get("payment_method_details", {})
|
||||||
|
card = details.get("card", {})
|
||||||
|
else:
|
||||||
|
details = pi["source"]
|
||||||
|
card = pi["source"]["card"]
|
||||||
|
except:
|
||||||
|
details = {}
|
||||||
|
card = {}
|
||||||
|
|
||||||
payments.append({
|
payments.append({
|
||||||
'PTID': '81',
|
'PTID': '81',
|
||||||
'PTN': 'Stripe',
|
'PTN': 'Stripe',
|
||||||
'PTNo1': p.info_data.get("id") or '',
|
'PTNo1': pi.get("id") or '',
|
||||||
'PTNo5': src.get("card", {}).get("last4") or '',
|
'PTNo5': card.get("last4", ""),
|
||||||
'PTNo7': round(float(p.amount), 2) or '',
|
'PTNo7': round(float(p.amount), 2) or '',
|
||||||
'PTNo8': str(self.event.currency) or '',
|
'PTNo8': str(self.event.currency) or '',
|
||||||
'PTNo10': src.get('owner', {}).get('verified_name') or src.get('owner', {}).get('name') or '',
|
'PTNo10': details.get('owner', {}).get('verified_name') or details.get('owner', {}).get('name') or '',
|
||||||
'PTNo15': p.full_id or '',
|
'PTNo15': p.full_id or '',
|
||||||
})
|
})
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user