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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@posx/yeahpay

v1.0.18

Published

YeahPay payment integration library

Readme

@posx/yeahpay

YeahPay支付集成库,提供安全的支付接口封装,支持银行卡与二维码支付。

✨ 特性

  • 🔐 安全加密(RSA+AES、SHA-256)
  • 🏦 多种支付(银行卡、主扫、被扫)
  • 🔄 异步查询与轮询
  • 💰 退款与撤销
  • 🧪 内置模拟,便于测试
  • 📱 基于 Capacitor,无 CORS 限制
  • 📝 TypeScript 类型完整

📦 安装

npm install @posx/yeahpay

依赖要求:

  • 需要 Capacitor 环境(v5/v6/v7)
  • 如果项目未安装,需额外安装:npm install @capacitor/core

说明: 本库使用 Capacitor HTTP 插件进行网络请求,避免浏览器 CORS 限制。

🚀 快速开始

基础配置

import { YeahPayClient, IYeahPayApiConfig } from '@posx/yeahpay'

const config: IYeahPayApiConfig = {
  asyncUrl: 'https://your-yeahpay-server.com/async',
  appId: 'YOUR_APP_ID',
  deviceSn: 'YOUR_DEVICE_SERIAL',
  serverRsaPublic: 'YOUR_SERVER_RSA_PUBLIC_KEY',
  clientRsaPrivate: 'YOUR_CLIENT_RSA_PRIVATE_KEY',
  signatureKey: 'YOUR_SIGNATURE_KEY'
}

const client = new YeahPayClient(config)

简单示例

// 银行卡支付
const pay = await client.createCardCharge({ amount: '10.50', bizOrderId: 'ORDER_' + Date.now() })
if (pay.success) {
  const q = await client.queryOrder({ bizOrderId: pay.data.bizOrderId })
  if (q.data.status === 2) console.log('支付成功')
}

// 二维码主扫
await client.createQRScanCharge({ amount: '25.00', bizOrderId: 'QR_' + Date.now(), authCode: '13319...' })

// 二维码被扫(示例以微信为例)
await client.createQRCodeCharge({ amount: '15.80', bizOrderId: 'QRCODE_' + Date.now(), payWay: 'WXZF' })

🔧 API 概览

class YeahPayClient {
  constructor(config: IYeahPayApiConfig)
  createCardCharge(req: IYeahPayCreateChargeRequest): Promise<IYeahPayResponse>
  createQRScanCharge(req: IYeahPayCreateChargeRequest): Promise<IYeahPayResponse>
  createQRCodeCharge(req: IYeahPayCreateChargeRequest): Promise<IYeahPayResponse>
  queryOrder(req: IYeahPayQueryRequest): Promise<IYeahPayResponse>
  refundCardCharge(req: IYeahPayRefundRequest): Promise<IYeahPayResponse>
  cancelCardCharge(req: Omit<IYeahPayRefundRequest, 'amount'>): Promise<IYeahPayResponse>
  refundQRCharge(req: IYeahPayRefundRequest): Promise<IYeahPayResponse>
  settlement(bizSettlementFlowId: string): Promise<IYeahPayResponse>
  reprint(bizOrderId: string, bizRefundId?: string): Promise<IYeahPayResponse>
  simulateCreateCharge(req: IYeahPayCreateChargeRequest): Promise<IYeahPayResponse>
  simulateQueryOrder(req: IYeahPayQueryRequest): Promise<IYeahPayResponse>
}

interface IYeahPayApiConfig {
  asyncUrl: string; appId: string; deviceSn: string;
  serverRsaPublic: string; clientRsaPrivate: string; signatureKey: string;
}

interface IYeahPayResponse {
  success: boolean; code: string; message: string; data?: any; traceId?: string; isTestData?: boolean;
}

🧪 运行

# 测试
npm test

# 集成测试
npm run test:integration

# 构建
npm run build

示例

npx ts-node examples/basic-usage.ts

📄 许可证与支持

  • 许可证:MIT(见 LICENSE
  • Issues:https://github.com/your-org/pay-yeahpay/issues

版本:v1.0.6
最后更新:2024-08-30