【问题标题】:In ApplePay.js, need to display an error message on the paysheet在 ApplePay.js 中,需要在 paysheet 上显示错误信息
【发布时间】:2018-03-01 04:29:32
【问题描述】:

尝试使用 ApplePay.js 为 Web 实施 ApplePay。如果用户输入了无效的送货地址,我想在付款单上突出显示错误,以便用户有机会更正问题。我看到这里有一个 ApplePayError 类:https://developer.apple.com/documentation/applepayjs/applepayerror,但是我不知道如何使用这个类。我试过这个没有运气:

var err = new ApplePayError("shippingContactInvalid", "postalAddress", "Address is invalid");

这对吗?它在工资单上没有显示任何错误,所以我认为这是错误的,但我不知道该怎么做,而且我似乎找不到任何关于它使用的信息。有人可以在这里指出我正确的方向吗?

【问题讨论】:

    标签: applepay applepayjs


    【解决方案1】:

    确保 Apple Pay js api 版本 3 用于创建 ApplePaySession。

    然后将带有状态和错误的结果对象传递给“完成”方法:

    var err = new ApplePayError("shippingContactInvalid", "postalAddress", "Address is invalid");
        session.completePayment({
            status: ApplePaySession.STATUS_FAILURE,
            errors: [ err ]
        });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-04-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多