Creating customers, and allowing them to deposit funds for holding


#1

Hi there, I’m currently developing an iOS application and integrating with the Dwolla Access API. I have a few specific questions, but I guess I’m also slightly unclear on the overall flow that I need to follow. Basically, I want to create a funding source for each user of my app, and allow that user to transfer funds from that holding source, into a “Dwolla Account” for holding, and eventually withdraw them for a purchase.

My understanding is that the first thing I’ll want to do, is generate an Access Token. I was able to do this using both the programmatic method here https://docsv2.dwolla.com/#application-authorization, and by clicking “create token” on my account page. I could be wrong, but are these two tokens the same thing?

Now I believe I want to create a customer, but I definitely need some clarification here. Should each of the users of my app be a customer? Or should they have an account? It was my first instinct to create a customer for each user, and add a funding source for that customer. I’m going to be verifying the funding sources through plaid, as I already have that code working, giving me the necessary processor_token. However, if I create a customer, and link a funding source, what is the destination parameter when a user wants to make a transfer to dwolla holding? Is it the customer ID? I see on my own Dwolla sandbox account dashboard that I have a ‘Dwolla Balance’, but I don’t see this option for customers.

Assuming I’m correct in that I need to create a customer for each user, I’m attempting to do just that. However, when making the request to create the customer, I’m getting a 406 error returned.

Per the instructions, the url im using *can be seen below
My headers are
let head: HTTPHeaders = [“Authorization”: "Bearer " + “(mytoken)”], where mytoken is the AccessToken I retrieved earlier. Lastly, I add the necessary parameters and make a JSON encoded post request with Alamofire. I’ve made multiple requests to different API’s including the request to get the AccessToken from dwolla, so I don’t beleive my Alamofire usage is incorrect. I get a ReponseValidationFailed error, and when I disable validation I just get back empty data. Does anyone have any insight as to why this may be happening?

I would appreciate a basic high level explanation of what I need to do as far as allowing my users to link a bank account, and deposit money from that account for holding. Also if anyone has any idea why my createDwolla customer function is getting an error. On second thought, I’m going to post the function in its entirety.

       func createDwollaCustomer(){
        let url = "https://api-sandbox.dwolla.com/customers"
        let firstName = "Test"
        let lastName = "LastTest"
        let email = "myEmail@gmail.com"
        let businessName = ""
        let mytoken = "0DZmb3ITRm0EUljw24hhubigVCxjOrgWPC61MeGE9SjpbcJg2c" //copied from "create token" on my dwolla account dashboard
        let head: HTTPHeaders = ["Authorization": "Bearer " + "\(mytoken)"]
        let para: [String: String] = ["firstName": firstName, "lastName": lastName, "email": email, "businessName": businessName]
        Alamofire.request(url, method: .post, parameters: para, encoding: JSONEncoding.default, headers: head).validate().responseJSON { response in
            switch response.result {
            case .success:
                print(response.result)
                if let result = response.result.value {
                    let JSON = result as! NSDictionary
                    print(JSON)
                }
            case .failure(let error):
                print(response.result)
                print(response.description)
                print(response.debugDescription)
                print(error)
            }
        }
    }

#3

Update. Received the clarification I needed. The original request was not working because it was missing the Content-type and Accept headers. Once those were added a customer was able to be created. Customers looking to deposit should be created as verified, and when making a transfer the source should be the customers funding source, and the destination should be the customer ID link. All funds deposited to the customers ID will be stored in a funding source created on the back end.


(Cory Anderson) #4