Stripe不断验证其“失败”测试图像

时间:2019-07-26 22:07:13

标签: ios stripe-payments

我正在从iPhone上传图像以进行验证到我的Firebase后端,该后端创建Stripe文件并返回fileID。我得到了一个fileID以及所有文件,但是我正在上载其“失败”图像,当我检查仪表板上的帐户时,Stripe说它们的图像已验证。这是我的iOS代码:

static func importFrontPhoto(frontID frontIdImg: UIImage?, completion: @escaping (String?) -> Void)
    {

        guard let frontImg = frontIdImg else {return}
        guard let frontImgData = frontImg.pngData() else {return}


        let headers: HTTPHeaders = [
            "Authorization": "Bearer " + Constants.STRIPE_PUBLISH_KEY,
            "Content-type": "multipart/form-data"
        ]


        /*** IMAGE UPLOAD OF FRONT OF ID ***/
        Alamofire.upload(multipartFormData: { (multipartFormData) in
            multipartFormData.append(frontImgData, withName: "front_img",fileName: "failed.png", mimeType: "image/png")

        }, usingThreshold: UInt64.init(), to: Constants.BASE_URL + Constants.UPLOAD_IMG, method: .post, headers: headers) { (result) in
            switch result{
            case .success(let upload, _, _):
                upload.responseJSON { response in
                    print("Succesfully uploaded")
                    guard let frontID = response.value else { return }
                    completion(frontID as? String)
                }
            case .failure(let error):
                print("Error in upload: \(error.localizedDescription)")
                completion(error.localizedDescription)
            }
        }
    }

这是我的后端代码:

app.post('/file_upload', (request, response) => {
const {
fieldname,
originalname,
encoding,
mimetype,
buffer,
} = request.files[0]

console.log(originalname);
console.log(fieldname);


stripe.files.create({
    file: {
        data: buffer,
        name: originalname,
        type: 'multipart/form-data'
    },
    purpose: 'identity_document'
},function(err, file){
    if(err){
        response.send(err);
        console.log("Error"+ err);
    }
    else{
        console.log("File:"+file.id);
        console.log(file);
        response.json(file.id)

    }
});
});

编辑: 我还应该补充一点,因为我已经从Stripe的Connect仪表板手动添加了照片,并且后端相应地失败了,并且向我的Webhook发送了正确的“失败”通知,所以后端可以工作。看来iOS方面有问题。

0 个答案:

没有答案