def create_link_token_for_payment(): global payment_id try: request = PaymentInitiationRecipientCreateRequest( name='John Doe', bacs=NullableRecipientBACS(account='26207729', sort_code='560029'), address=PaymentInitiationAddress(street=['street name 999'], city='city', postal_code='99999', country='GB')) response = client.payment_initiation_recipient_create(request) recipient_id = response['recipient_id'] request = PaymentInitiationPaymentCreateRequest( recipient_id=recipient_id, reference='TestPayment', amount=Amount(currency='GBP', value=100.00)) response = client.payment_initiation_payment_create(request) pretty_print_response(response) payment_id = response['payment_id'] request = LinkTokenCreateRequest( products=[Products('payment_initiation')], client_name='Plaid Test', country_codes=[CountryCode('GB')], language='en', user=LinkTokenCreateRequestUser(client_user_id=str(time.time())), payment_initiation=LinkTokenCreateRequestPaymentInitiation( payment_id=payment_id)) response = client.link_token_create(request) pretty_print_response(response.to_dict()) return jsonify(response.to_dict()) except plaid.ApiException as e: return json.loads(e.body)
def create_link_token_for_payment(): global payment_id try: request = PaymentInitiationRecipientCreateRequest( name='John Doe', bacs=RecipientBACSNullable(account='26207729', sort_code='560029'), address=PaymentInitiationAddress(street=['street name 999'], city='city', postal_code='99999', country='GB')) response = client.payment_initiation_recipient_create(request) recipient_id = response['recipient_id'] request = PaymentInitiationPaymentCreateRequest( recipient_id=recipient_id, reference='TestPayment', amount=PaymentAmount(PaymentAmountCurrency('GBP'), value=100.00)) response = client.payment_initiation_payment_create(request) pretty_print_response(response.to_dict()) payment_id = response['payment_id'] linkRequest = LinkTokenCreateRequest( products=[Products('payment_initiation')], client_name='Plaid Test', country_codes=list( map(lambda x: CountryCode(x), PLAID_COUNTRY_CODES)), language='en', user=LinkTokenCreateRequestUser(client_user_id=str(time.time())), payment_initiation=LinkTokenCreateRequestPaymentInitiation( payment_id=payment_id)) if PLAID_REDIRECT_URI != None: linkRequest['redirect_uri'] = PLAID_REDIRECT_URI linkResponse = client.link_token_create(linkRequest) pretty_print_response(linkResponse.to_dict()) return jsonify(linkResponse.to_dict()) except plaid.ApiException as e: return json.loads(e.body)
# at https://dashboard.plaid.com/team/api. PLAID_REDIRECT_URI = empty_to_none('PLAID_REDIRECT_URI') configuration = plaid.Configuration(host=plaid.Environment.Sandbox, api_key={ 'clientId': PLAID_CLIENT_ID, 'secret': PLAID_SECRET, 'plaidVersion': '2020-09-14' }) api_client = plaid.ApiClient(configuration) client = plaid_api.PlaidApi(api_client) products = [] for product in PLAID_PRODUCTS: products.append(Products(product)) # We store the access_token in memory - in production, store it in a secure # persistent data store. access_token = None # The payment_id is only relevant for the UK Payment Initiation product. # We store the payment_id in memory - in production, store it in a secure # persistent data store. payment_id = None item_id = None @app.route('/api/info', methods=['POST']) def info(): global access_token