npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

unique-pay

v0.0.4

Published

微信支付、支付宝支付聚合SDK,支持内置对象调用、jsSdk 调用,支持 vuejs、script 引用

Downloads

8

Readme

UniquePay

微信支付、支付宝支付聚合SDK,支持内置对象调用、jsSdk 调用

install

npm install unique-pay

npm

import uniquePay from 'unique-pay';
Vue.use(uniquePay,{
    useSdk: false //是否使用各自平台 jssdk
});

script

默认挂载到 window.UniquePay

  • 非jssdk版本
<script src="path/unique-pay/src/UniquePay.js"></script>
  • jssdk版本(增加 "usesdk" 屬性)
<script src="path/unique-pay/src/UniquePay.js" usesdk></script>

use

<template>
   <div class="input-box clearFix">
	<button v-on:click="pay">测试支付</button>
   </div>
</template>

<script>
    export default {
        name: 'app',
        data () {
          return {
            params: {} //各支付平台参数
          }
        },
        methods:{
          pay() {
            this.$uniquePay
                .pay(this.params)
                .then(resp => {
                  console.log(resp);
                })
                .catch(err => {
                  console.log(err);
                })
          }
        }
    }
</script>
<body>
   <body>
		<button onclick="pay()">pay</button>
	</body>
	<script type="text/javascript" src="js/UniquePay.js"></script>
	<script>
		function pay() {
			//初始化SDK
			UniquePay.initSdk({
				"appId": "",
				"timeStamp": "",
				"nonceStr": "",
				"signature": "",
				"jsApiList": ["chooseWXPay"]
			})
			window.UniquePay.pay({
				"appId": "",
				"timeStamp": "",
				"nonceStr": "",
				"signType": "",
				"paySign": "",
				"package": ""
			}).then(res => console.log(res));
		}
	</script>
</body>

配置说明

{
    useSdk:Bool //是否使用各自平台 jssdk,为 true 时,自动识别当前调用环境(微信/支付宝)注入支付平台jssdk,默认为 false(调用内置桥接对象)
}

方法说明

initSdk

初始化SDK(仅用于微信SDK模式签名)

(void) this.$uniquePay.initSdk(signatureConfig /微信权限验证配置/)

pay

自动识别当前调用环境,执行对应支付函数

(Promise) this.$uniquePay.pay(params)

(Promise) this.$uniquePay.pay(params, signatureConfig /微信权限验证配置,initSdk后不需要传递/)

wechatPay(非SDK模式)

手动调用微信支付桥接对象,内部调用 WeixinJSBridge.invoke('getBrandWCPayRequest')

(Promise) this.$uniquePay.wechatPay(params)

wechatPay(SDK模式)

手动调用微信支付jsapi,内部调用 wx.chooseWXPay(params)

(Promise) this.$uniquePay.wechatPay(params, signatureConfig /微信权限验证配置,initSdk后不需要传递/)

aliPay(非SDK模式)

非SDK模式:内部调用 AlipayJSBridge.call('tradePay') SDK模式:内部调用 ap.tradePay(options)

(Promise) this.$uniquePay.aliPay(params)

参数说明

微信

支付参数

权限验证配置

支付宝

支付参数

回调说明

{
    code: '',  //微信平台回调['ok'|'cancel'|'fail'],支付宝平台请参考官方文档 resultCode
    message: '', //回调消息
    ...          //支付平台返回的其他参数
}
License

LICENSE