如何在 NativeScript 中使用 Apple Pay

How to use Apple Pay in NativeScript

我正在尝试使用本机代码在 NativeScript 应用程序中制作 Apple Pay。
但是数据类型有一些错误 (?)

let item = new PKPaymentSummaryItem();
item.label = "iPhone Xs 64 Gb";
item.amount = 39999;

JavaScript 错误:

file:///app/components/Home.vue:24:0 JS ERROR Error: -[__NSCFNumber decimalNumberByRoundingAccordingToBehavior:]: unrecognized selector sent to instance 0xf549d0dbe6e8cc69

如错误消息所示,您需要正确进行打字转换。安装 tns-platform-declarations 包作为项目的开发依赖项将为您提供方便的智能感知,它将指导您解决此类问题。对于这种特殊情况,请这样尝试:

item.amount = new NSDecimalNumber({ string: "29999" });