luncher / alipay Goto Github PK
View Code? Open in Web Editor NEWAlipay Node.js SDK 基于最新版蚂蚁金服 支付宝开发文档
License: MIT License
Alipay Node.js SDK 基于最新版蚂蚁金服 支付宝开发文档
License: MIT License
网页支付的异步回调地址在哪里配?
查询账单下载地址 billDownloadQuery 接口报错:
2018-07-24 11:50:11,094 ERROR 1093 [-/127.0.0.1/-/0ms GET /] nodejs.TypeError: Cannot read property 'code' of undefined
at isSucceed (/.../node_modules/alipay-mobile/lib/index.js:99:43)
at Alipay.makeResponse (/.../node_modules/alipay-mobile/lib/index.js:107:11)
at /.../node_modules/alipay-mobile/lib/index.js:132:23
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
可能是 config.ALIPAY_API_LIST列表未添加 alipay.data.dataservice.bill.downloadurl.query 的原因
{ code: '-2',
message: 'permission denied'
...}
我创建订单没问题,,"out_trade_no":"117814570259111501"用这个订单号创建的,可以正常打开支付。但一直查询结果时,一样用这个out_trade_no,一直返回‘交易不存在’?
{"code":"-1","data":{"code":"40004","msg":"Business Failed","sub_code":"ACQ.TRADE_NOT_EXIST","sub_msg":"交易不存在","buyer_pay_amount":"0.00","invoice_amount":"0.00","out_trade_no":"117814570259111501","point_amount":"0.00","receipt_amount":"0.00"},"message":"error"}
const data = {
subject: '辣条',
out_trade_no: '1232423',
total_amount: '100',
product_code:"FAST_INSTANT_TRADE_PAY"
}
我实现了alipay.fund.trans.order.query(查询转账订单接口) 可以添加成员,并且提交代码吗,
在源码src/config/index.js中有配置项如下,其中至少缺少了alipay.trade.precreate
,导致调用相关API时在makeResponse中不能正确处理。
ALIPAY_API_LIST: {
'alipay.trade.query': '订单查询',
'alipay.trade.refund': '交易退款',
'alipay.trade.cancel': '取消订单',
'alipay.trade.close': '关闭交易',
'alipay.trade.create': '创建交易',
'alipay.trade.order.settle': '交易结算',
'alipay.trade.fastpay.refund.query': '交易退款查询',
'alipay.trade.app.pay': '生成创建订单所需参数',
'alipay.fund.trans.toaccount.transfer': '单笔转账到支付宝账户接口',
'async.notify': '异步通知' // 自定义
},
NodeJS代码
const service = new Alipay(options) //配置没有问题生成支付链接都可以
console.log(out_trade_no) //订单号也没有问题
const verify = await service.queryOrder({ out_trade_no });
console.log(verify)
报错信息
{ code: '-1',message: 'Cannot read property 'code' of undefined',data: {} }
这个报错没看懂,求帮助。
拿到支付宝异步回调的报文,直接用verifyPayment 怎么验证不成功?返回错误 code:-1 message:error
如题,想在支付宝小程序里,集成支付宝支付的功能。可以用这个开源项目吗?谢谢
定义上说接口返回是统一的
{
"code": string,
"message": string,
"data": string
}
实际使用的时候,发现其中的 code
参数在有些接口如 createAppOrder
, createPageOrder
等是number
类型,在其他接口是 string
看代码发现是这样的。建议把错误码改成常量然后用到的时候用常量就好,这样会不会好一点?
希望如果有空能修改一下,非常感谢啦~
function Validator(presets, params) {
this.result = {};
this.params = null;
this.presets = null;
this.paramsKeys = null;
this.presetKeys = null;
this.invalid = false;
this.message = 'Success';
this.paramsKeys = Object.keys(params);
this.presetKeys = Object.keys(presets);
}
这个地方的两个参数没有初始化
this.paramsKeys = params;
this.presetKeys = presets;
改成这样才行
https://docs.open.alipay.com/270/105899/
alipay.trade.page.pay
在回调成功后的地址里面有 version=1.0 app_id sign_type=RSA2 等信息 如何关闭这个
还有就是
var result = service.createPageOrderURL(orderData, alipayBaseParams)
创建url后这个assert(result.code == 0, result.message)的作用是用来验证url是否存在吗 还是别的作用....求大佬解答
internal/modules/cjs/loader.js:582
throw err;
^
Error: Cannot find module 'src/config'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:580:15)
at Function.Module._load (internal/modules/cjs/loader.js:506:25)
at Module.require (internal/modules/cjs/loader.js:636:17)
at require (internal/modules/cjs/helpers.js:20:18)
Alipay is not a constructor
const Alipay = require('alipay-mobile');
const options = {
app_id: '***',
appPrivKeyFile: read('./key/private-key.pem'),
alipayPubKeyFile: read('./key/public-key.pem'),
gatewayUrl: 'https://openapi.alipaydev.com/gateway.do'
}
const service = new Alipay(options);
开启应用提示 Alipay is not a constructor
版本3.0.9
ALIPAY_API_LIST只有'alipay.trade.query'和'alipay.trade.app.pay',我在做退款申请的时候在makeResponse中respType会是undefined,导致response[respType]时会报错Cannot read property 'code' of undefined,这里是不是有问题??
在测试验签模块时,出现报错。
code:
const info = {
"memo" : "xxxxx",
"result" : {
"alipay_trade_app_pay_response":{
"code":"10000",
"msg":"Success",
"app_id":"2014072300007148",
"out_trade_no":"081622560194853",
"trade_no":"2016081621001004400236957647",
"total_amount":"0.01",
"seller_id":"2088702849871851",
"charset":"utf-8",
"timestamp":"2016-10-11 17:43:36"
},
"sign":"NGfStJf3i3ooWBuCDIQSumOpaGBcQz+aoAqyGh3W6EqA/gmyPYwLJ2REFijY9XPTApI9YglZyMw+ZMhd3kb0mh4RAXMrb6mekX4Zu8Nf6geOwIa9kLOnw0IMCjxi4abDIfXhxrXyj********",
"sign_type":"RSA2"
},
"resultStatus" : "9000"
}
const result = service.verifyPayment(info)
报错信息:
throw new Error('Not Found responseType: ' + String(response.msg));
^
Error: Not Found responseType: Success
请问是什么原因,谢谢!
"version": "3.0.8",
代码中的参数和alipay请求传送过来的参数不一致,导致schema验证失败.
代码中的schema(alipay/src/validator/schema/notify.ts
):
export const notifySchema: Joi.ObjectSchema = Joi.object({
notify_time: Joi.string().required(),
notify_type: Joi.string().required(),
notify_id: Joi.string().required(),
app_id: Joi.string().required(),
version: Joi.string().required(),
sign_type: Joi.string().required(),
sign: Joi.string().required(),
trade_no: Joi.string().required(),
out_trade_no: Joi.string().required()
})
alipay请求传送的参数(取自alipay异步通知示例):
total_amount:2.00
buyer_id:2088102116773037
body:大乐透2.1
trade_no:2016071921001003030200089909
refund_fee:0.00
notify_time:2016-07-19 14:10:49
subject:大乐透2.1
sign_type:RSA2
charset:utf-8
notify_type:trade_status_sync
out_trade_no:0719141034-6418
gmt_close:2016-07-19 14:10:46
gmt_payment:2016-07-19 14:10:47
trade_status:TRADE_SUCCESS
version:1.0
sign:kPbQIjX+xQc8F0/A6/AocELIjhhZnGbcBN6G4MM/HmfWL4ZiHM6fWl5NQhzXJusaklZ1LFuMo+lHQUELAYeugH8LYFvxnNajOvZhuxNFbN2LhF0l/KL8ANtj8oyPM4NN7Qft2kWJTDJUpQOzCzNnV9hDxh5AaT9FPqRS6ZKxnzM=
gmt_create:2016-07-19 14:10:44
app_id:2015102700040153
seller_id:2088102119685838
notify_id:4a91b7a78a503640467525113fb7d8bg8e
验证支付结果和异步验证校验需要传的参数具体是什么,全部必须传的参数有哪些?比如memo,result各是指什么?
能解答一下嘛!非常感谢
现在似乎只有Alipay对象初始化的时候才会生效,之后每个请求单独设置不生效的
这个问题还在,并且3.0.4下载不来,只能npm3.0.3
`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'
}
const result = service.createOrder(data)`
手机支付过程中,meno 有可能返回的值为空字符串
https://doc.open.alipay.com/doc2/detail.htm?treeId=204&articleId=105462&docType=1
{
memo = "";
result = "{
\"alipay_trade_wap_pay_response\":{
\"code\":\"10000\",
\"msg\":\"Success\",
\"out_trade_no\":\"70501111111S001111119\",
\"trade_no\":\"2014112400001000340011111118\",
\"total_amount\":9.00,
\"seller_id\":\"2088111111116894\"
},
\"sign\":
\"WLRdHxAfnP1Z+lTyiu9LoFRbw80rCKXz0PLBtB9EnLb6Jsq6R0TuX0BkWXF9hhKmbtdXHzMq4OM9l9H7IGs92kTvJbmvp80vnLcx+i8KOCqveVoXJrO8v0QtX1xuEQpyrmfG9BQLX8p5dw0+8iba2BeHVjGueQGmUwU72wXiWtg=\"
}";
resultStatus = "9000";
}
因此在verifyPayment的时候meno不应该是required,
memo: {
type: 'string',
// required: true,
},
result: {
type: 'object', // --->
required: true
},
而且返回的result 应该是 string类型的数据.
但是当我将result转化为object的时候,会返回{ code: '-1', message: 'result. Length equal 0.', data: {} }的错误。
在支付宝异步通知时获取到的参数为空 使用express模块
请问 有遇到过吗
初步 怀疑是 支付宝 数据 不是规范数据?
const basicParams = {
return_url: 'http://xxx.com'
}
这里的return_url是支付后返回的url链接吗?
为啥没有notify_url回调响应配置?
感觉很不安,为什么只有异步通知校验了签名
签名是用RSA2吗?APP支付时报错,{"errMsg":"requestPayment:fail [payment支付宝:62009]未知错误","errCode":-100,"code":-100}
安装的版本是3.0.5,依旧有这个报错
希望把这个功能加进去。原谅我伸手党了,es6来不及看。
能不能做个单笔付款到支付宝的接口非常感谢!
如题
app支付成功支付宝返回的url传给后台解析出的result为"{"alipay_trade_app_pay_response":{"code":"10000","msg":"Success",。。。}"
报错为
"Cannot use 'in' operator to search for 'alipay_trade_query_response' in {"alipay_trade_app_pay_response":{"code":"10000","msg":"Success",。。。。}"
这里是不是少了什么?
nodejs: v8.9.4
alipay-mobile: v2.2.1
我用你项目中测试用例里的 app_priv_key.pem 也会报这个错。
麻烦看看呗,是啥问题导致的呢?
const isTest = process.env.NODE_ENV === 'test'
const GETWAY = isTest ? config.ALIPAY_DEV_GETWAY : config.ALIPAY_GETWAY
这个config.ALIPAY_DEV_GETWAY 可否增加一个手动配置的方法哈老哥😄
const options = {
app_id: '2016080100137766',
appPrivKeyFile: read('./keys/app_priv_key.pem'),
alipayPubKeyFile: read('./keys/alipay_public_key.pem'),
"gatewayUrl": "https://openapi.alipaydev.com/gateway.do",
}
因为文档没有说,现在不是很确定,俩种方式都试过了,但是没有异步回掉成功,现在不确定是自己配置的问题,还是什么其他的问题,但是签名种出现了 notify_url
先谢过了 🙏
第一种
const alipayResult = await alipay.createOrder({
subject: 'xxx',
out_trade_no: 'xxx',
total_amount: '0.01',
notify_url: 'https://xxxx.com/xxxx'
});
第二种
const alipayResult = await alipay.createOrder({
subject: 'xxx',
out_trade_no: 'xxx',
total_amount: '0.01'
}, {
notify_url: 'https://xxxx.com/xxxx'
});
我写了process.env.NODE_ENV = ‘test’,支付宝的页面显示“错误代码 invalid-signature 错误原因: 验签出错,sign参数值非法,请检查是否做了正确的url编码”,是不是哪里错了
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.