2
2
# Read env vars from .env file
3
3
from plaid .exceptions import ApiException
4
4
from plaid .model .payment_amount import PaymentAmount
5
+ from plaid .model .payment_amount_currency import PaymentAmountCurrency
5
6
from plaid .model .products import Products
6
7
from plaid .model .country_code import CountryCode
7
8
from plaid .model .recipient_bacs_nullable import RecipientBACSNullable
@@ -167,7 +168,7 @@ def create_link_token_for_payment():
167
168
recipient_id = recipient_id ,
168
169
reference = 'TestPayment' ,
169
170
amount = PaymentAmount (
170
- currency = 'GBP' ,
171
+ PaymentAmountCurrency ( 'GBP' ) ,
171
172
value = 100.00
172
173
)
173
174
)
@@ -176,7 +177,7 @@ def create_link_token_for_payment():
176
177
)
177
178
pretty_print_response (response .to_dict ())
178
179
payment_id = response ['payment_id' ]
179
- request = LinkTokenCreateRequest (
180
+ linkRequest = LinkTokenCreateRequest (
180
181
products = [Products ('payment_initiation' )],
181
182
client_name = 'Plaid Test' ,
182
183
country_codes = list (map (lambda x : CountryCode (x ), PLAID_COUNTRY_CODES )),
@@ -188,9 +189,12 @@ def create_link_token_for_payment():
188
189
payment_id = payment_id
189
190
)
190
191
)
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 ())
194
198
except plaid .ApiException as e :
195
199
return json .loads (e .body )
196
200
@@ -203,12 +207,13 @@ def create_link_token():
203
207
client_name = "Plaid Quickstart" ,
204
208
country_codes = list (map (lambda x : CountryCode (x ), PLAID_COUNTRY_CODES )),
205
209
language = 'en' ,
206
- redirect_uri = PLAID_REDIRECT_URI ,
207
210
user = LinkTokenCreateRequestUser (
208
211
client_user_id = str (time .time ())
209
212
)
210
213
)
211
- # create link token
214
+ if PLAID_REDIRECT_URI != None :
215
+ request ['redirect_uri' ]= PLAID_REDIRECT_URI
216
+ # create link token
212
217
response = client .link_token_create (request )
213
218
return jsonify (response .to_dict ())
214
219
except plaid .ApiException as e :
0 commit comments