nativescript-square-reader
允许您在不离开您的应用程序的情况下通过 Square 接受支付。目前仅限 iOS (暂时) 支持iOS 11+
npm i --save nativescript-square-reader

NativeScript Square Reader

仅限 iOS (暂时) 的 Square Reader SDK https://squareup.com/us/en/developers/reader-sdk 的 nativescript 插件

注意:仅适用于iOS 11+。要支持旧版本,请考虑使用 https://github.com/fhackenb/nativescript-square-plugin

安装

tns plugin add nativescript-square-reader

设置

iOS 设置指南:https://docs.connect.squareup.com/payments/readersdk/setup-ios

  1. tns plugin add nativescript-square-reader
  2. 按照上述列表中的步骤 1-2 获取 SquareReaderSDK.framework
  3. 将 SquareReaderSDK.framework 添加到您的构建路径
  4. 使用说明更新您的 Info.plist(链接中的步骤 3)
  5. 获取授权代码 https://docs.connect.squareup.com/payments/readersdk/mobile-authz-guide
  6. 开始编码!

用法

查看演示应用程序以获取更详细的示例用法

认证

this.squareReader = new SquareReader();
this.squareReader.authenticate(this.code)
.then( (res: SquareAuthStatus) => {
if (res.code === 0) {
// authenticated
} else {
// not authenticated
}
});

结账

this.squareReader.startCheckout(100, this.page.ios)
.subscribe( (result: SquareCheckoutResult) => {
switch (result.status) {
case 1:
console.log("Cancelled!");
break;
case 2:
console.log("Failed!");
break;
case 0:
console.log("Succeeded!");
console.log("LocationId:", result.checkoutResult.locationID);
console.log("Tenders:", result.checkoutResult.tenders);
break;
}
});

许可证

Apache 许可证版本 2.0,2004 年 1 月