diff --git a/python/account_details.py b/python/account_details.py index 5abf85b..8e982cb 100644 --- a/python/account_details.py +++ b/python/account_details.py @@ -7,8 +7,8 @@ CLIENT_SECRET = 'your client secret here' if __name__ == '__main__': - account_id = 'FI6593857450293470-EUR' # try changing this - endpoint = 'v2/accounts/{}'.format(account_id) + account_id = 'DK20301544117544-DKK' # try changing this + endpoint = 'v3/accounts/{}'.format(account_id) access_token = generate_access_token() headers = { 'X-IBM-Client-Id': CLIENT_ID, diff --git a/python/generate_access_token.py b/python/generate_access_token.py index 9be1818..8465c42 100644 --- a/python/generate_access_token.py +++ b/python/generate_access_token.py @@ -4,7 +4,7 @@ API_URI = 'https://api.nordeaopenbanking.com/' CLIENT_ID = 'your client id here' CLIENT_SECRET = 'your client secret here' -REDIRECT_URI = 'http://httpbin.org/get' +REDIRECT_URI = 'http://httpbin.org/' """ This is an example how to generate the access token from the scratch. @@ -14,11 +14,14 @@ """ def get_code(): - endpoint = 'v1/authentication' + endpoint = 'v3/authorize' payload = { 'client_id': CLIENT_ID, - 'redirect_uri': REDIRECT_URI, - 'state': '' + 'redirect_uri': REDIRECT_URI + "anything", + 'state': 'oauth2', + 'scope': 'ACCOUNTS_BASIC,ACCOUNTS_BALANCES,ACCOUNTS_DETAILS,ACCOUNTS_TRANSACTIONS,PAYMENTS_MULTIPLE', + 'duration': '1234', + 'country': 'DK' } r = requests.get(API_URI + endpoint, params=payload) if not r.status_code == requests.codes.ok: @@ -29,17 +32,21 @@ def get_code(): def get_access_token(code): - endpoint = 'v1/authentication/access_token' + endpoint = 'v3/authorize/token' headers = { 'Content-Type': 'application/x-www-form-urlencoded', 'X-IBM-Client-Id': CLIENT_ID, - 'X-IBM-Client-Secret': CLIENT_SECRET + 'X-IBM-Client-Secret': CLIENT_SECRET, + 'cache-control' : "no-cache", + 'Accept':'application/json' } payload = { 'code': code, - 'redirect_uri': REDIRECT_URI + 'redirect_uri': REDIRECT_URI + "anything", + 'grant_type': 'authorization_code' } + r = requests.post(API_URI + endpoint, data=payload, headers=headers) if not r.status_code == requests.codes.ok: raise Exception(r.text) diff --git a/python/get_payments.py b/python/get_payments.py index a94b850..4418f59 100644 --- a/python/get_payments.py +++ b/python/get_payments.py @@ -7,7 +7,8 @@ CLIENT_SECRET = 'your client secret here' if __name__ == '__main__': - endpoint = 'v2/payments/sepa/' + account_id = 'DK20301544117544-DKK' # try changing this + endpoint = 'v3/accounts/{}/transactions'.format(account_id) access_token = generate_access_token() headers = { 'X-IBM-Client-Id': CLIENT_ID, diff --git a/python/initiate_payment.py b/python/initiate_payment.py index a766500..3382e11 100644 --- a/python/initiate_payment.py +++ b/python/initiate_payment.py @@ -8,7 +8,7 @@ CLIENT_SECRET = 'your client secret here' if __name__ == '__main__': - endpoint = 'v2/payments/sepa' + endpoint = 'v3/payments/domestic' access_token = generate_access_token() headers = { 'X-IBM-Client-Id': CLIENT_ID, @@ -17,31 +17,39 @@ 'X-Response-Scenarios': 'AuthorizationSkipAccessControl', 'content-type': 'application/json' } + payload = { - "amount": "621000.45", - "creditor": { - "account": { - "_type": "IBAN", - "value": "FI1350001520000081" - }, - "message": "This is a message, 123!", - "name": "Beneficiary name", - "reference": { - "_type": "RF", - "value": "RF18539007547034" - } - }, - "currency": "EUR", - "debtor": { - "_accountId": "FI6593857450293470-EUR" - } + "amount" : "100.12", + "currency" : "DKK", + "debtor" : { + "account" : { + "value" : "DK6120301544118028", + "_type" : "IBAN", + "currency" : "DKK" + } + }, + "creditor" : { + "account" : { + "currency": "DKK", + "value" : "DK3420301544117544", + "_type" : "IBAN" + }, + "name" : "Creditor name", + "message" : "wow", + "reference" : { + "value" : "RF11223344", + "_type" : "RF" + } + } } r = requests.post(API_URI + endpoint, headers=headers, data=json.dumps(payload)) + if not r.status_code == requests.codes.created: raise Exception(r.text) response = r.json() payment_id = response['response']['_id'] + # print the payment id print(payment_id) diff --git a/python/list_accounts.py b/python/list_accounts.py index 93eacc9..d4fe73b 100644 --- a/python/list_accounts.py +++ b/python/list_accounts.py @@ -11,7 +11,7 @@ # get valid access token access_token = generate_access_token() # endpoint we query - endpoint = 'v2/accounts' + endpoint = 'v3/accounts' # set headers and make the request headers = { 'X-IBM-Client-Id': CLIENT_ID, diff --git a/wow.txt b/wow.txt new file mode 100644 index 0000000..e69de29