Skip to content

Commit c92aa93

Browse files
committed
[ADD] virtual beneficiary option
1 parent 7165fbc commit c92aa93

35 files changed

Lines changed: 396 additions & 250 deletions

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.1.0
1+
1.2.0

examples/ais/accounts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
print("Searching customer accounts...")
1414

15-
customer_id = 'f1923614953cb0e1f1da8b5c016fd5a7'
15+
customer_id = 'a95784c3ddfed8f3f20790c4ad338569'
1616

1717
resp = fintecture.Customer.get_accounts(customer_id)
1818

examples/ais/connect.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
print("Searching URL to connect with AIS...")
99

10-
redirect_uri = 'https://webhook.site/5940c656-7fd3-40a0-ad41-9cfba1e986f3'
10+
redirect_uri = 'https://webhook.site/4ff3f300-c82c-4b4f-b92e-d0691656a663'
1111

1212
resp = fintecture.AIS.connect(
1313
app_id=os.environ.get("FINTECTURE_APP_ID"),

examples/ais/oauth.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
print("After user connect him account you will receive in your webhook a code for authenticate")
1313

14-
code = 'ec2c1ee4d1f40f4db60ea30f4ea4769d'
14+
code = '5ebc08acf13a866a0a97c2a37013cb28'
1515
token_resp = fintecture.AIS.oauth(code=code)
1616

1717
fintecture.access_token = token_resp['access_token']

examples/pis/connect.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@
44

55
import fintecture
66

7-
87
fintecture.app_id = os.environ.get("FINTECTURE_APP_ID")
98
fintecture.app_secret = os.environ.get("FINTECTURE_APP_SECRET")
109
fintecture.private_key = os.environ.get("FINTECTURE_PRIVATE_KEY")
1110

12-
1311
try:
1412
print("Searching URL to connect with PIS...")
1513

@@ -23,6 +21,7 @@
2321

2422
resp_connect = fintecture.PIS.connect(
2523
state="1234",
24+
with_virtualbeneficiary=True,
2625
meta={
2726
'psu_name': 'M. John Doe',
2827
'psu_email': 'john@doe.com',
@@ -35,13 +34,17 @@
3534
'city': 'Gotham',
3635
'country': 'FR',
3736
},
37+
"reconciliation": {
38+
"level": "payment_session",
39+
"match_amount": True
40+
}
3841
},
3942
data={
40-
'type': 'SEPA',
43+
'type': 'connect',
4144
'attributes': {
4245
'amount': '550.60',
4346
'currency': 'EUR',
44-
'communication': 'Order 15654'
47+
'communication': 'Order 15654',
4548
}
4649
}
4750
)

examples/pis/request_pays.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
resp_request_to_pay = fintecture.PIS.request_to_pay(
6363
redirect_uri,
6464
language='es',
65+
state='85321',
6566
meta={
6667
'psu_name': 'M. John Doe',
6768
'psu_email': 'john@doe.com',
@@ -95,4 +96,4 @@
9596
# session_id fee8b638c1c44af1a4a2dd7dd781ecf8
9697
# status payment_created
9798
# provider cmcifrpp
98-
# state 1234
99+
# state 85321

fintecture/api_resources/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1+
# File generated from our OpenAPI spec
12
from __future__ import absolute_import, division, print_function
23

34
# flake8: noqa
45

5-
from fintecture.api_resources.error_object import ErrorObject
6+
from fintecture.api_resources.error_object import ErrorObject, OAuthErrorObject
67
from fintecture.api_resources.list_object import ListObject
78
from fintecture.api_resources.search_result_object import SearchResultObject
89

10+
from fintecture.api_resources import identity
911
from fintecture.api_resources import test_helpers
1012

1113
from fintecture.api_resources.ais import AIS

fintecture/api_resources/abstract/api_resource.py

Lines changed: 61 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,21 @@ def _request(
4949
self,
5050
method_,
5151
url_,
52-
app_id=None,
52+
api_key=None,
53+
idempotency_key=None,
5354
fintecture_version=None,
55+
fintecture_account=None,
5456
headers=None,
5557
params=None,
5658
):
5759
obj = FintectureObject._request(
5860
self,
5961
method_,
6062
url_,
61-
app_id,
63+
api_key,
64+
idempotency_key,
6265
fintecture_version,
66+
fintecture_account,
6367
headers,
6468
params,
6569
)
@@ -77,7 +81,9 @@ def _request_and_refresh(
7781
method_,
7882
url_,
7983
app_id=None,
84+
idempotency_key=None,
8085
fintecture_version=None,
86+
fintecture_account=None,
8187
headers=None,
8288
params=None,
8389
):
@@ -86,7 +92,9 @@ def _request_and_refresh(
8692
method_,
8793
url_,
8894
app_id,
95+
idempotency_key,
8996
fintecture_version,
97+
fintecture_account,
9098
headers,
9199
params,
92100
)
@@ -102,32 +110,69 @@ def _static_request(
102110
method_,
103111
url_,
104112
app_id=None,
113+
idempotency_key=None,
105114
fintecture_version=None,
115+
fintecture_account=None,
106116
params=None,
107117
):
108118
params = None if params is None else params.copy()
119+
idempotency_key = util.read_special_variable(
120+
params, "idempotency_key", idempotency_key
121+
)
109122
fintecture_version = util.read_special_variable(
110123
params, "fintecture_version", fintecture_version
111124
)
112-
fintecture_app_id = util.read_special_variable(
113-
params, "app_id", app_id
114-
)
115-
fintecture_app_secret = util.read_special_variable(
116-
params, "app_secret", None
117-
)
118-
fintecture_private_key = util.read_special_variable(
119-
params, "private_key", None
125+
fintecture_account = util.read_special_variable(
126+
params, "fintecture_account", fintecture_account
120127
)
121128
headers = util.read_special_variable(params, "headers", None)
122129

123130
requestor = api_requestor.APIRequestor(
124-
app_id=fintecture_app_id,
125-
app_secret=fintecture_app_secret,
126-
private_key=fintecture_private_key,
127-
api_version=fintecture_version,
131+
app_id, api_version=fintecture_version, account=fintecture_account
128132
)
129133

130-
response, my_app_id = requestor.request(method_, url_, params, headers)
134+
if idempotency_key is not None:
135+
headers = {} if headers is None else headers.copy()
136+
headers.update(util.populate_headers(idempotency_key))
137+
138+
response, api_key = requestor.request(method_, url_, params, headers)
131139
return util.convert_to_fintecture_object(
132-
response, my_app_id, fintecture_version, params
140+
response, api_key, fintecture_version, fintecture_account, params
141+
)
142+
143+
# The `method_` and `url_` arguments are suffixed with an underscore to
144+
# avoid conflicting with actual request parameters in `params`.
145+
@classmethod
146+
def _static_request_stream(
147+
cls,
148+
method_,
149+
url_,
150+
api_key=None,
151+
idempotency_key=None,
152+
fintecture_version=None,
153+
fintecture_account=None,
154+
params=None,
155+
):
156+
params = None if params is None else params.copy()
157+
api_key = util.read_special_variable(params, "api_key", api_key)
158+
idempotency_key = util.read_special_variable(
159+
params, "idempotency_key", idempotency_key
160+
)
161+
fintecture_version = util.read_special_variable(
162+
params, "fintecture_version", fintecture_version
133163
)
164+
fintecture_account = util.read_special_variable(
165+
params, "fintecture_account", fintecture_account
166+
)
167+
headers = util.read_special_variable(params, "headers", None)
168+
169+
requestor = api_requestor.APIRequestor(
170+
api_key, api_version=fintecture_version, account=fintecture_account
171+
)
172+
173+
if idempotency_key is not None:
174+
headers = {} if headers is None else headers.copy()
175+
headers.update(util.populate_headers(idempotency_key))
176+
177+
response, _ = requestor.request_stream(method_, url_, params, headers)
178+
return response

fintecture/api_resources/abstract/createable_api_resource.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,18 @@ class CreateableAPIResource(APIResource):
77
@classmethod
88
def create(
99
cls,
10-
app_id=None,
10+
api_key=None,
11+
idempotency_key=None,
1112
fintecture_version=None,
13+
fintecture_account=None,
1214
**params
1315
):
1416
return cls._static_request(
1517
"post",
1618
cls.class_url(),
17-
app_id,
19+
api_key,
20+
idempotency_key,
1821
fintecture_version,
22+
fintecture_account,
1923
params,
2024
)

fintecture/api_resources/abstract/custom_method.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
from fintecture.six.moves.urllib.parse import quote_plus
55

66

7-
def custom_method(name, http_verb, http_path=None):
8-
if http_verb not in ["get", "post", "patch", "delete"]:
7+
def custom_method(name, http_verb, http_path=None, is_streaming=False):
8+
if http_verb not in ["get", "post", "delete"]:
99
raise ValueError(
10-
"Invalid http_verb: %s. Must be one of 'get', 'post', 'patch' or 'delete'"
10+
"Invalid http_verb: %s. Must be one of 'get', 'post' or 'delete'"
1111
% http_verb
1212
)
1313
if http_path is None:
@@ -29,7 +29,18 @@ def custom_method_request(cls, sid, **params):
2929

3030
return obj
3131

32-
class_method_impl = classmethod(custom_method_request)
32+
def custom_method_request_stream(cls, sid, **params):
33+
url = "%s/%s/%s" % (
34+
cls.class_url(),
35+
quote_plus(util.utf8(sid)),
36+
http_path,
37+
)
38+
return cls._static_request_stream(http_verb, url, params=params)
39+
40+
if is_streaming:
41+
class_method_impl = classmethod(custom_method_request_stream)
42+
else:
43+
class_method_impl = classmethod(custom_method_request)
3344

3445
existing_method = getattr(cls, name, None)
3546
if existing_method is None:

0 commit comments

Comments
 (0)