如果钱包中没有卡,对于Apple Pay按钮,哪种行为更可取? [英] What behaviour is pereferable for Apple Pay button if no cards in the wallet?

查看:571
本文介绍了如果钱包中没有卡,对于Apple Pay按钮,哪种行为更可取?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过了苹果指南,但没有发现有关此问题的任何信息.

I was looked through the apple guidelines but did not found anything about this question.

其他信息:

我已经在应用程序中添加了Apple Pay按钮,如果没有可用的功能(例如卡),则将其隐藏.但是客户不喜欢它,并且希望使用其他方法.我认为我们可能会像要求用户添加卡一样打开钱包,但是我不确定Apple指南对此有何看法.

I have added Apple Pay button to app and hide it if there are no capabilities (e.g., cards) to pay with. But customer does not like it and wants some other approach. I think we may open wallet like asking user to add a card, but I am not sure what Apple guidelines think about it.

对此有明确建议吗?

推荐答案

这是Apple的这是相关的部分: 使用 PKPaymentAuthorizationViewController 方法

Here is the relevant section: Using PKPaymentAuthorizationViewController methods

如果canMakePayments返回NO,则设备不支持Apple Pay.不要显示Apple Pay按钮.相反,请转而使用另一种付款方式.

If canMakePayments returns NO, the device does not support Apple Pay. Do not display the Apple Pay button. Instead, fall back to another method of payment.

如果canMakePayments返回YES,但canMakePaymentsUsingNetworks:返回NO,则设备支持Apple Pay,但用户尚未为任何请求的网络添加卡.您可以选择显示付款设置按钮,提示用户设置他或她的卡.用户点击此按钮后,立即启动设置新卡的过程(例如,通过调用openPaymentSetup方法).

If canMakePayments returns YES but canMakePaymentsUsingNetworks: returns NO, the device supports Apple Pay, but the user has not added a card for any of the requested networks. You can, optionally, display a payment setup button, prompting the user to set up his or her card. As soon as the user taps this button, initiate the process of setting up a new card (for example, by calling the openPaymentSetup method).

要创建Apple Pay品牌的按钮以在iOS 8.3或更高版本上启动付款请求,请使用 PKPaymentButton 类.

To create an Apple Pay–branded button for initiating payment request on iOS 8.3 or later, use the PKPaymentButton class.

从PKPaymentButton文档:

From the PKPaymentButton docs:

提供一个按钮,该按钮可用于通过以下方式触发付款 Apple Pay或提示用户设置卡.

Provides a button that is used either to trigger payments through Apple Pay or to prompt the user to set up a card.

您可以使用setUp类型对其进行初始化.

You can initialize it with a type setUp.

当用户点击此按钮时,调用 openPaymentSetup ./p>

When the user taps this button, call openPaymentSetup.

 override func viewDidLoad() {
    super.viewDidLoad()

    var applePayButton: PKPaymentButton?
    if !PKPaymentAuthorizationViewController.canMakePayments() {
      // Apple Pay not supported
      return
    }
    if !PKPaymentAuthorizationViewController.canMakePayments(usingNetworks: [.masterCard]) {
      // Apple Pay supported and payment not setup
      applePayButton = PKPaymentButton.init(paymentButtonType: .setUp, paymentButtonStyle: .black)
      applePayButton?.addTarget(self, action: #selector(self.setupPressed(_:)), for: .touchUpInside)
    } else {
      // Apple Pay supported and payment setup
      applePayButton = PKPaymentButton.init(paymentButtonType: .buy, paymentButtonStyle: .black)
      applePayButton?.addTarget(self, action: #selector(self.payPressed(_:)), for: .touchUpInside)
    }

    applePayButton?.translatesAutoresizingMaskIntoConstraints = false
    self.view.addSubview(applePayButton!)
    applePayButton?.centerXAnchor.constraint(equalTo: self.view.centerXAnchor).isActive = true
    applePayButton?.widthAnchor.constraint(equalToConstant: 200).isActive = true
    applePayButton?.heightAnchor.constraint(equalToConstant: 60).isActive = true
    applePayButton?.bottomAnchor.constraint(equalTo: self.view.bottomAnchor, constant: -20).isActive = true

  }

  @objc func payPressed(_ sender: PKPaymentButton){
    // Start payment
  }

  @objc func setupPressed(_ sender: PKPaymentButton){
    let passLibrary = PKPassLibrary()
    passLibrary.openPaymentSetup()
  }

}

这篇关于如果钱包中没有卡,对于Apple Pay按钮,哪种行为更可取?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆