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

@edu-fe/pay

v1.3.4

Published

A pay schema for edu-fe

Downloads

76

Readme

@edu-fe/pay


  # yarn 安装
  $ yarn add @edu-fe/pay

  # npm 安装
  $ npm i -S @edu-fe/pay

  // new 即调用支付
  const pay = new Pay({
    courseId: '',
    type: 1
  })
  console.log(pay)

支付流程


    进入
      ↓
    判断是否登录 → 否 → login() → end
      ↓ 是
  ① 判断课程是否已购买 → 是 → hasBuyCallback() -> end
      ↓ 否 -- 以上为准备阶段
  ② 判断是否传入优惠券 → 是 → ⑤
      ↓ 否
  ③ 判断是否在购买页 → 是 → ⑤
      ↓ 否
  ④ 判断是否有可用的优惠券 → 是 → gotoPayment() 去支付页 -> end
      ↓ 否
  ⑤ 判断是否免费 → 是 → free() -> ⑥
      ↓ 否
    pay() 判断端
      ↓
  ⑥ 轮询订单状态 (有orderId时直接开启轮询, 没有时先通过courseId查询orderId然后轮询)
      ↘ h5支付宝支付: returnUrl 为当前页面, 后台会加上orderId, 进入页面时如果有orderId, 则开启轮询
      ↘ h5微信支付: 返回当前页面, 根据 courseId 来查询 orderId, 开启轮询
      ↘ 微信支付: 轮询
      ↘ 其他支付: 轮询
      ↓ 成功
    gotoResult(orderId) 去结果页, 在结果页中判断是否赠送
      ↓
    end

参数

| name | typeof | required | default | description | other | |---------------------|--------------|---------------|-----------|--------------|------------------------------------------------------------| | courseId | String | yes | - | 商品Id | - | | type | Number | - | 1 | 商品类型 | 1:课程 2:专题 8:畅读卡 | | gotoResult | Function | yes | - | 去往结果页 | - | | payment | Boolean | - | false | 是否在支付页调用支付 | - | | gotoPayment | Function | - | - | 去往支付页 | 当 payment 不为 true 时会被调用, 如果没有传递 gotoPayment, 则直接执行支付 | | couponId | String | - | - | 优惠券id | - | | price | Number | - | - | 价钱 | 不一定是实际支付价钱, 用于判断是否免费 | | free | Boolean | - | false | 是否是免费支付 | 为 true 不会再判断 price 参数 | | from | String | - | 'edu_pay' | 订单来源 | 先取传入参数, 未传入则去链接中的 from 字段, from 字段为空时使用 'edu_pay' | | isSend | Boolean | - | false | 是否是赠送 | 赠送课程成功会调用 sendCallback | | theme | Number | - | 1 | 赠送主题 | isSend 为 true 时会用到 | | payWay | Number | yes when h5 | - | 下单方式 | 9:支付宝 10:微信支付 (如果h5支付时没传, 则调用 gotoPayment) | | thirdSession | String | yes when wxmp | - | 小程序用户信息 | - | | token | String | - | - | 分享唯一标示 | 用于分销 | | hasBuyCallback | Function | - | - | 已购买回调 | 几乎是必须 | | ~~sendCallback~~ | ~~Function~~ | - | - | ~~赠送回调(废弃)~~ | ~~isSend 为 true 时会用到~~ | | ~~successCallback~~ | ~~Function~~ | - | - | ~~成功回调(废弃)~~ | ~~若 isSend 为true, 则先调用 sendCallback, 再调用 successCallback~~ |

实例属性和方法(有用的)

| name | async function | description | other | |-------------------------------------|----------------|-------------|---------------------| | params | - | 参数集合 | 传进去的和内部处理过的 | | wpsSid | - | 用户id | - | | resultData | - | 支付结果返回数据 | { orderId, giftId } | | getWpsSid() | yes | 获取用户id | 重新获取id | | getFrom() | no | 获取from | - | | checkLogin(callback) | yes | 检查登录并调用 | - | | checkCourse(courseId, type, wpsSid) | yes | 检查课程是否已购买 | - | | checkCoupon(courseId, type, wpsSid) | yes | 检查课程是否有可用优惠 | - | | pay() | yes | 支付 | new 时会被调用 | | pay5() | yes | 从第五步开始的支付 | - | | startLoop() | no | 开启订单轮询 | - | | stopLoop() | no | 结束订单轮询 | - | | finish() | no | 支付成功 | - |