Square寄存器IOS SDK的用户ID不匹配

时间:2017-01-30 19:14:46

标签: ios swift square-connect

使用SquareRegisterSDK-iOS时,我收到user_id_mismatch错误代码。

我首先在初始视图控制器中设置客户端ID:

override func viewDidLoad() {
    super.viewDidLoad()

    SCCAPIRequest.setClientID(<my application id>)

    view.backgroundColor = UIColor(red: 18 / 255, green: 63 / 255, blue: 87 / 255, alpha: 1.0)
    pinInput.attributedPlaceholder = NSAttributedString(string: "pin", attributes: [NSForegroundColorAttributeName: UIColor(white: 1.0, alpha: 0.25)])
}

然后在另一个视图控制器中发出请求:

@IBAction func purchase(_ sender: Any) {
    let amount: SCCMoney

    do {
        amount = try SCCMoney(amountCents: 2300, currencyCode: Constants.currencyCodeString)
    } catch let error as NSError {
        print("Error creating SCCMoney: \(error)")
        return
    }

    let request: SCCAPIRequest
    do {
        request = try SCCAPIRequest(
            callbackURL: URL(string:"myproject://payment-complete")!,
            amount: amount,
            userInfoString: nil,
            merchantID: <my merchant id>,
            notes: nil,
            customerID: nil,
            supportedTenderTypes: .all,
            clearsDefaultFees: false,
            returnAutomaticallyAfterPayment: true)

        do {
            try SCCAPIConnection.perform(request)
        } catch let error as NSError {
            print("Cannot perform request: \(error)")
            return
        }
    } catch let error as NSError {
        print("Error SCCApiRequest: \(error)")
    }
}

我不确定它正在寻找什么用户ID,除非我错过了某个地方的文档

1 个答案:

答案 0 :(得分:0)

所以我似乎误解了商家ID是什么,我把它与从https://connect.squareup.com/v1/me返回的方形商家ID混为一谈。

nil修复我的错误

中将商家ID设置为SCCAPIRequest