![PyPI Now Supports iOS and Android Wheels for Mobile Python Development](https://cdn.sanity.io/images/cgdhsj6q/production/96416c872705517a6a65ad9646ce3e7caef623a0-1024x1024.webp?w=400&fit=max&auto=format)
Security News
PyPI Now Supports iOS and Android Wheels for Mobile Python Development
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
mic-alipay-mobile
Advanced tools
## MARK: This package is fork from [https://github.com/Luncher/alipay](https://github.com/Luncher/alipay)
蚂蚁金服开放平台Node.js
SDK。
npm i mic-alipay-mobile -S
const fs = require('fs')
const Alipay = require('mic-alipay-mobile')
const read = filename => {
return fs.readFileSync(path.resolve(__dirname, filename))
}
//app_id: 开放平台 appid
//appPrivKeyFile: 你的应用私钥
//alipayPubKeyFile: 蚂蚁金服公钥
const options = {
app_id: '2016080100137766',
appPrivKeyFile: read('./keys/app_priv_key.pem'),
alipayPubKeyFile: read('./keys/alipay_public_key.pem')
}
const service = new Alipay(options)
const data = {
subject: '辣条',
out_trade_no: '1232423',
total_amount: '100'
}
return service.createOrder(data)
.then(result => {
assert(result.code == 0, result.message)
assert(result.message == 'success', result.message)
})
详细参数请参考接口对应的官方文档
{
'0': 'success',
'1': 'processing',
'-1': 'error',
'-2': 'permission denied',
'-3': 'sign error'
}
{
code: 错误码,
message: 错误信息,
data: 蚂蚁金服返回的原始数据//可能为空对象
}
为了方便异步处理,所有接口均返回
Promise
createOrder
用于返回给APP,传递给支付宝端发起交易申请
const service = new Alipay(options)
const data = {
subject: '辣条',
out_trade_no: '1232423',
total_amount: '100'
}
return service.createOrder(data)
.then(result => {
assert(result.code == 0, result.message)
assert(result.message == 'success', result.message)
//result.data 用于返回给APP,传递给支付宝端发起交易申请
})
createWebOrderURL
该接口用于支付宝手机网页支付,服务端调用该接口生成一个
URL
返回给客户端, 客户端拿到该URL
之后跳转到该URL发起支付请求。支付结束支付宝会跳转到客户端填写的return_url
。
const service = new Alipay(options)
const data = {
subject: '辣条',
out_trade_no: '1232423',
total_amount: '100'
}
const basicParams = {
return_url: 'http://xxx.com'
}
return service.createWebOrderURL(data, basicParams)
.then(result => {
assert(result.code == 0, result.message)
assert(result.message == 'success', result.message)
})
createPageOrderURL
const service = new Alipay(options)
const data = {
subject: '辣条',
out_trade_no: '1232423',
total_amount: '100'
}
const basicParams = {
return_url: 'http://xxx.com'
}
return service.createPageOrderURL(data, basicParams)
.then(result => {
assert(result.code == 0, result.message)
assert(result.message == 'success', result.message)
})
queryOrder
const outTradeNo = '1232423'
return service.queryOrder({ out_trade_no: outTradeNo })
.then(result => {
assert(result.code == -1, result.message)
assert(result.message == 'error', result.message)
assert(result.data.code === '40004')
assert(result.data.sub_msg === '交易不存在')
})
cancelOrder
const outTradeNo = 'foobar'
return service.cancelOrder({ out_trade_no: outTradeNo })
.then(result => {
assert(result.code == -1, result.message)
assert(result.message == 'error', result.message)
assert(result.data.code === '40004')
assert(result.data.sub_msg === '交易不存在')
})
verifyPayment
const params = {
memo: "xxxx",
result: "xxxx",
resultStatus: "xxx"
}
return service.verifyPayment(params)
makeNotifyResponse
const params = {
sign: 'xxxxxxxx',
sign_type: 'xxxxx',
...
}
return service.makeNotifyResponse(params)
在接收到蚂蚁金服服务器的订单状态变更通知之后,需要进行应答,有两种(成功、失败)应答类型:
import AlipayConfig from 'mic-alipay-mobile/config'
console.log(AlipayConfig.ALIPAY_NOTIFY_SUCCESS) // 'success'
console.log(AlipayConfig.ALIPAY_NOTIFY_FAILURE) // 'failure'
tradeClose
const params = {
out_trade_no: 'xxxxx'
}
return service.tradeClose(params)
tradeRefund
const params = {
out_trade_no: 'xxxxx'
}
return service.tradeRefund(params)
tradeRefundQuery
const params = {
out_trade_no: 'xxxxx'
}
return service.tradeRefundQuery(params)
billDownloadQuery
const params = {
bill_type: 'trade',
bill_date: '2017-05-06'
}
return service.billDownloadQuery(params)
tradePrecreate
const params = {
out_trade_no: 'xxx',
seller_id: 'asad',
total_amount: '231wawsda',
subject: '面包'
}
return service.tradePrecreate(params)
tradeSettle
const params = {
out_request_no: 'xxx'
}
return service.tradeSettle(params)
toaccountTransfer
const params = {
out_biz_no: "1234",
payee_type: 'ALIPAY_LOGONID',
payee_account: "user666",
amount: "100"
}
return service.toaccountTransfer(params)
FAQs
## MARK: This package is fork from [https://github.com/Luncher/alipay](https://github.com/Luncher/alipay)
The npm package mic-alipay-mobile receives a total of 1 weekly downloads. As such, mic-alipay-mobile popularity was classified as not popular.
We found that mic-alipay-mobile demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.