import os
from synapse_pay_rest import Client
args = {
'client_id': os.environ['TEST_CLIENT_ID'], # your client id
'client_secret': os.environ['TEST_CLIENT_SECRET'], # your client secret
'fingerprint': 'user_fingerprint',
'ip_address': '127.0.0.1', # user's IP
'development_mode': True, # (optional) default False
'logging': False # (optional) logs to stdout if True
}
client = Client(**args)
from synapse_pay_rest import User
options = {
'page': 1,
'per_page': 20,
'query': 'Steven' # name/email substring
}
users = User.all(client, **options)
user = User.by_id(client, '57e97ab786c2737f4ccd4dc1')
optional:
user = User.by_id(client, '57e97ab786c2737f4ccd4dc1', full_dehydrate='yes')
Example of user response with full_dehydrate:
**Please note: if full_dehydrate='no', some fields will return as 'None'
user.base_documents[0] =
{
'user': "<class 'synapse_pay_rest.models.users.user.User'>(id=592f1dfa8384540026e39a95)",
'id': '189d2fc37c1ee5694aa62f302bcd7c0efaae2c0229f45bfc8bb3470f6f7ab92a',
'name': 'Charlie Brown',
'email': '[email protected]',
'phone_number': '111-111-1111',
'ip': '::1',
'alias': 'Woof Woof',
'entity_type': 'M',
'entity_scope': 'Arts & Entertainment',
'birth_day': 2,
'birth_month': 5,
'birth_year': 1989,
'address_street': '170 St Germain Ave',
'address_city': 'SF',
'address_subdivision': 'CA',
'address_postal_code': '94114',
'address_country_code': 'US',
'screening_results': {
'561': 'NO_MATCH',
'aucl': 'NO_MATCH',
'concern_location': 'NO_MATCH',
'dpl': 'NO_MATCH',
'dtc': 'NO_MATCH',
'el': 'NO_MATCH',
'eucl': 'NO_MATCH',
'fatf_non_cooperative_jurisdiction': 'NO_MATCH',
'fbi_bank_robbers': 'NO_MATCH',
'fbi_counter_intelligence': 'NO_MATCH',
'fbi_crimes_against_children': 'NO_MATCH',
'fbi_criminal_enterprise_investigations': 'NO_MATCH',
'fbi_cyber': 'NO_MATCH',
'fbi_domestic_terrorism': 'NO_MATCH',
'fbi_human_trafficking': 'NO_MATCH',
'fbi_murders': 'NO_MATCH',
'fbi_violent_crimes': 'NO_MATCH',
'fbi_wanted_terrorists': 'NO_MATCH',
'fbi_white_collar': 'NO_MATCH',
'fincen_red_list': 'NO_MATCH',
'fse': 'NO_MATCH',
'fto_sanctions': 'NO_MATCH',
'futures_sanctions': 'NO_MATCH',
'hkma_sanctions': 'NO_MATCH',
'hm_treasury_sanctions': 'NO_MATCH',
'isn': 'NO_MATCH',
'mas_sanctions': 'NO_MATCH',
'monitored_location': 'NO_MATCH',
'ns-isa': 'NO_MATCH',
'ofac_561_list': 'NO_MATCH',
'ofac_eo13645': 'NO_MATCH',
'ofac_fse': 'NO_MATCH',
'ofac_fse_ir': 'NO_MATCH',
'ofac_fse_sy': 'NO_MATCH',
'ofac_isa': 'NO_MATCH',
'ofac_ns_isa': 'NO_MATCH',
'ofac_plc': 'NO_MATCH',
'ofac_sdn': 'NO_MATCH',
'ofac_ssi': 'NO_MATCH',
'ofac_syria': 'NO_MATCH',
'ofac_ukraine_eo13662': 'NO_MATCH',
'osfi': 'NO_MATCH',
'pep': 'NO_MATCH',
'plc': 'NO_MATCH',
'primary_concern': 'NO_MATCH',
'sdn': 'NO_MATCH',
'ssi': 'NO_MATCH',
'tel_sanctions': 'NO_MATCH',
'ukcl': 'NO_MATCH',
'uvl': 'NO_MATCH'
},
'permission_scope': 'SEND|RECEIVE|1000|DAILY',
'physical_documents': 1,
'social_documents': 4,
'virtual_documents': 1
}
args = {
'email': '[email protected]',
'phone_number': '555-555-5555',
'legal_name': 'Hello McHello',
'note': ':)', # optional
'supp_id': '123abc', # optional
'is_business': True,
'cip_tag': 1
}
user_without_basedocs = User.create(client, **args)
docs = {
"email":"[email protected]",
"phone_number":"901.111.1111",
"ip":"::1",
"name":"Test User",
"alias":"Test",
"entity_type":"M",
"entity_scope":"Arts & Entertainment",
"day":2,
"month":5,
"year":1989,
"address_street":"1 Market St.",
"address_city":"San Francisco",
"address_subdivision":"CA",
"address_postal_code":"94114",
"address_country_code":"US",
"virtual_docs":[{
"document_value":"2222",
"document_type":"SSN"
}],
"physical_docs":[{
"document_value": "data:image/gif;base64,SUQs==",
"document_type": "GOVT_ID"
}],
"social_docs":[{
"document_value":"https://www.facebook.com/valid",
"document_type":"FACEBOOK"
}]
}
args = {
'email': '[email protected]',
'phone_number': '555-555-5555',
'legal_name': 'Hello McHello',
'note': ':)', # optional
'supp_id': '123abc', # optional
'is_business': True,
'cip_tag': 1
}
user_with_basedocs = User.create(client, base_docs=docs, **args)
user = user.add_legal_name('Sam Iam')
user = user.add_login('[email protected]')
user = user.remove_login('[email protected]')
user = user.add_phone_number('415-555-5555')
user = user.remove_phone_number('415-555-5555')
user = user.change_cip_tag(1)
Adds KYC documents to the current user and returns the updated user as a User object
document = {
"email":"[email protected]",
"phone_number":"901.111.1111",
"ip":"::1",
"name":"Test User",
"alias":"Test",
"entity_type":"M",
"entity_scope":"Arts & Entertainment",
"day":2,
"month":5,
"year":1989,
"address_street":"1 Market St.",
"address_city":"San Francisco",
"address_subdivision":"CA",
"address_postal_code":"94114",
"address_country_code":"US",
"virtual_docs":[{
"document_value":"2222",
"document_type":"SSN"
}],
"physical_docs":[{
"document_value": "data:image/gif;base64,SUQs==",
"document_type": "GOVT_ID"
}],
"social_docs":[{
"document_value":"https://www.facebook.com/valid",
"document_type":"FACEBOOK"
}]
}
user = user.add_document(document)
options = {
'email': '[email protected]',
'phone_number': '707-555-5555',
'ip': '127.0.0.1',
'name': 'Doctor BaseDoc',
'alias': 'Basey',
'entity_type': 'F',
'entity_scope': 'Arts & Entertainment',
'birth_day': 28,
'birth_month': 2,
'birth_year': 1990,
'address_street': '42 Base Blvd',
'address_city': 'San Francisco',
'address_subdivision': 'CA',
'address_postal_code': '94114',
'address_country_code': 'US'
}
base_document = user.add_base_document(**options)
user = base_document.user
options = {
'email': '[email protected]',
'phone_number': '415-555-5555',
'ip': '127.0.0.2',
'name': 'Doctor Boop',
'alias': 'Boopsie',
'entity_type': 'M',
'entity_scope': 'Education',
'birth_day': 21,
'birth_month': 3,
'birth_year': 1986,
'address_street': '42 Boop Blvd',
'address_city': 'Frisco',
'address_subdivision': 'TX',
'address_postal_code': '75034',
'address_country_code': 'UK'
}
base_document = base_document.update(**options)
value = 'data:image/png;base64,SUQs=='
physical_document = base_document.add_physical_document(type='GOVT_ID',
value=value)
base_document = physical_document.base_document
file_path = 'path/to/file.png'
physical_document = base_document.add_physical_document(type='GOVT_ID',
file_path=file_path)
base_document = physical_document.base_document
url = 'https://cdn.synapsepay.com/static_assets/[email protected]'
physical_document = base_document.add_physical_document(type='GOVT_ID', url=url)
base_document = physical_document.base_document
byte_stream = b'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00...'
physical_document = base_document.add_physical_document(type='GOVT_ID',
mime_type='image/jpeg',
byte_stream=byte_stream)
base_document = physical_document.base_document
value = 'facebook.com/sankaet'
social_document = base_document.add_social_document(type= 'FACEBOOK',
value=value)
base_document = social_document.base_document
virtual_document = base_document.add_virtual_document(type='SSN', value='3333')
base_document = virtual_document.base_document
from synapse_pay_rest import Node
options = {
'page': 1,
'per_page': 20,
'type': 'ACH-US'
}
nodes = Node.all(user, **options)
node = Node.by_id(user, '57ec57be86c27345b3f8a159')
optional parameters:
node = Node.by_id(user, '57ec57be86c27345b3f8a159', full_dehydrate='yes', force_refresh='yes')
Example of node response with full_dehydrate:
**Please note: if full_dehydrate='no', some fields will return as 'None'
node =
<class'synapse_pay_rest.models.nodes.ach_us_node.AchUsNode'>({
'user': "<class 'synapse_pay_rest.models.users.user.User'>(id=592f1dfa8384540026e39a95)",
'type': 'ACH-US',
'id': '592f1e2d603964002f1b07f7',
'is_active': True,
'permission': 'LOCKED',
'nickname': 'SynapsePay Test Checking Account - 8901',
'name_on_account': ' ',
'bank_long_name': 'CAPITAL ONE N.A.',
'bank_name': 'CAPITAL ONE N.A.',
'account_type': 'PERSONAL',
'account_class': 'CHECKING',
'account_number': '12345678901',
'routing_number': '031176110',
'account_id': None,
'address': 'PO BOX 85139, RICHMOND, VA, US',
'swift': None,
'ifsc': None,
'user_info': {
'account_id': 'fd52bf51f0354335e634940139a006ef91d7e789c665857e9821656d18e7d012',
'addresses': [
{
'city': 'San Francisco',
'state': 'CA',
'street': '5315 Castro St.',
'zipcode': '94110'
}
],
'dob': '',
'emails': [
'[email protected]'
],
'names': [
'Test User'
],
'phone_numbers': [
'1652545112',
'1432656106',
'1888321821',
'6589100779'
]
},
'timeline': [
{
'date': 1496260140541,
'note': 'Node created.'
},
{
'date': 1496260142204,
'note': 'Unable to send micro deposits as node allowed is not CREDIT.'
},
{
'date': 1496260420927,
'note': "User locked. Thus node 'allowed' changed to LOCKED."
}
],
'transactions': [
{
'amount': 8.0,
'category': {
'primary': '',
'subcategory': ''
},
'current_balance': 8693.0,
'date': 1470715200.0,
'debit': False,
'description': 'CAPITAL ONE MOBILE PMT PPD:32078173097005',
'pending': False
},
{
'amount': 249.0,
'category': {
'primary': '',
'subcategory': ''
},
'current_balance': 827.0,
'date': 1411358400.0,
'debit': False,
'description': 'WF Credit Card PPD:21164346914575',
'pending': True
},
{
'amount': 61.0,
'category': {
'primary': '',
'subcategory': ''
},
'current_balance': 4284.0,
'date': 1460779200.0,
'debit': False,
'description': 'AMEX EPAYMENT PPD:22042046432370',
'pending': True
},
{
'amount': 289.0,
'category': {
'primary': '',
'subcategory': ''
},
'current_balance': 2039.0,
'date': 1481432400.0,
'debit': False,
'description': 'BK OF AM CRD PPD:76067398573865',
'pending': True
},
{
'amount': 489.0,
'category': {
'primary': '',
'subcategory': ''
},
'current_balance': 1938.0,
'date': 1397880000.0,
'debit': True,
'description': 'CAPITAL ONE MOBILE PMT PPD:12283074879351',
'pending': True
},
{
'amount': 306.0,
'category': {
'primary': '',
'subcategory': ''
},
'current_balance': 4175.0,
'date': 1436587200.0,
'debit': False,
'description': 'BK OF AM CRD PPD:36590769006391',
'pending': False
},
{
'amount': 162.0,
'category': {
'primary': '',
'subcategory': ''
},
'current_balance': 2830.0,
'date': 1480654800.0,
'debit': True,
'description': 'Payment to Chase card PPD:50214599701703',
'pending': True
},
{
'amount': 40.0,
'category': {
'primary': '',
'subcategory': ''
},
'current_balance': 1738.0,
'date': 1425099600.0,
'debit': False,
'description': 'BK OF AM CRD PPD:51422971086988',
'pending': False
},
{
'amount': 126.0,
'category': {
'primary': '',
'subcategory': ''
},
'current_balance': 8386.0,
'date': 1393131600.0,
'debit': False,
'description': 'CAPITAL ONE MOBILE PMT PPD:83488871898117',
'pending': False
},
{
'amount': 18.0,
'category': {
'primary': '',
'subcategory': ''
},
'current_balance': 5685.0,
'date': 1439611200.0,
'debit': True,
'description': 'DISCOVER E-PAYMENT PPD:35631911243360',
'pending': True
},
{
'amount': 67.0,
'category': {
'primary': '',
'subcategory': ''
},
'current_balance': 4634.0,
'date': 1416027600.0,
'debit': True,
'description': 'DISCOVER E-PAYMENT PPD:52756385725550',
'pending': True
},
{
'amount': 228.0,
'category': {
'primary': '',
'subcategory': ''
},
'current_balance': 1321.0,
'date': 1404532800.0,
'debit': False,
'description': 'Payment to Chase card PPD:18727859364976',
'pending': True
},
{
'amount': 107.0,
'category': {
'primary': '',
'subcategory': ''
},
'current_balance': 1065.0,
'date': 1414296000.0,
'debit': True,
'description': 'CAPITAL ONE MOBILE PMT PPD:26468111647708',
'pending': True
},
{
'amount': 103.0,
'category': {
'primary': '',
'subcategory': ''
},
'current_balance': 7907.0,
'date': 1415336400.0,
'debit': False,
'description': 'DISCOVER E-PAYMENT PPD:82490497472711',
'pending': True
},
{
'amount': 106.0,
'category': {
'primary': '',
'subcategory': ''
},
'current_balance': 7574.0,
'date': 1468814400.0,
'debit': True,
'description': 'DISCOVER E-PAYMENT PPD:38032120832376',
'pending': False
},
{
'amount': 50.0,
'category': {
'primary': '',
'subcategory': ''
},
'current_balance': 8876.0,
'date': 1406433600.0,
'debit': True,
'description': 'Payment to Chase card PPD:35892567736339',
'pending': True
},
{
'amount': 61.0,
'category': {
'primary': '',
'subcategory': ''
},
'current_balance': 9015.0,
'date': 1435291200.0,
'debit': False,
'description': 'CITI CARDS PPD:28749452237576',
'pending': True
},
{
'amount': 445.0,
'category': {
'primary': '',
'subcategory': ''
},
'current_balance': 9027.0,
'date': 1447477200.0,
'debit': True,
'description': 'Payment to Chase card PPD:77434089827332',
'pending': False
},
{
'amount': 343.0,
'category': {
'primary': '',
'subcategory': ''
},
'current_balance': 1252.0,
'date': 1428206400.0,
'debit': True,
'description': 'Payment to Chase card PPD:48935439759518',
'pending': True
},
{
'amount': 50.0,
'category': {
'primary': '',
'subcategory': ''
},
'current_balance': 5973.0,
'date': 1462766400.0,
'debit': True,
'description': 'WF Credit Card PPD:91101427763846',
'pending': False
},
{
'amount': 253.0,
'category': {
'primary': '',
'subcategory': ''
},
'current_balance': 2814.0,
'date': 1401854400.0,
'debit': False,
'description': 'CAPITAL ONE MOBILE PMT PPD:79516847131777',
'pending': True
},
{
'amount': 275.0,
'category': {
'primary': '',
'subcategory': ''
},
'current_balance': 9891.0,
'date': 1423112400.0,
'debit': False,
'description': 'WF Credit Card PPD:69798304985993',
'pending': True
},
{
'amount': 102.0,
'category': {
'primary': '',
'subcategory': ''
},
'current_balance': 1775.0,
'date': 1421211600.0,
'debit': True,
'description': 'DISCOVER E-PAYMENT PPD:67858400658712',
'pending': True
},
{
'amount': 382.0,
'category': {
'primary': '',
'subcategory': ''
},
'current_balance': 1585.0,
'date': 1402632000.0,
'debit': False,
'description': 'BK OF AM CRD PPD:59371638589444',
'pending': False
},
{
'amount': 486.0,
'category': {
'primary': '',
'subcategory': ''
},
'current_balance': 3946.0,
'date': 1404187200.0,
'debit': True,
'description': 'WF Credit Card PPD:97364551261150',
'pending': False
}
],
'balance': '800.00',
'currency': 'USD',
'supp_id': '',
'gateway_restricted': None
})
Returns a list of nodes unless the bank requires MFA.
from synapse_pay_rest.models.nodes import AchUsNode
required = {
'bank_name': 'fake',
'username': 'synapse_good',
'password': 'test1234'
}
ach_us = AchUsNode.create_via_bank_login(user, **required)
ach_us.mfa_verified
# => False (requires MFA)
If the bank requires MFA, you will need to resolve the MFA question(s):
ach_us.mfa_message
# => "Enter the code we texted to your phone number."
nodes = ach_us.answer_mfa('test_answer')
# => returns list of nodes if successful
# => returns self if incorrect answer or if there is a new MFA question
ach_us.mfa_verified
# => True
required = {
'nickname': 'Primary Joint Checking',
'account_number': '2222222222',
'routing_number': '051000017',
'account_type': 'PERSONAL',
'account_class': 'CHECKING'
}
node = AchUsNode.create(user, **required)
Resend microdeposits if user failed verification
node = node.resend_microdeposits()
ACH-US nodes added by account/routing must be verified with microdeposits:
required = {
'amount1': 0.1,
'amount2': 0.1
}
node = node.verify_microdeposits(**required)
node.deactivate()
from synapse_pay_rest import Transaction
options = {
'page': 1,
'per_page': 20
}
transactions = Transaction.all(node, **options)
transaction = Transaction.by_id(node, '57fc1a6886c2732e64a94c25')
args = {
'to_type': 'ACH-US',
'to_id': '57f4241d86c27331523e2f26',
'amount': 5.50,
'currency': 'USD',
'ip': '127.0.0.1',
'process_in': 0, # delay until processing (in days) [optional]
'note': 'hi synapse', # a note to synapse [optional]
'supp_id': 'ABC123', # optional
'fees': [ # optional
{
'fee': 0.12, # Fee associated with the transaction
'note': 'Test Fee 1', # Reason for the fee
'to': {'id': fee_node.id} # Node ID where the fee would be credited when the transaction settles. Fee node has to be SYNAPSE-US type.
}
]
}
transaction = Transaction.create(node, **args)
transaction = transaction.add_comment('this is my best transaction')
transaction = transaction.cancel()
from synapse_pay_rest import Subnet
options = {
'page': 1,
'per_page': 20
}
subnets = Subnet.all(node, **options)
subnet = Subnet.by_id(node, '57fc1a6886c2732e64a94c25')
args = {
'nickname': 'Test Subnet'
}
subnet = Subnet.create(node, **args)
subnet = subnet.lock()
from synapse_pay_rest import Subscription
options = {
'page': 1,
'per_page': 20
}
subscription = Subscription.all(client)
subscription = Subscription.by_id(client, '57fc1a6886c2732e64a94c25')
args = {
'scope': [
'USERS|POST',
'USER|PATCH',
'NODES|POST',
'NODE|PATCH',
'TRANS|POST',
'TRAN|PATCH'
],
'url': 'https://requestb.in/1756g2g1'
}
subscription = Subscription.create(client, **args)
new_url = 'test.com'
subscription = subscription.update_url(new_url)
new_scope = ["USERS|POST"]
subscription = subscription.update_scope(new_scope)
from synapse_pay_rest.models import PublicKey
options = {
'scope': 'CLIENT|CONTROLS'
}
public_key = PublicKey.issue(client, **options)
from synapse_pay_rest.models import Atm
options = {
'zip': '94113',
'radius': '5',
'page': 1,
'per_page': 20
}
atms = Atm.locate(client, **options)
atm = atms[0]
from synapse_pay_rest.models import Atm
options = {
'lat': '350.3040400',
'lon': "-122.33333"
'radius': '5',
'page': 1,
'per_page': 20
}
atms = Atm.locate(client, **options)
atm = atms[0]