capacitor-plugin-pay
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

capacitor-plugin-pay

[ios/android] wechat pay & alipay

demo (如需正常支付需修改支付参数,参考下方)

[android] 修改 android/build.gradle 文件中 wxPayPackageName 的值为你app在微信支付上登记的appid,ios 无需此操作

配置

修改项目目录下 capacitor.config.json :

{
  "appId": "你的应用appid",
  "wxappId": "你的应用微信支付appid",
  "universalLink": "你的universalLink",
  "appName": "你的app名字",
  "bundledWebRuntime": false,
  "npmClient": "npm",
  "webDir": "www",
  "plugins": {
    "SplashScreen": {
      "launchShowDuration": 0
    }
  },
  "cordova": {}
}

Android配置方法:

在根目录下找到 android 目录 ,依次找到 android/src/main/java/**** (嵌套包名文件夹)/activities/MainActivity.java,修改:

......
import com.veluxa.plugins.FileDownloader;

public class MainActivity extends BridgeActivity {
    ......
    this.init(savedInstanceState, new ArrayList<Class<? extends Plugin>>() {{
        ......
        add(FileDownloader.class);
    }});
    ......
}

IOS配置方法: 无需配置

调用

在需要使用到插件的文件,添加:

......
import 'capacitor-plugin-pay';
import { Plugins } from '@capacitor/core';
const { Pay } = Plugins;

......

// 微信支付
const wxPayParams = {
    mch_id: xxxx,
    prepay_id: xxxxx,
    nonce: xxxx,
    timestamp: xxxxx,
    sign: xxxx
};
Pay.wxPayRequest(wxPayParams).then(res => console.log('wx成功:',res))
.catch(err => { console.log('wx失败:',err) });

// 支付宝支付

Pay.aliPayRequest({ orderInfo: payUrlStr }).then(res => console.log('zfb成功:', res))
    .catch(err => { console.log('zfb失败:', err) });
......

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.0.10latest

Version History

VersionDownloads (Last 7 Days)Published
0.0.10

Package Sidebar

Install

npm i capacitor-plugin-pay

Weekly Downloads

0

Version

0.0.1

License

MIT

Unpacked Size

27.8 MB

Total Files

74

Last publish

Collaborators

  • fwindpeak