alipay-sdk-node

1.1.4 • Public • Published

alipay-sdk-node

All Contributors

Build Status JavaScript Style Guide

npm download Total visitors Visitors in today


Install

 $ npm install alipay-sdk-node --save

Usage

Create Alipay Instance

e.g.

  const Alipay = require('alipay-sdk-node')
 
  /**
   *  @param app_id required
   *  @param app_private_key required
   *  @param alipay_public_key required
   *  @param notify_url required
   *  @param return_url optional, for wap pay
   *  @param sign_type optional, default is RSA2
   *  @param base_url optional, default is 'https://openapi.alipay.com/gateway.do'
   *  @param cache optional, whether cache the alipay instance or not
   * /
  const alipay = new Alipay({
    app_id: 'xxx',
    app_private_key: fs.readFileSync('filePath'),
    alipay_public_key: fs.readFileSync('filePath'),
    notify_url: 'xxx',
    sign_type: 'RSA2',
    base_url: 'https://openapi.alipaydev.com/gateway.do',
    return_url: 'xxx',
    cache: false
  })

WAP pay click

  • #getWapPageUrl(bizContent[,publicParams]): get the url of wap pay
  • params: bizContent { JSON: required }
  • params: publicParams { JSON: optional }, override the public params
  • return: String

e.g.

  alipay.getWapPageURL({
    subject: 'xxx',
    out_trade_no: 'xxx',
    total_amount: 'xxx',
    product_code: 'xxx'
  }, { return_url: 'http://xxx.com/orders/result/{id}' })

APP Pay click

  • #getOrderInfoStr(bizContent[,publicParams]): get the string of order info
  • params: bizContent {JSON: required}
  • params: publicParams { JSON: optional }, override the public params
  • return: String

e.g.

  alipay.getOrderInfoStr({
    subject: 'xxx',
    out_trade_no: 'xxx',
    total_amount: 'xxx',
    product_code: 'xxx'
  })

Check sign click

  • #rsaCheck(options): check sign
  • params: request body {JSON}
  • return: Boolean

e.g.

  alipay.rsaCheck(request.body)

Refund click

  • #refund(bizContent[,callback]): refund api
  • params: bizContent {JSON}
  • return: Promise Or Callback

e.g.

  alipay.refund({
    out_trade_no: 'xxx',
    trade_no: 'xxx',
    refund_amount: 'xxx',
    out_request_no: 'xxx',
    refund_reason: 'xxx'
  })

Contributors ✨

Thanks goes to these wonderful people (emoji key):


Aaron Che

💻 🐛

This project follows the all-contributors specification. Contributions of any kind welcome!

Readme

Keywords

none

Package Sidebar

Install

npm i alipay-sdk-node

Weekly Downloads

2

Version

1.1.4

License

MIT

Unpacked Size

10.5 kB

Total Files

4

Last publish

Collaborators

  • cynosure