Create new stripe Account

PHOTO EMBED

Tue Mar 29 2022 07:49:14 GMT+0000 (UTC)

Saved by @hasnat #ios #swift #stripe

    func createStripeConnectAccount() {
        let parameters: [String:Any] = [
            "type" : "express",
            "country" : "US",
//            "capabilities": [["card_payments"]["requested"],
//            "capabilities[transfers][requested]": true,
//            "business_type": "individual",
            "business_profile[url]": "https://google.com"]
        
        let url = "https://api.stripe.com/v1/accounts"
        let api_key = "add test api key here"
        let loginData = api_key.data(using: String.Encoding.utf8)
        let base64LoginString = loginData?.base64EncodedString()
        print("key : ", (base64LoginString ?? "") as String)
        let headers: HTTPHeaders = ["Authorization": "Basic \(base64LoginString!)", "Content-Type": "application/x-www-form-urlencoded", "Accept": "*/*"]
        AF.request(url, method: .post, parameters: parameters, encoding: URLEncoding.httpBody, headers: headers)
            .responseDecodable(of: DecodableType.self)
            { response in
                switch response.result {
                case .success(let dict):
                    print("success ", response.result, dict)
                    let res = dict.id
                    print("ID1 : ", res)
                case .failure(let error):
                    print("Failure : ", error)
                }
            }
    }
content_copyCOPY