Esempio n. 1
0
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 get_institution(access_token):
    request = ItemGetRequest(access_token=access_token)
    response = client.item_get(request)
    request = InstitutionsGetByIdRequest(
        institution_id=response['item']['institution_id'],
        country_codes=[CountryCode('US')]
    )
    institution_response = client.institutions_get_by_id(request)
    return institution_response
Esempio n. 3
0
def create_link_token():
    try:
        request = LinkTokenCreateRequest(
            products=products,
            client_name="Plaid Quickstart",
            country_codes=[CountryCode('US')],
            language='en',
            user=LinkTokenCreateRequestUser(client_user_id=str(time.time())))

        # create link token
        response = client.link_token_create(request)
        return jsonify(response.to_dict())
    except plaid.ApiException as e:
        return json.loads(e.body)
Esempio n. 4
0
def create_link_token():
    try:
        request = LinkTokenCreateRequest(
            products=products,
            client_name="Plaid Quickstart",
            country_codes=list(
                map(lambda x: CountryCode(x), PLAID_COUNTRY_CODES)),
            language='en',
            user=LinkTokenCreateRequestUser(client_user_id=str(time.time())))
        if PLAID_REDIRECT_URI != None:
            request['redirect_uri'] = PLAID_REDIRECT_URI
    # create link token
        response = client.link_token_create(request)
        return jsonify(response.to_dict())
    except plaid.ApiException as e:
        return json.loads(e.body)
Esempio n. 5
0
def item():
    try:
        request = ItemGetRequest(access_token=access_token)
        response = client.item_get(request)
        request = InstitutionsGetByIdRequest(
            institution_id=response['item']['institution_id'],
            country_codes=[CountryCode('US')])
        institution_response = client.institutions_get_by_id(request)
        pretty_print_response(response.to_dict())
        pretty_print_response(institution_response.to_dict())
        return jsonify({
            'error':
            None,
            'item':
            response.to_dict()['item'],
            'institution':
            institution_response.to_dict()['institution']
        })
    except plaid.ApiException as e:
        error_response = format_error(e)
        return jsonify(error_response)
Esempio n. 6
0
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)