首页 > 解决方案 > Swift Stripe 支付界面在收集卡信息后显示错误

问题描述

我正在尝试用 swift 中的条带实现添加付款方式。我能够弄清楚 SwiftUI 集成,但在输入卡信息后我不断收到错误警报

这是生成 STPPaymentOptionsViewController 并在按下添加卡按钮时显示 STPAddCardViewController 的代码。

import Foundation
import SwiftUI
import Stripe

struct PaymentOptionsView: UIViewControllerRepresentable {
  func makeCoordinator() -> Coordinator {
    Coordinator(self)
 }

class Coordinator: NSObject, STPPaymentOptionsViewControllerDelegate {
    var control: PaymentOptionsView

    init(_ control: PaymentOptionsView) {
        self.control = control
    }

    // Implement required delegate methods here:
    func paymentOptionsViewControllerDidCancel(_ paymentOptionsViewController: STPPaymentOptionsViewController) {

    }

    func paymentOptionsViewControllerDidFinish(_ paymentOptionsViewController: STPPaymentOptionsViewController) {

    }

    func paymentOptionsViewController(_ paymentOptionsViewController: STPPaymentOptionsViewController, didFailToLoadWithError error: Error) {

    }
}

func makeUIViewController(context: UIViewControllerRepresentableContext<PaymentOptionsView>) -> STPPaymentOptionsViewController {
      let config = STPPaymentConfiguration()
      //          config.requiredBillingAddressFields = .none
      config.appleMerchantIdentifier = "dummy-merchant-id"

    return STPPaymentOptionsViewController(configuration: config, theme: STPTheme(), apiAdapter: STPCustomerContext(keyProvider: MyAPIClient()), delegate: context.coordinator)
  }


 func updateUIViewController(_ uiViewController: STPPaymentOptionsViewController, context: UIViewControllerRepresentableContext<PaymentOptionsView>) { }
 }

这是唯一的错误打印输出

ake a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.
2021-07-15 07:23:21.114929-0400 app[28150:407027] LOG ANALYTICS: ["apple_pay_enabled": 1, "device_type": "x86_64", "publishable_key": "pk_test_TYooMQauvdEDq54NiTphI7jx", "bindings_version": "21.5.1", "app_name": "konstant", "shipping_type": "shipping", "company_name": "konstant", "ui_usage_level": "partial", "required_shipping_address_fields": "none", "product_usage": ["STPAddCardViewController", "STPCustomerContext", "STPPaymentCardTextField", "STPPaymentOptionsViewController"], "source_type": "card", "os_version": "14.4", "additional_payment_methods": "none", "apple_merchant_identifier": "unknown", "analytics_ua": "analytics.stripeios-1.0", "event": "stripeios.payment_method_creation", "additional_info": [], "required_billing_address_fields": "zip", "ocr_type": "none", "app_version": "1.0"]
2021-07-15 07:23:21.970800-0400 app[28150:407027] Can't find keyplane that supports type 11 for keyboard iPhone-PortraitTruffle-NumberPad; using 25901_PortraitTruffle_iPhone-Simple-Pad_Default
2021-07-15 07:23:22.415522-0400 app[28150:407027] [SwiftUI] Invalid frame dimension (negative or non-finite).
2021-07-15 07:23:22.417320-0400 app[28150:407027] [SwiftUI] Invalid frame dimension (negative or non-finite).
2021-07-15 07:23:22.417689-0400 app[28150:407027] [SwiftUI] Invalid frame dimension (negative or non-finite).
2021-07-15 07:23:22.417927-0400 app[28150:407027] [SwiftUI] Invalid frame dimension (negative or non-finite).
2021-07-15 07:23:22.419214-0400 app[28150:407027] [SwiftUI] Invalid frame dimension (negative or non-finite).
2021-07-15 07:23:22.419532-0400 app[28150:407027] [SwiftUI] Invalid frame dimension (negative or non-finite).
LIS

没有其他可以解释错误的相应消息打印输出

这是我得到的错误屏幕上

是什么原因造成的,我该如何解决?

标签: swiftstripe-payments

解决方案


推荐阅读