Beispiel #1
0
def valid_dwolla(prompt):
    if valid_phone(prompt) == True:
        try:
            Dwolla = DwollaClientApp(DWOLLA_API_KEY, DWOLLA_API_SECRET)
            Dwolla.get_account_info(prompt)
            return True
        except:
            return False
    else:
        return False
Beispiel #2
0
  def get(self):
    Dwolla = DwollaClientApp(_keys.apiKey, _keys.apiSecret)
    oauth_return_url =  'http://' + self.request.host + '/dwolla/return'
    code = self.request.get("code")
    dwolla_token = Dwolla.get_oauth_token(code, redirect_uri=oauth_return_url)
    userid = self.userid

    dwolla = DwollaUser(dwolla_token).get_account_info()

    # Store the credentials in the data store using the userid as the key.
    creds = DwollaCredentials(userid = userid,
                              token = dwolla_token,
                              dwollaId = dwolla['Id']).put()
    logging.info('Successfully stored credentials for user: %s', userid)
    
    self.redirect_to('dwolla_pin')
Beispiel #3
0
  def _handle_locations_notification(self, data):
    """Handle locations notification."""
    Dwolla = DwollaClientApp(_keys.apiKey, _keys.apiSecret)

    location = self.mirror_service.locations().get(id=data['itemId']).execute()

    loc = 'dg-' + str(round(location.get('latitude'), 3)) + 'x' + str(round(location.get('longitude'), 3))
    logging.info('Your loc is ' + loc)

    items = self.mirror_service.timeline().list().execute()

    loc_exists = False

    for i in items['items']:
    #  FIXME: need to not send down items every 10 minutes 
    #   if i['bundleId'] == loc:
    #     loc_exists = True

    #   logging.info('parsed date')
    #   try:
    #     logging.info(parse_date(i['created']))
    #   except: 
    #     pass

    #   logging.info(type(i['created']))
    #   logging.info('current time plus 5:')
    #   logging.info(datetime.now() + timedelta(minutes=5))

    #   if i['created'] < (datetime.now() + timedelta(minutes=5)):
    #     loc_exists = False


    # if loc_exists == False:
      spots = Dwolla.get_nearby_spots()#lat=location.get('latitude'), lon=location.get('longitude'))
      for spot in spots:
        html = """<article><section class="align-center text-auto-size"><p>%s is nearby.</p></section><footer class="align-center">eyepay</footer></article>""" % (spot['Name'])
        logging.info('Inserting timeline item')
        
        body = {
            "html": html,
            "bundleId": loc,
            "menuItems": [],
            "notification": {
              "level": "DEFAULT"
            }
          }

        amt = 0
        while amt < 1:
          amt += 0.01
          id_text = str(amt) + "@" + spot['Id']
          body['menuItems'].append({
                                  "action": "CUSTOM",
                                  "id": id_text,
                                  "values": [{
                                    "displayName": "Pay $%s" % (amt),
                                    "iconUrl": "http://upload.wikimedia.org/wikipedia/commons/e/ec/Blank_50px.png"
                                  }]
                                })

        self.mirror_service.timeline().insert(body=body).execute()
Beispiel #4
0
# Include the Dwolla REST Client
from dwolla import DwollaClientApp

# Include any required keys
import _keys

# Instantiate a new Dwolla User client
# And, Seed a previously generated access token
Dwolla = DwollaClientApp(_keys.apiKey, _keys.apiSecret)

'''
    EXAMPLE 1: 
      Register a new Dwolla user
'''
user = Dwolla.register_user(email="*****@*****.**", password="******", firstName="Michael", lastName="Schonfeld", address="902 Broadway St.", address2="Floor 4", city="New York", state="NY", zip=10010, dateOfBirth="01/01/1960", phone="5551231234", pin="1234")
print(user)
Beispiel #5
0
# Include the Flask framework
from flask import Flask, url_for, request, redirect, render_template, session
app = Flask(__name__)

# Include the Dwolla REST Client
from dwolla import DwollaClientApp

# Include any required keys
import _keys

# Instantiate a new Dwolla User client
# And, Seed a previously generated access token
Dwolla = DwollaClientApp(_keys.apiKey, _keys.apiSecret)


'''
    STEP 1: 
      Create an authentication URL
      that the user will be redirected to
'''
@app.route("/")
def index():
    oauth_return_url = url_for('dwolla_oauth_return', _external=True) # Point back to this file/URL
    permissions = 'Send|Transactions|Balance|Request|Contacts|AccountInfoFull'
    authUrl = Dwolla.init_oauth_url(oauth_return_url, permissions)
    return 'To begin the OAuth process, send the user off to <a href="%s">%s</a>' % (authUrl, authUrl)


'''
    STEP 2: 
      Exchange the temporary code given
Beispiel #6
0
# Include the Dwolla REST Client
from dwolla import DwollaClientApp, DwollaUser

# Include any required keys
import _keys

# Instantiate a new Dwolla User client
# And, Sseed a previously generated access token
Dwolla = DwollaClientApp(_keys.apiKey, _keys.apiSecret)
DwollaUser = DwollaUser(_keys.token)
'''
    EXAMPLE 1: 
      Fetch account information for the
      account associated with the provided
      OAuth token
'''
me = DwollaUser.get_account_info()
print(me)
'''
    EXAMPLE 2: 
      Fetch basic account information
      for a given Dwolla ID
'''
me = Dwolla.get_account_info('812-626-8794')
print(me)
'''
    EXAMPLE 3: 
      Fetch basic account information
      for a given Email address
'''
me = Dwolla.get_account_info('*****@*****.**')
geocodeURL = 'http://maps.googleapis.com/maps/api/geocode/json?' + urllib.urlencode({'address': origin})
data = urllib.urlopen(geocodeURL).read()

# Parse JSON response for lat/lon pair
try: js = json.loads(str(data))
except: js = None
if 'status' not in js or js['status'] != 'OK':
    print '==== Failure To Retrieve ===='
    print data
    quit()
else:
    latVal = js['results'][0]['geometry']['location']['lat']
    lonVal = js['results'][0]['geometry']['location']['lng']

# Query Dwolla for spots near the address            
DwollaClient = DwollaClientApp(key, secret)

radius = 2
spots = DwollaClient.get_nearby_spots(latVal, lonVal, radius, maxHits)

# If there are fewer results than the user-specified maximum, query again over a 
# larger radius
while (len(spots) < maxHits) and (radius < 50):
    radius = radius * 5
    spots = DwollaClient.get_nearby_spots(latVal, lonVal, radius, maxHits)

# Output the results
print('The ' + str(len(spots)) + ' closest spots that accept Dwolla are:\n')
rVal = range(0,len(spots))
for index in rVal:
    # Convert the delta parameter (which seems to be Earth Central Angle in degrees) into miles
Beispiel #8
0
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from .settings import set_dwolla_env
set_dwolla_env()

from django.conf import settings
from dwolla import DwollaClientApp, DwollaGateway

if settings.DWOLLA_SANDBOX:
    KEY = 'sandbox'
    DWOLLA_ADMIN_ID = settings.DWOLLA_ACCOUNTS[KEY]['user_id']
    DWOLLA_ADMIN_APP = None
else:
    KEY = 'production'
    DWOLLA_ADMIN_ACCOUNT = settings.DWOLLA_ACCOUNTS['admin']
    DWOLLA_ADMIN_ID = DWOLLA_ADMIN_ACCOUNT['user_id']
    DWOLLA_ADMIN_APP = DwollaClientApp(DWOLLA_ADMIN_ACCOUNT['key'],
                                       DWOLLA_ADMIN_ACCOUNT['secret'])

DWOLLA_ACCOUNT = settings.DWOLLA_ACCOUNTS[KEY]
DWOLLA_APP = DwollaClientApp(DWOLLA_ACCOUNT['key'], DWOLLA_ACCOUNT['secret'])
if DWOLLA_ADMIN_APP is None:
    DWOLLA_ADMIN_APP = DWOLLA_APP
DWOLLA_GATE = DwollaGateway(DWOLLA_ACCOUNT['key'], DWOLLA_ACCOUNT['secret'])
Beispiel #9
0
# Include the Dwolla REST Client
from dwolla import DwollaClientApp, DwollaUser

# Include any required keys
import _keys

# Instantiate a new Dwolla User client
# And, Seed a previously generated access token
Dwolla = DwollaClientApp(_keys.apiKey, _keys.apiSecret)
DwollaUser = DwollaUser(_keys.token)

'''
    EXAMPLE 1: 
      Fetch account information for the
      account associated with the provided
      OAuth token
'''
me = DwollaUser.get_account_info()
print(me)


'''
    EXAMPLE 2: 
      Fetch basic account information
      for a given Dwolla ID
'''
me = Dwolla.get_account_info('812-626-8794')
print(me)


'''