コード例 #1
0
 def get_credentials(event=None):
     """
     If the event parameter is None, It returns the secret and publishable key of the Admin's Stripe account.
     Else, it returns the corresponding values for the event organizer's account.
     :param event:
     :return: Stripe secret and publishable keys.
     """
     if not event:
         settings = get_settings()
         if settings['app_environment'] == 'development' and settings['stripe_test_secret_key'] and \
                 settings['stripe_test_publishable_key']:
             return {
                 'SECRET_KEY': settings['stripe_test_secret_key'],
                 'PUBLISHABLE_KEY': settings["stripe_test_publishable_key"]
             }
         elif settings['stripe_secret_key'] and settings["stripe_publishable_key"]:
             return {
                 'SECRET_KEY': settings['stripe_secret_key'],
                 'PUBLISHABLE_KEY': settings["stripe_publishable_key"]
             }
         else:
             return None
     else:
         if represents_int(event):
             authorization = StripeAuthorization.query.filter_by(event_id=event).first()
         else:
             authorization = event.stripe_authorization
         if authorization:
             return {
                 'SECRET_KEY': authorization.stripe_secret_key,
                 'PUBLISHABLE_KEY': authorization.stripe_publishable_key
             }
         else:
             return None
コード例 #2
0
 def get_credentials(event=None):
     """
     If the event parameter is None, It returns the secret and publishable key of the Admin's Stripe account.
     Else, it returns the corresponding values for the event organizer's account.
     :param event:
     :return: Stripe secret and publishable keys.
     """
     if not event:
         settings = get_settings()
         if settings['stripe_secret_key'] and settings["stripe_publishable_key"] and settings[
             'stripe_secret_key'] != "" and \
                 settings["stripe_publishable_key"] != "":
             return {
                 'SECRET_KEY': settings['stripe_secret_key'],
                 'PUBLISHABLE_KEY': settings["stripe_publishable_key"]
             }
         else:
             return None
     else:
         if represents_int(event):
             authorization = StripeAuthorization.query.filter_by(event_id=event).first()
         else:
             authorization = event.stripe_authorization
         if authorization:
             return {
                 'SECRET_KEY': authorization.stripe_secret_key,
                 'PUBLISHABLE_KEY': authorization.stripe_publishable_key
             }
         else:
             return None
コード例 #3
0
 def get_credentials(event=None):
     if not event:
         settings = get_settings()
         if settings['stripe_secret_key'] and settings["stripe_publishable_key"] and settings[
             'stripe_secret_key'] != "" and \
                 settings["stripe_publishable_key"] != "":
             return {
                 'SECRET_KEY': settings['stripe_secret_key'],
                 'PUBLISHABLE_KEY': settings["stripe_publishable_key"]
             }
         else:
             return None
     else:
         if represents_int(event):
             authorization = StripeAuthorization.query.filter_by(event_id=event).first()
         else:
             authorization = event.stripe
         if authorization:
             return {
                 'SECRET_KEY': authorization.stripe_secret_key,
                 'PUBLISHABLE_KEY': authorization.stripe_publishable_key
             }
         else:
             return None
コード例 #4
0
    def get_credentials(event=None, override_mode=False, is_testing=False):
        if event and represents_int(event):
            event = safe_query(db, Event, 'id', event, 'event_id')
        settings = get_settings()
        if not override_mode:
            if settings['paypal_mode'] and settings['paypal_mode'] != "":
                if settings['paypal_mode'] == 'live':
                    is_testing = False
                else:
                    is_testing = True
            else:
                return None

        if is_testing:
            credentials = {
                'USER': settings['paypal_sandbox_username'],
                'PWD': settings['paypal_sandbox_password'],
                'SIGNATURE': settings['paypal_sandbox_signature'],
                'SERVER': 'https://api-3t.sandbox.paypal.com/nvp',
                'CHECKOUT_URL': 'https://www.sandbox.paypal.com/cgi-bin/webscr',
                'EMAIL': '' if not event or not event.paypal_email or event.paypal_email == "" else event.paypal_email
            }
        else:
            credentials = {
                'USER': settings['paypal_live_username'],
                'PWD': settings['paypal_live_password'],
                'SIGNATURE': settings['paypal_live_signature'],
                'SERVER': 'https://api-3t.paypal.com/nvp',
                'CHECKOUT_URL': 'https://www.paypal.com/cgi-bin/webscr',
                'EMAIL': '' if not event or not event.paypal_email or event.paypal_email == "" else event.paypal_email
            }
        if credentials['USER'] and credentials['PWD'] and credentials['SIGNATURE'] and credentials['USER'] != "" and \
                credentials['PWD'] != "" and credentials['SIGNATURE'] != "":
            return credentials
        else:
            return None
コード例 #5
0
def test_represents_int():
    """Method to test representation of int"""

    assert represents_int(4) is True
    assert represents_int('test') is False
コード例 #6
0
    def test_represents_int(self):
        """Method to test representation of int"""

        with app.test_request_context():
            self.assertTrue(represents_int(4))
            self.assertFalse(represents_int('test'))
コード例 #7
0
ファイル: test_utilities.py プロジェクト: shawnjots/eventcity
    def test_represents_int(self):
        """Method to test representation of int"""

        self.assertTrue(represents_int(4))
        self.assertFalse(represents_int('test'))