npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

wcpay-notify-result

v1.0.2

Published

A package to build a result string for wechat pay notify callback

Downloads

3

Readme

wcpay-notify-result

Read by language: [Engish] [简体中文]

Description

A package to build a result string for wechat pay notify callback.

概述

一个收到微信支付服务器支付结果通知后,生成用于返回的应答字符串的库。

支付完成后,微信会把相关支付结果和用户信息发送给商户,商户需要接收处理,并返回应答。 这个包就是生成这个应答字符串信息用的。

安装

选择下列一种方式安装即可。

  • 直接安装
npm i wcpay-notify-result
  • 作为依赖项安装
npm i --save wcpay-notify-result

使用

商户程序在处理完支付核验业务逻辑后,需要给微信支付服务器返回相应的xml应答字符串。 以下3种情况,可根据实际选择使用。

  • 简单处理
var result = require('wcpay-notify-result')

// 这里是你的处理信息
// 当业务处理成功时,msg应当为空
// 否则会被当作失败
var msg = '...'
var reply = result.result(msg)
// 使用你自己的服务器相关方法返回结果
res.setHeader('content-type', 'application/xml; charset=utf-8')
res.send(reply)
  • 处理成功
var result = require('wcpay-notify-result')

// 直接视为处理成功
var reply = result.success()
// 使用你自己的服务器相关方法返回结果
res.setHeader('content-type', 'application/xml; charset=utf-8')
res.send(reply)
  • 处理失败
var result = require('wcpay-notify-result')

// 失败信息
var msg = '签名失败'
// 获取处理失败时,返回给服务器的xml字符串
var reply = result.fail(msg)
// 使用你自己的服务器相关方法返回结果
res.setHeader('content-type', 'application/xml; charset=utf-8')
res.send(reply)

API

  • function (msg)

msg 失败原因

  • function success()

  • function fail(msg)

msg 失败原因

其他方案

本节列出社区中相关问题的其他解决方案,供大家参考。

注:这些包由社区中的其他成员维护。

  • tenpay - 微信支付 for nodejs

npm GitHub

这个包通过中间件的形式对支付结果通知、退款结果通知进行处理。如果你觉得中间件比较方便,可以选择此包。

参考

微信支付开发文档:支付结果通知

协议

MIT, see LICENSE file for detail.
Copyright © 2018 Richard Libre.
Copyright © 2018 LibreRose Studio.