Skip to content

Commit 59b65df

Browse files
add redirect logic (#341)
* add redirect logic * remove console logs
1 parent 6641a16 commit 59b65df

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

python/server.py

+12-7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# Read env vars from .env file
33
from plaid.exceptions import ApiException
44
from plaid.model.payment_amount import PaymentAmount
5+
from plaid.model.payment_amount_currency import PaymentAmountCurrency
56
from plaid.model.products import Products
67
from plaid.model.country_code import CountryCode
78
from plaid.model.recipient_bacs_nullable import RecipientBACSNullable
@@ -167,7 +168,7 @@ def create_link_token_for_payment():
167168
recipient_id=recipient_id,
168169
reference='TestPayment',
169170
amount=PaymentAmount(
170-
currency='GBP',
171+
PaymentAmountCurrency('GBP'),
171172
value=100.00
172173
)
173174
)
@@ -176,7 +177,7 @@ def create_link_token_for_payment():
176177
)
177178
pretty_print_response(response.to_dict())
178179
payment_id = response['payment_id']
179-
request = LinkTokenCreateRequest(
180+
linkRequest = LinkTokenCreateRequest(
180181
products=[Products('payment_initiation')],
181182
client_name='Plaid Test',
182183
country_codes=list(map(lambda x: CountryCode(x), PLAID_COUNTRY_CODES)),
@@ -188,9 +189,12 @@ def create_link_token_for_payment():
188189
payment_id=payment_id
189190
)
190191
)
191-
response = client.link_token_create(request)
192-
pretty_print_response(response.to_dict())
193-
return jsonify(response.to_dict())
192+
193+
if PLAID_REDIRECT_URI!=None:
194+
linkRequest['redirect_uri']=PLAID_REDIRECT_URI
195+
linkResponse = client.link_token_create(linkRequest)
196+
pretty_print_response(linkResponse.to_dict())
197+
return jsonify(linkResponse.to_dict())
194198
except plaid.ApiException as e:
195199
return json.loads(e.body)
196200

@@ -203,12 +207,13 @@ def create_link_token():
203207
client_name="Plaid Quickstart",
204208
country_codes=list(map(lambda x: CountryCode(x), PLAID_COUNTRY_CODES)),
205209
language='en',
206-
redirect_uri=PLAID_REDIRECT_URI,
207210
user=LinkTokenCreateRequestUser(
208211
client_user_id=str(time.time())
209212
)
210213
)
211-
# create link token
214+
if PLAID_REDIRECT_URI!=None:
215+
request['redirect_uri']=PLAID_REDIRECT_URI
216+
# create link token
212217
response = client.link_token_create(request)
213218
return jsonify(response.to_dict())
214219
except plaid.ApiException as e:

0 commit comments

Comments
 (0)