New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

wang.imchao.plugin.alipay

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wang.imchao.plugin.alipay

支付宝支付插件,alipay payment

  • 0.0.2
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-80%
Maintainers
1
Weekly downloads
 
Created
Source

Cordova 支付宝支付插件

还在开发中,待加入订单信息

支持的系统

  • iOS
  • Android

手动安装

  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" value="$PRIVATE_KEY" />
    

改成

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

**注意**:总共有两处

3. 安装

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

使用方法

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

参数说明

  • tradeNo 这个是支付宝需要的,应该是一个唯一的ID号
  • subject 这个字段会显示在支付宝付款的页面
  • body 订单详情,没找到会显示哪里
  • price 价格,支持两位小数
  • fromUrlScheme 支付完成跳转的URL Scheme(iOSAndroid),可以使用这个Cordova插件定义你的App的Scheme

调用pay方法会打开支付宝支付页面进行支付(如果有安装支付宝钱包的话会打开支付宝钱包),支付完成之后会跳回到程序,会跳到fromUrlScheme定义的程序页面, 如上面的例子会返回你的程序的/afterPaymentSuccess路径所定义的页面,并且支付结果会附加到这个url后面。你可以在程序中调试来确定该怎么处理。

为什么不能自动安装

正常情况下,应该是可以使用下面的命令安装的

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

但是因为private key里面有时会有等号(=),而当前版本的cordova(v5.1.1)有一个bug,当参数中有等号(=)的时候就不能正常解析变量值了。这个bug已经在cordova的master上已经修好了,但是还没有发布。

Liscense

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

Keywords

FAQs

Package last updated on 05 Aug 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc