-
Notifications
You must be signed in to change notification settings - Fork 21
/
hello_payments.py
52 lines (52 loc) · 1.94 KB
/
hello_payments.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# # -*- coding: utf-8 -*-
# from requests_oauthlib import OAuth1Session
# # oauth flow in simple words: http://pyoauth.readthedocs.org/en/latest/guides/oauth1.html
#
# client_key = "yourcustomerkey"
# client_secret = "yourcustomersecret"
#
# base_url = "https://apisandbox.openbankproject.com"
# request_token_url = base_url + "/oauth/initiate"
# authorization_base_url = base_url + "/oauth/authorize"
# access_token_url = base_url + "/oauth/token"
#
# openbank = OAuth1Session(client_key, client_secret=client_secret, callback_uri='http://127.0.0.1/cb')
# openbank.fetch_request_token(request_token_url)
#
# authorization_url = openbank.authorization_url(authorization_base_url)
# print 'Please go here and authorize:', authorization_url
#
# redirect_response = raw_input('Paste the full redirect URL here:')
# openbank.parse_authorization_response(redirect_response.strip())
# openbank.fetch_access_token(access_token_url)
#
# #get accounts for a specific bank
# our_bank = 'rbs'
# print "Available accounts"
# r = openbank.get(u"{}/obp/v1.2.1/banks/{}/accounts/private".format(base_url, our_bank))
#
# accounts = r.json()['accounts']
# for a in accounts:
# print a['id']
#
# #just picking first account
# our_account = accounts[0]['id']
#
# print "Get owner transactions"
# r = openbank.get(u"{}/obp/v1.2.1/banks/{}/accounts/{}/owner/transactions".format(base_url,
# our_bank,
# our_account), headers= {'obp_limit': '25'})
# transactions = r.json()['transactions']
# print "Got {} transactions".format(len(transactions))
#
# print "Transfer some money"
# send_to = {"bank": "rbs", "account": "savings-kids-john"}
# payload = '{"account_id": "' + send_to['account'] +'", "bank_id": "' + send_to['bank'] + '", "amount": "10" }'
# headers = {'content-type': 'application/json'}
# r = openbank.post(u"{}/obp/v1.2.1/banks/{}/accounts/{}/owner/transactions".format(base_url,
# our_bank, our_account), data=payload, headers=headers)
#
# print r
# print r.json()
#
#