This plugin is a wrapper for the MobilePay AppSwitch SDK (https://github.com/MobilePayDev/MobilePay-AppSwitch-SDK). It allows your app to utilize and integrate directly with Mobile Pay if installed on the phone.
To use the plugin you would have create an account at MobilePay.
Describe your plugin installation steps. Ideally it would be something like:
tns plugin add nativescript-mobilepay
First add the following lines to main.ts:
import { platformNativeScriptDynamic } from "nativescript-angular/platform";
import { AppModule } from "./app/app.module";
import { MobilePay } from "nativescript-mobilepay";
// Do this for nativescript-mobilepay
var mobilePay = new MobilePay();
mobilePay.addDelegate();
platformNativeScriptDynamic().bootstrapModule(AppModule);
Simply import the MobilePay class as shown below and start using the features.
import { Component, OnInit } from "@angular/core";
import { MobilePay } from 'nativescript-mobilepay';
import { isAndroid, isIOS } from 'tns-core-modules/platform';
declare var dk: any;
@Component({
selector: "Home",
moduleId: module.id,
templateUrl: "./home.component.html"
})
export class HomeComponent implements OnInit {
private mobilePay: MobilePay;
constructor() {
// Use the component constructor to inject providers.
}
ngOnInit(): void {
// Create an instance on init. Important!
this.mobilePay = new MobilePay();
this.mobilePay.createMobilePayInstance("APPDK0000000000");
}
pay() {
const isInstalled = this.mobilePay.isMobilePayInstalled("APPDK0000000000");
console.log("Mobile Pay installed? " + isInstalled + " Android: " + isAndroid + " iOS: " + isIOS);
// You can choose to provide a result callback like this
MobilePay.onPaymentSuccess = (result) => (console.log("WE MADE A SUCCESSFUL RESULT"));
MobilePay.onPaymentFailure = (failure) => (console.log("WE MADE A FAILURE LOL"));
MobilePay.onPaymentCancel = () => (console.log("WE MADE A SUCCESSFUL CANCEL"));
if(isInstalled) {
this.mobilePay.MakePayment("APPDK0000000000", 1.0, "86715c57-8840-4a6f-af5f-07ee89107ece")
}
}
}
Properties of the plugin
Creates a mobile pay instance. Please see demo example.
Checks whether or not mobile pay is installed on device.
Makes a payment request to mobile pay.
Callback function if a payment was successful.
Callback if payment failed.
Callback if payment was cancelled.
Apache License Version 2.0, January 2004
NativeScript 可以使用 Javascript,CSS, XML 创建真正的 Native 跨平台应用,支持 iOS Android,NativeScript 将您的跨平台代码翻译成目标平台的代码。 UI 使用 XML 描述,CSS 样式,在编译时将 UI 转化成本地原生代码,最终得到正在的 Native 原生应用。 Telerik 公开了用于创建安卓、iOS和Windows Unive
NativeScript Command-Line Interface The NativeScript CLI lets you create, build, and deploy NativeScript-based apps on iOS and Android devices. Get it using: npm install -g nativescript What is Native
NativeScript-Snackbar �� �� �� NativeScript plugin for Material Design SnackBar component. Installation: NativeScript 7+:tns plugin add @nstudio/nativescript-snackbar NativeScript version prior to 7:t
Nativescript-Ripple This plugin aims to bring a native (or close to native) ripple implementation on Android and iOS. The android version uses a RippleDrawable and conserves the previous background, a
NativeScript-FloatingActionButton NativeScript plugin for Material Design Floating Action Button UI component. Installation Nativescript 7+: ns plugin add @nstudio/nativescript-floatingactionbutton Na
NativeScript CardView A NativeScript plugin to provide an XML widget to implement the Material Design CardView component. Installation NativeScript 7+: ns plugin add @nstudio/nativescript-cardview Nat