Skip to content

MethodFi/method-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

method-python

Python library for the Method API

Install

pip install method-python

Usage

from method import Method

method = Method(env='production', api_key='{API_KEY}')

# or 

method = Method({'env': 'production', 'api_key': '{API_KEY}'})

Entities

Create Individual Entity

entity = method.entities.create({
  'type': 'individual',
  'individual': {
    'first_name': 'Kevin',
    'last_name': 'Doyle',
    'phone': '+16505555555',
    'email': 'kevin.doyle@gmail.com',
    'dob': '1997-03-18',
  },
  'address': {
    'line1': '3300 N Interstate 35',
    'line2': None,
    'city': 'Austin',
    'state': 'TX',
    'zip': '78705'
  }
})

Create Corporation Entity

entity = method.entities.create({
  'type': 'c_corporation',
  'corporation': {
    'name': 'Alphabet Inc.',
    'dba': 'Google',
    'ein': '641234567',
    'owners': [
      {
        'first_name': 'Sergey',
        'last_name': 'Brin',
        'phone': '+16505555555',
        'email': 'sergey@google.com',
        'dob': '1973-08-21',
        'address': {
          'line1': '600 Amphitheatre Parkway',
          'line2': None,
          'city': 'Mountain View',
          'state': 'CA',
          'zip': '94043'
        }
      }
    ]
  },
  'address': {
    'line1': '1600 Amphitheatre Parkway',
    'line2': None,
    'city': 'Mountain View',
    'state': 'CA',
    'zip': '94043'
  }
})

Retrieve Entity

entity = method.entities.get('ent_au22b1fbFJbp8')

Update Entity

entity = method.entities.update('ent_au22b1fbFJbp8', {
  'individual': {
    'first_name': 'Kevin',
    'last_name': 'Doyle',
    'email': 'kevin.doyle@gmail.com',
    'dob': '1997-03-18',
  }
})

List Entities

entities = method.entities.list()

Refresh Capabilities

entity = method.entities.refresh_capabilities('ent_au22b1fbFJbp8')

Create Individual Auth Session

response = method.entities.create_auth_session('ent_au22b1fbFJbp8')

Update Individual Auth Session

response = method.entities.update_auth_session('ent_au22b1fbFJbp8', {
  "answers": [
    {
      "question_id": "qtn_ywWqCnXDGGmmg",
      "answer_id": "ans_74H68MJjqNhk8"
    },
    ...
  ]
})

Accounts

Create Ach Account

account = method.accounts.create({
  'holder_id': 'ent_y1a9e1fbnJ1f3',
  'ach': {
    'routing': '367537407',
    'number': '57838927',
    'type': 'checking'
  }
})

Create Liability Account

account = method.accounts.create({
  'holder_id': 'ent_au22b1fbFJbp8',
  'liability': {
    'mch_id': 'mch_2',
    'account_number': '1122334455'
  }
})

Retrieve Account

account = method.accounts.get('acc_Zc4F2aTLt8CBt')

List Accounts

accounts = method.accounts.list()

ACH Verification

Create Micro-Deposits Verification

verification = method
  .accounts('acc_b9q2XVAnNFbp3')
  .verification
  .create({ 'type': 'micro_deposits' })

Create Plaid Verification

verification = method
  .accounts('acc_b9q2XVAnNFbp3')
  .verification
  .create({
    'type': 'plaid',
    'plaid': {
      'balances': {
        'available': 100,
        'current': 110,
        'iso_currency_code': 'USD',
        'limit': None,
        'unofficial_currency_code': None
      },
      'transactions': [
        ...
      ]
    }
  })

Create Teller Verification

verification = method
  .accounts('acc_b9q2XVAnNFbp3')
  .verification
  .create({
    'type': 'teller',
    'teller': {
      'balances': {
        'account_id': 'acc_ns9gkibeia6ad0rr6s00q',
        'available': '93011.13',
        'ledger': '93011.13',
        'links': {
          'account': 'https://api.teller.io/accounts/acc_ns9gkibeia6ad0rr6s00q',
          'self': 'https://api.teller.io/accounts/acc_ns9gkibeia6ad0rr6s00q/balances'
        }
      },
      'transactions': [
        {
          'account_id': 'acc_ns9gkia42a6ad0rr6s000',
          'amount': '-51.19',
          'date': '2022-01-04',
          'description': 'Venmo Payment',
          'details': {
            'category': 'services',
            'counterparty': {
              'name': 'LOUISE BENTLEY',
              'type': 'person'
            },
            'processing_status': 'complete'
          },
          'id': 'txn_ns9gkiph2a6ad0rr6s000',
          'links': {
            'account': 'https://api.teller.io/accounts/acc_ns9gkia42a6ad0rr6s000',
            'self': 'https://api.teller.io/accounts/acc_ns9gkia42a6ad0rr6s000/transactions/txn_ns9gkiph2a6ad0rr6s000'
          },
          'running_balance': None,
          'status': 'pending',
          'type': 'digital_payment'
        }
      ]
    }
  })

Create MX Verification

verification = method
  .accounts('acc_b9q2XVAnNFbp3')
  .verification
  .create({
    'type': 'mx',
    'mx': {
      'account ': {
        'institution_code': 'chase',
        'guid': 'ACT-06d7f44b-caae-0f6e-1384-01f52e75dcb1',
        'account_number': None,
        'apr': None,
        'apy': None,
        'available_balance': 1000.23,
        'available_credit': None,
        'balance': 1000.23,
        'cash_balance': 1000.32,
        'cash_surrender_value': 1000.23,
        'created_at': '2016-10-13T17:57:37+00:00'
        ...
      },
      'transactions': [
        ...
      ]
    } 
  )

Update Verification

verification = method
  .accounts('acc_b9q2XVAnNFbp3')
  .verification
  .update({
    'micro_deposits': {
      'amounts': [10, 4]
    }
  })

Retrieve Verification

verification = method
  .accounts('acc_b9q2XVAnNFbp3')
  .verification
  .get()

Merchants

List Merchants

merchants = method.merchants.list()

Retrieve Merchant

merchant = method.merchants.get('mch_1')

Payments

Create Payment

payment = method.payments.create({
  'amount': 5000,
  'source': 'acc_JMJZT6r7iHi8e',
  'destination': 'acc_AXthnzpBnxxWP',
  'description': 'Loan Pmt'
})

Retrieve Payment

payment = method.payments.get('pmt_rPrDPEwyCVUcm')

Delete Payment

payment = method.payments.delete('pmt_rPrDPEwyCVUcm')

List Payments

payments = method.payments.list()

Reversals

Retrieve Reversal

reversal = method.payments('pmt_rPrDPEwyCVUcm').reversals.get('rvs_eaBAUJtetgMdR')

Update Reversal

reversal = method
  .payments('pmt_rPrDPEwyCVUcm')
  .reversals
  .update('rvs_eaBAUJtetgMdR', { 'status': 'pending' })

List Reversals for Payment

reversals = method.payments('pmt_rPrDPEwyCVUcm').reversals.list()

Webhooks

Create Webhook

webhook = method.webhooks.create({
  'type': 'payment.update',
  'url': 'https://api.example.app/webhook',
  'auth_token': 'md7UqcTSmvXCBzPORDwOkE'
})

Retrieve Webhook

webhook = method.webhooks.get('whk_cSGjA6d9N8y8R')

Delete Webhoook

webhook = method.webhooks.delete('whk_cSGjA6d9N8y8R')

List Webhooks

webhooks = method.webhooks.list()

Reports

Create Report

report = method.reports.create({ 'type': 'payments.created.current' })

Retrieve Report

report = method.reports.get('rpt_cj2mkA3hFyHT5')

Download Report

report_csv = method.reports.download('rpt_cj2mkA3hFyHT5')