<commit_before>from trustify.client.challenge import Challenge
from trustify.client import logger

# TODO: How is this determined?
curses = True;

############################################################
# Possible addition to challenge structure: priority parameter
# If only DVSNI and Payment are required, the user might want
# to be validated before submitting payment, allowing the user
# to gain confidence in the system.  If things do go poorly the 
# user has less invested in that particular session/transaction. 
#############################################################

class Payment_Challenge(Challenge):
    # Possible reasons: Wildcard Certificates, EV certificates
    # Malware scanning services, Organization or Identity validated certs
    def __init__(self, url, reason="Specialty Certificate"):
        self.url = url
    def perform(self, quiet=True):
        if curses:
            dialog.Dialog().msgbox("You are buying " + formatted_reasons() + " You will need to visit " + self.url + " to submit your payment\nPlease click continue once your payment has been submitted", width=70)
        return True
    
    def redo(self, quiet=True):
        """
        Some other message called when challenge verification wasn't successful
        This should probably be a standard challenge function for all failed
        challenge attempts
        """
        if curses:
            dialog.Dialog().msgbox("The CA did not record your payment, please visit " + self.url + " for more information or to finish processing your transaction.", width=70)

        return True
<commit_msg>Payment challenge redo was merged into perform based on execution count<commit_after>from trustify.client.challenge import Challenge
from trustify.client import logger

# TODO: How is this determined?
curses = True;

############################################################
# Possible addition to challenge structure: priority parameter
# If only DVSNI and Payment are required, the user might want
# to be validated before submitting payment, allowing the user
# to gain confidence in the system.  If things do go poorly the 
# user has less invested in that particular session/transaction. 
#############################################################

class Payment_Challenge(Challenge):
    # Possible reasons: Wildcard Certificates, EV certificates
    # Malware scanning services, Organization or Identity validated certs
    def __init__(self, url, reason="Specialty Certificate"):
        self.url = url
        self.reason = reason
        self.times_performed = 0
        
    def perform(self, quiet=True):
        if curses:
            dialog.Dialog().msgbox(get_display_string(), width=70)
        else:
            print get_display_string()
            raw_input('')

        self.times_performed += 1
        return True
    

    def get_display_string():
        if self.times_performed == 0:
            return "You are buying " + formatted_reasons() + " You will need to visit " + self.url + " to submit your payment\nPlease press enter once your payment has been submitted"

        # The user has tried at least once... display a different message
        else:
            return "The CA did not record your payment, please visit " + self.url + " for more information or to finish processing your transaction.\nPress Enter to continue"
        

    def formatted_reasons():
        return "\n\t* %s\n", self.reason


{'fraction_non_alphanumeric': 0.13256150506512301, 'fraction_numerical': 0.0026049204052098407, 'mean_word_length': 3.402547770700637, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2539961', 'n_tokens_mistral': 837, 'n_tokens_neox': 790, 'n_words': 347}