Code Monkey home page Code Monkey logo

alipay's People

Contributors

dependabot[bot] avatar jerryhu avatar luncher avatar rycheung avatar snowyu avatar wangzhilongh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

alipay's Issues

Alipay is not a constructor

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

接口返回码 `code` 参数的类型不统一

定义上说接口返回是统一的

{
    "code": string,
    "message": string,
    "data": string
}

实际使用的时候,发现其中的 code 参数在有些接口如 createAppOrder, createPageOrder 等是number 类型,在其他接口是 string

看代码发现是这样的。建议把错误码改成常量然后用到的时候用常量就好,这样会不会好一点?

希望如果有空能修改一下,非常感谢啦~

config上的ALIPAY_API_LIST的问题

ALIPAY_API_LIST只有'alipay.trade.query'和'alipay.trade.app.pay',我在做退款申请的时候在makeResponse中respType会是undefined,导致response[respType]时会报错Cannot read property 'code' of undefined,这里是不是有问题??

BUG: 查询账单下载地址 billDownloadQuery 接口出错

查询账单下载地址 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 的原因

[bug] 缺少配置项

在源码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': '异步通知' // 自定义
},

verifyPayment报错Error: Not Found responseType

在测试验签模块时,出现报错。
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

请问是什么原因,谢谢!

异步回调问题

拿到支付宝异步回调的报文,直接用verifyPayment 怎么验证不成功?返回错误 code:-1 message:error

memo is required. But Not Found In params

手机支付过程中,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: {} }的错误。

安装后报错 Error: Cannot find module 'src/config'

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)

异步通知校验makeNotifyResponse schema验证失败问题

版本信息

"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

服务器同步/异步通知参数说明

解决方案

  • 方法1: 完善代码中的schema
  • 方法2: 移除对异步通知对校验

queryOrder 订单查询接口,一直返回‘交易不存在’?

我创建订单没问题,,"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"}

TypeError: Cannot read property 'app_id' of null

`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)`

请问如何设置为沙箱测试模式?

我写了process.env.NODE_ENV = ‘test’,支付宝的页面显示“错误代码 invalid-signature 错误原因: 验签出错,sign参数值非法,请检查是否做了正确的url编码”,是不是哪里错了

你好 在支付成功后通过 回调地址里面有appid等信息

在回调成功后的地址里面有 version=1.0 app_id sign_type=RSA2 等信息 如何关闭这个
还有就是
var result = service.createPageOrderURL(orderData, alipayBaseParams)
创建url后这个assert(result.code == 0, result.message)的作用是用来验证url是否存在吗 还是别的作用....求大佬解答

app支付后,verifyPayment同步校验一直不过

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",。。。。}"
这里是不是少了什么?

订单查询报错 Cannot read property \'code\' of undefined',

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: {} }

这个报错没看懂,求帮助。

app 签名 notify_url 正确的写法是?

因为文档没有说,现在不是很确定,俩种方式都试过了,但是没有异步回掉成功,现在不确定是自己配置的问题,还是什么其他的问题,但是签名种出现了 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'
});

支付测试GETWAY 可否设置成config 配置

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",
}

文件编译后的代码错误,路径是/dist/validator/index.js

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;
改成这样才行

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.