"""
In order to get a tokenized credit card back from braintreee you need to base64(hash) the payment token

This file gets the hash of the payment token and returning the 'authorizationFingerprint'
"""

import base64
import json


def decode_user_token(token):
    decode_token = base64.b64decode(token)
    decode_token = decode_token.decode('utf-8')
    authorization_fingerprint = json.loads(decode_token)
    authorization_fingerprint = authorization_fingerprint['authorizationFingerprint']

    # print(authorization_fingerprint)
    return authorization_fingerprint
