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

cordova-plugin-alipay

v0.9.1

Published

支付宝支付插件,alipay payment

Downloads

28

Readme

Cordova 支付宝支付插件

最新更新

  1. 增加callback
  2. 默认使用自动安装的方法
  3. 去除了对URL Scheme的依赖

支持的系统

  • iOS
  • Android

自动安装(Cordova > v5.1.1)

cordova plugin add $CORDOVA_PLUGIN_DIR --variable PARTNER_ID=[你的商户PID可以在账户中查询] --variable SELLER_ACCOUNT=[你的商户支付宝帐号] --variable PRIVATE_KEY=[你生成的private key]

注意:PRIVATE_KEY的值是生成的私钥,要求是PKCS格式,需要去掉——-BEGIN PRIVAT KEY——-和——-END PRIVATE KEY——-,以及空格换行。关于私钥的说明详见下面关于私钥部分

使用方法

window.alipay.pay({
	tradeNo: tradeNo,
	subject: "测试标题",
	body: "我是测试内容",
	price: 0.02,
	notifyUrl: "http://your.server.notify.url"
}, function(successResults){alert(results)}, function(errorResults){alert(results)});

参数说明

  • tradeNo 这个是支付宝需要的,应该是一个唯一的ID号
  • subject 这个字段会显示在支付宝付款的页面
  • body 订单详情,没找到会显示哪里
  • price 价格,支持两位小数
  • function(successResults){} 是成功之后的回调函数
  • function(errorResults){} 是失败之后的回调函数

successResultserrorResults分别是成功和失败之后支付宝SDK返回的结果,类似如下内容

// 成功
{
	resultStatus: "9000",
	memo: "",
	result: "partner=\"XXXX\"&seller_id=\"XXXX\"&out_trade_no=\"XXXXX\"..."	
}
// 用户取消
{
	memo: "用户中途取消", 
	resultStatus: "6001", 
	result: ""	
}
  • resultStatus的含义请参照这个官方文档:客户端返回码
  • memo:一般是一些纯中文的解释,出错的时候会有内容。
  • result: 是所有支付请求参数的拼接起来的字符串。

关于私钥

这里用的私钥一定是PKCS格式的,详细生成步骤请参照官方文档:RSA私钥及公钥生成

文档中描述的这一步:OpenSSL> pkcs8 -topk8 -inform PEM -in rsa_private_key.pem -outform PEM -nocrypt会将生成的私钥打印到屏幕上,记得复制下来。

手动安装

  1. 使用git命令将插件下载到本地,并标记为$CORDOVA_PLUGIN_DIR

     git clone https://github.com/charleyw/cordova-plugin-alipay.git && cd cordova-plugin-alipay && export CORDOVA_PLUGIN_DIR=$(pwd)
    	
  2. 修改$CORDOVA_PLUGIN_DIR/plugin.xml,删除下面这一行:

     <preference name="PRIVATE_KEY"/>
    	
  3. 修改$CORDOVA_PLUGIN_DIR/plugin.xml,将

     <preference name="private_key" value="$PRIVATE_KEY" />

改成

	<preference name="PRIVATE_KEY" value="你生成的private key的内容"/>

**注意**:总共有两处
  1. 安装

     cordova plugin add $CORDOVA_PLUGIN_DIR --variable PARTNER_ID=[你的商户PID可以在账户中查询] --variable SELLER_ACCOUNT=[你的商户支付宝帐号]

Liscense

© 2015 Wang Chao. This code is distributed under the MIT license.