Options
All
  • Public
  • Public/Protected
  • All
Menu

Class WapEntrust

H5签约

const pay = new WapEntrust({
  appId: "wxb80e5bddb2d804f3",
  key: "6Q9VX4N3WTBM9G9XBL7H1L9PB9ANHLY7",
  mchId: "1434712502",
  pfx: fs.readFileSync(path.resolve(__dirname, "cert.p12"))
});
see

https://pay.weixin.qq.com/wiki/doc/api/pap.php?chapter=18_16&index=3

Hierarchy

Index

Constructors

constructor

Properties

appId

appId: string

公众账号ID

debug

debug: boolean = false

仿真模式开关

key

key: string

密钥

keyForDebug

keyForDebug: string

测试用验签密钥

mchId

mchId: string

商户号

pfx

pfx: Buffer

证书

Methods

Protected completeURL

  • completeURL(base: string): string

contractNotify

  • contractNotify(info: types.ContractNotifySuccess | types.ContractNotifyFail, handler: types.ContractNotifyHandler): Promise<string>
  • 签约,解约结果通知

    router.post("/wechatpay/notify/contract", (req, res) => {
      getXMLBody(req, options).then(data => {
        pay
          .contractNotify(data, async parsedData => {
            if (!pay.verifySign(parsedData)) {
              // 签名校验失败
            }
            if (parsedData.result_code === "FAIL") {
              // 业务逻辑失败
            }
            // ...
            return {
              return_code: "SUCCESS",
              return_msg: "OK"
            };
          })
          .then(returnData => {
            res.set("Content-Type", "application/xml; charset=utf-8");
            res.end(returnData);
          });
      });
    });
    see

    https://pay.weixin.qq.com/wiki/doc/api/pap.php?chapter=18_17&index=5

    Parameters

    • info: types.ContractNotifySuccess | types.ContractNotifyFail
    • handler: types.ContractNotifyHandler

    Returns Promise<string>

contractOrder

Protected contractOrderBase

Protected createFetchOptions

  • createFetchOptions(url: string, usePfx?: boolean): Promise<FetchOptions>

deleteContract

downloadBill

entrust

Protected entrustBase

  • entrustBase(options: any): Promise<any>

Protected getKey

  • getKey(): string

papOrderQuery

papPayApply

papPayNotify

  • papPayNotify(info: types.PapPayNotifySuccess | types.PapPayNotifyFail, handler: types.PapPayNotifyHandler): Promise<string>
  • 扣款结果通知

    router.post("/wechatpay/notify/refund", (req, res) => {
      getXMLBody(req, options).then(data => {
        pay
          .papPayNotify(data, async parsedData => {
            if (!pay.verifySign(parsedData)) {
              // 签名校验失败
            }
            if (parsedData.result_code === "FAIL") {
              // 业务逻辑失败
            }
            // ...
            return {
              return_code: "SUCCESS",
              return_msg: "OK"
            };
          })
          .then(returnData => {
            res.set("Content-Type", "application/xml; charset=utf-8");
            res.end(returnData);
          });
      });
    });
    see

    https://pay.weixin.qq.com/wiki/doc/api/pap.php?chapter=18_7&index=10

    Parameters

    • info: types.PapPayNotifySuccess | types.PapPayNotifyFail
    • handler: types.PapPayNotifyHandler

    Returns Promise<string>

queryContract

refund

refundQuery

setDebug

  • setDebug(useDebug: boolean): Promise<void>

verifySign

  • verifySign(data: object, signType?: SignType): boolean

Generated using TypeDoc