无法在Square Connect中设置URL Scheme和回调网址

时间:2017-05-17 09:53:32

标签: ios swift square-connect

我需要在我的iOS应用中集成方形支付网关。我已经下载了他们的快速示例,为它添加了一个依赖项。在开发人员门户上设置应用程序。鉴于此"创新"在应用程序URL方案下。这是用于呼叫支付网关API的代码。

 let currencyCodeString = currencyField.text?.nilIfEmpty ?? currencyField.placeholder!
    let amountString = amountField.text?.nilIfEmpty ?? amountField.placeholder!

    let amount: SCCMoney
    guard let amountCents = Int(amountString) else {
        showErrorMessage(title: "Invalid Amount", message: "\(amountString) is not a valid amount.")
        return
    }

    do {
        amount = try SCCMoney(amountCents: amountCents, currencyCode: currencyCodeString)
    } catch let error as NSError {
        showErrorMessage(title: "Invalid Amount", error: error)
        return
    }

    let userInfoString = userInfoStringField.text?.nilIfEmpty
    let merchantID = merchantIDField.text?.nilIfEmpty
    let customerID = customerIDField.text?.nilIfEmpty
    let notes = notesField.text?.nilIfEmpty

    let request: SCCAPIRequest
    do {
        request = try SCCAPIRequest(callbackURL: yourCallbackURL,
                                    amount: amount,
                                    userInfoString: userInfoString,
                                    merchantID: merchantID,
                                    notes: notes,
                                    customerID: customerID,
                                    supportedTenderTypes: supportedTenderTypes,
                                    clearsDefaultFees: clearsDefaultFees,
                                    returnAutomaticallyAfterPayment: returnAutomaticallyAfterPayment)
    } catch let error as NSError {
        showErrorMessage(title: "Invalid Amount", error: error)
        return
    }

    do {
        try SCCAPIConnection.perform(request)
    } catch let error as NSError {
        showErrorMessage(title: "Cannot Perform Request", error: error)
        return
    }

我将此作为回调网址

let yourCallbackURL = URL(string: "innovation://callback")!

包含了Info.plist中的值

<array>
    <dict>
        <key>CFBundleTypeRole</key>
        <string>Editor</string>
        <key>CFBundleURLName</key>
        <string>com.squareup.hellocharge</string>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>innovation</string>
        </array>
    </dict>
</array>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSApplicationQueriesSchemes</key>
<array>
    <string>square-commerce-v1</string>
</array>

但是,我仍然收到此错误&#34;无法执行请求。确保&#34; square-commerce-v1&#34;包含在info.plist中的LSApplicationQuerySchemes中,并且您的设备上安装了方形销售点&#34;。

0 个答案:

没有答案