Esempio n. 1
0
def dwolla_charge(sender, amount, order, event, pin, source):
    """
    Charges to dwolla and returns a charge transaction.
    """
    dwolla_prep(event.api_type)
    access_token = dwolla_get_token(sender, event.api_type)
    organization_access_token = dwolla_get_token(event.organization, event.api_type)
    if event.api_type == LIVE:
        destination = event.organization.dwolla_user_id
    else:
        destination = event.organization.dwolla_test_user_id

    user_charge_id = transactions.send(
        destinationid=destination,
        amount=amount,
        alternate_token=access_token,
        alternate_pin=pin,
        params={
            "facilitatorAmount": float(get_fee(event, amount)),
            "fundsSource": source,
            "notes": "Order {} for {}".format(order.code, event.name),
        },
    )
    # Charge id returned by send_funds is the transaction ID
    # for the user; the event has a different transaction ID.
    # But we can use this one to get that one.

    event_charge = transactions.info(tid=str(user_charge_id), alternate_token=organization_access_token)

    return event_charge
 def testsend(self):
     transactions.send('812-111-1234',
                       5.00,
                       a='parameter',
                       alternate_token='AN OAUTH TOKEN',
                       dwollaparse='dwolla')
     transactions.r._post.assert_any_call(
         '/transactions/send', {
             'a': 'parameter',
             'destinationId': '812-111-1234',
             'amount': 5.0,
             'pin': 1234
         }, {
             'alternate_token': 'AN OAUTH TOKEN',
             'dwollaparse': 'dwolla'
         })
Esempio n. 3
0
def dwolla_charge(account, amount, order, event, pin, source):
    """
    Charges to dwolla and returns a charge transaction.
    """
    if amount < 0:
        raise InvalidAmountException('Cannot charge an amount less than zero.')
    if account.api_type != event.api_type:
        raise ValueError("Account and event API types do not match.")
    org_account = event.organization.get_dwolla_account(event.api_type)
    if not org_account or not org_account.is_connected():
        raise ValueError("Event is not connected to dwolla.")
    dwolla_prep(account.api_type)
    access_token = account.get_token()
    organization_access_token = org_account.get_token()
    destination = org_account.user_id

    user_charge_id = transactions.send(
        destinationid=destination,
        amount=amount,
        alternate_token=access_token,
        alternate_pin=pin,
        params={
            'facilitatorAmount': float(get_fee(event, amount)),
            'fundsSource': source,
            'notes': "Order {} for {}".format(order.code, event.name),
        },
    )
    # Charge id returned by send_funds is the transaction ID
    # for the user; the event has a different transaction ID.
    # But we can use this one to get that one.

    event_charge = transactions.info(tid=str(user_charge_id),
                                     alternate_token=organization_access_token)

    return event_charge
Esempio n. 4
0
  The following is a quick-start example for the transaction endpoints.
'''

from dwolla import transactions, constants

# Configure the library (change these)
constants.sandbox=False

constants.client_id = "zbDwIC0dWCVU7cQtfvGwVwVjvxwQfjaTgkVi+FZOmKqPBzK5JG"
constants.client_secret = "ckmgwJz9h/fZ09unyXxpupCyrmAMe0bnUiMHF/0+SDaR9RHe99"
constants.access_token = "aK6DdCVlIsR1hKvTbp8VCwnvci8cwaTLlW9edtbHJVmKoopnoe"
constants.pin = 1234

# Example 1: Send $5.50 to a Dwolla ID.

print transactions.send('812-197-4121', 5.50)
# Return:
# 113533 (Sender's transaction ID)


# Example 2: List transactions for the user
# associated with the current OAuth token.

print transactions.get()
# Return:
# [
#     {
#         "Id": 113533,
#         "Amount": 5.50,
#         "Date": "2014-12-13T05:07:15Z",
#         "Type": "money_sent",
Esempio n. 5
0
 def testsend(self):
     transactions.send('812-111-1234', 5.00, a='parameter', alternate_token='AN OAUTH TOKEN', dwollaparse='dwolla')
     transactions.r._post.assert_any_call('/transactions/send', {'a': 'parameter', 'destinationId': '812-111-1234', 'amount': 5.0, 'pin': 1234}, {'alternate_token':'AN OAUTH TOKEN', 'dwollaparse':'dwolla'})
Esempio n. 6
0
    # which has already been processed.
    old_tx_ids = [i for sub in Reflector.select(Reflector.tx).order_by(Reflector.id.desc()).tuples() for i in sub]

    print "reflec2r: Fetching transactions from Dwolla."

    # Query Dwolla for transactions
    txlist = t.get(types='money_received', limit=200) \
        + t.get(types='money_received', limit=200, skip=200) \
        + t.get(types='money_received', limit=200, skip=400) \
        + t.get(types='money_received', limit=200, skip=600) \
        + t.get(types='money_received', limit=200, skip=800) \

    # Reimburse those that qualify
    for tx in txlist:
        if (tx['Id'] not in old_tx_ids) and (tx['Status'] == 'processed') and (tx['Notes'] != "reflec2r/do-not-reimburse"):
            r = t.send(tx['Source']['Id'], tx['Amount'])
            Reflector.create(amount=tx['Amount'], date=datetime.datetime.now(), refund=r, tx=tx['Id']).save()
            print "reflec2r: Successfully sent $" + str(tx['Amount']) + " to " + str(tx['Source']['Id'])
        else:
            print "reflec2r: Skipping transaction #" + str(tx['Id']) + ", already reflected or flagged."

    # Unlock mutex, exit
    shitty_mutex.value = 0
    shitty_mutex.save()

    print "reflec2r: Gracefully executed, quitting application."
    exit(0)

except Exception as e:
    print "reflec2r: Execution failed on " + str(datetime.datetime.now()) + ", dumping exception, unlocking and quitting."
    print "reflec2r: " + e.message
Esempio n. 7
0
 def testsend(self):
     transactions.send('812-111-1234', 5.00, {'a': 'parameter'})
     transactions.r._post.assert_any_call('/transactions/send/', {'a': 'parameter', 'destinationId': '812-111-1234', 'oauth_token': 'AN OAUTH TOKEN', 'amount': 5.0, 'pin': 1234})
Esempio n. 8
0
  The following is a quick-start example for the transaction endpoints.
'''

from dwolla import transactions, constants

# Configure the library (change these)
constants.sandbox = False

constants.client_id = "zbDwIC0dWCVU7cQtfvGwVwVjvxwQfjaTgkVi+FZOmKqPBzK5JG"
constants.client_secret = "ckmgwJz9h/fZ09unyXxpupCyrmAMe0bnUiMHF/0+SDaR9RHe99"
constants.access_token = "aK6DdCVlIsR1hKvTbp8VCwnvci8cwaTLlW9edtbHJVmKoopnoe"
constants.pin = 1234

# Example 1: Send $5.50 to a Dwolla ID.

print(transactions.send('812-197-4121', 5.50))
# Return:
# 113533 (Sender's transaction ID)

# Example 2: List transactions for the user
# associated with the current OAuth token.

print(transactions.get())
# Return:
# [
#     {
#         "Id": 113533,
#         "Amount": 5.50,
#         "Date": "2014-12-13T05:07:15Z",
#         "Type": "money_sent",
#         "UserType": "Email",