Skip to content

Commit

Permalink
Merge pull request #811 from xzzy/master
Browse files Browse the repository at this point in the history
Fix store card error when card token already exists on user account and payment logging env
  • Loading branch information
xzzy committed Aug 14, 2020
2 parents 05b92d8 + 62cef38 commit 85c1a93
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
7 changes: 7 additions & 0 deletions ledger/payments/bpoint/facade.py
Expand Up @@ -189,6 +189,13 @@ def post_transaction(self, action,_type,sub_type,order_number=None,reference=Non
raise

def store_token(self, user,token,masked_card,expiry_date,card_type):

bt = BpointToken.objects.filter(user=user,masked_card=masked_card,expiry_date=datetime.datetime.strptime(expiry_date, '%m%y').date(),card_type=card_type)
if bt.count() > 0:
for b in bt:
b.delete()
print ("Existing store token exists for userid "+str(user.id)+". Deleting Existing token to allow new token to be created")

token,created = BpointToken.objects.get_or_create(
user=user,
DVToken=token,
Expand Down
21 changes: 18 additions & 3 deletions ledger/settings_base.py
Expand Up @@ -249,6 +249,16 @@
'formatter': 'verbose',
'maxBytes': 5242880
},

'ledger_bpoint': {
'level': 'INFO',
'class': 'logging.handlers.RotatingFileHandler',
'filename': os.path.join(BASE_DIR, 'logs', 'ledger_bpoint.log'),
'formatter': 'verbose',
'maxBytes': 5242880
}


},
'loggers': {
'': {
Expand Down Expand Up @@ -294,9 +304,14 @@
}
}
PAYMENT_LOGGING=env('PAYMENT_LOGGING','False')
if PAYMENT_LOGGING == 'True':
LOGGING = {'loggers': {'ledger_bpoint': { 'handlers': ['file'],'level': 'INFO', } }}
LOGGING = {'loggers': {'oscar.checkout': { 'handlers': ['file'],'level': 'INFO', } }}
print ("LOGGING")
print (PAYMENT_LOGGING)
if PAYMENT_LOGGING == 'True' or PAYMENT_LOGGING is True:
LOGGING['loggers']['ledger_bpoint'] = { 'handlers': ['file'],'level': 'INFO', }
LOGGING['loggers']['oscar.checkout'] = { 'handlers': ['file'],'level': 'INFO', }


print (LOGGING)
# django-dynamic-fields test generation settings
DDF_FILL_NULLABLE_FIELDS = False

Expand Down

0 comments on commit 85c1a93

Please sign in to comment.