Coder Social home page Coder Social logo

plaid-go's Introduction

plaid-go

plaid-go is a Go client implementation of the Plaid API.

Install via go get github.com/plaid/plaid-go.

Documentation: GoDoc

TODO:

  • Complete README
  • Complete testing
  • Add CI

Examples

Adding an Auth user

client := plaid.NewClient("test_id", "test_secret", plaid.Tartan)

// POST /auth
postRes, mfaRes, err := client.AuthAddUser("plaid_test", "plaid_good", "", "bofa", nil)
if err != nil {
    fmt.Println(err)
} else if mfaRes != nil {
    // Need to switch on different MFA types. See https://plaid.com/docs/api/#mfa-auth.
    switch mfaRes.Type {
    case "device":
        fmt.Println("--Device MFA--")
        fmt.Println("Message:", mfaRes.Device.Message)
    case "list":
        fmt.Println("--List MFA--")
        fmt.Println("Mask:", mfaRes.List[0].Mask, "\nType:", mfaRes.List[0].Type)
    case "questions":
        fmt.Println("--Questions MFA--")
        fmt.Println("Question:", mfaRes.Questions[0].Question)
    case "selections":
        fmt.Println("--Selections MFA--")
        fmt.Println("Question:", mfaRes.Selections[1].Question)
        fmt.Println("Answers:", mfaRes.Selections[1].Answers)
    }

    postRes2, mfaRes2, err := client.AuthStepSendMethod(mfaRes.AccessToken, "type", "email")
    if err != nil {
        fmt.Println("Error submitting send_method", err)
    }
    fmt.Println(mfaRes2, postRes2)

    postRes2, mfaRes2, err = client.AuthStep(mfaRes.AccessToken, "tomato")
    if err != nil {
        fmt.Println("Error submitting mfa", err)
    } else {
        fmt.Println(mfaRes2, postRes2)
    }
} else {
    fmt.Println(postRes.Accounts)
    fmt.Println("Auth Get")
    fmt.Println(client.AuthGet("test_bofa"))

    fmt.Println("Auth DELETE")
    fmt.Println(client.AuthDelete("test_bofa"))
}

Plaid Link Exchange Token Process

Exchange a Plaid Link public_token for an API access_token:

client := plaid.NewClient("test_id", "test_secret", plaid.Tartan)

// POST /exchange_token
postRes, err := client.ExchangeToken(public_token)
if err != nil {
    fmt.Println(err)
} else {
    // Use the returned Plaid API access_token to retrieve
    // account information.
    fmt.Println(postRes.AccessToken)
    fmt.Println("Auth Get")
    fmt.Println(client.AuthGet(postRes.AccessToken))
}

With the Plaid + Stripe ACH integration, exchange a Link public_token and account_id for an API access_token and Stripe bank_account_token:

client := plaid.NewClient(CLIENT_ID, SECRET, plaid.Tartan)

// POST /exchange_token
postRes, err := client.ExchangeTokenAccount(public_token, account_id)
if err != nil {
    fmt.Println(err)
} else {
    // Use the returned Plaid access_token to make Plaid API requests and the
    // Stripe bank account token to make Stripe ACH API requests.
    fmt.Println(postRes.AccessToken)
    fmt.Println(postRes.BankAccountToken)
}

Querying a category

// GET /categories/13001001
category, err := plaid.GetCategory(plaid.Tartan, "13001001")
if err != nil {
    fmt.Println(err)
} else {
    fmt.Println("category", category.ID, "is", strings.Join(category.Hierarchy, ", "))
}

plaid-go's People

Contributors

charleswli avatar michaelckelly avatar soroushjp avatar pbernasconi avatar albrow avatar andrewwatson avatar

Watchers

James Cloos avatar Joe Siewert avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.