From f73e5fabb3d302d96e9db9f447fc9ab2cfa3dbb6 Mon Sep 17 00:00:00 2001 From: Shwetabh Kumar Date: Tue, 16 Apr 2024 18:55:10 +0530 Subject: [PATCH] Fix: Handling country name safely in Payment profiles (TP) (#196) --- apps/travelperk/connector.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/travelperk/connector.py b/apps/travelperk/connector.py index aaefd68..4d7ebff 100644 --- a/apps/travelperk/connector.py +++ b/apps/travelperk/connector.py @@ -67,13 +67,15 @@ def sync_invoice_profile(self): response = self.connection.invoice_profiles.get_all() for invoice_profile in response: + country_name = invoice_profile['billing_information']['country_name'] if 'country_name' in invoice_profile['billing_information'] else None + currency = invoice_profile['currency'] if 'currency' in invoice_profile else None TravelperkProfileMapping.objects.update_or_create( org_id=self.org_id, profile_name=invoice_profile['name'], source_id=invoice_profile['id'], defaults={ - 'country': invoice_profile['billing_information']['country_name'], - 'currency': invoice_profile['currency'], + 'country': country_name, + 'currency': currency, } )