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

@activity-maker/payment-process

v1.0.1

Published

电商中台支付相关 SDK

Readme

电商中台支付相关 SDK

公共类型

Env

运行环境

| 值 | 说明 | | ------------ | -------- | | test | 测试环境 | | uat | UAT 环境 | | production | 生产环境 |

Goods

商品

| 参数 | 说明 | 类型 | 必填 | 默认值 | | --------- | ------------ | ----------- | ---- | ------ | | itemId | 商品 ID | string | 是 | - | | quantity | 商品数量 | string | 是 | - | | extension | 商品扩展字段 | Extension | 否 | - |

Extension

商品扩展字段

| 参数 | 说明 | 类型 | 必填 | 默认值 | | ----------- | ------------ | -------- | ---- | ------ | | sourceType | 商品来源类型 | string | 否 | - | | sourceValue | 商品来源值 | string | 否 | - |

Domain

下单用户来源

| 值 | 说明 | | --- | -------- | | 1 | 喜马拉雅 | | 2 | 开放平台 | | 3 | 知识宝 |

TradeType

交易类型

| 值 | 说明 | | --- | ---- | | 1 | 消费 | | 2 | 充值 | | 4 | 拼团 | | 5 | 买赠 |

Context

附带的业务参数,下单时会透传。object 对象,key 为 string,值为 any

支付

Author: haoran.zhang

基本用法

import React, { useEffect } from 'react';
import { Button, message } from 'antd';
import { checkWxAuth, getWxAuth, payment, PaymentProcessResponse } from '@activity-maker/payment-process'

export default () => {

  useEffect(() => {
    if (!checkWxAuth(17)) {
      getWxAuth(17).then(value => {
        // value: { ret: 0, msg: '微信授权成功' }
        // 静默授权成会自动跳转到授权链接
        if(value.ret === 0) {
          message.success(value.msg)
        }
      }).catch(reason => {
        // reason: new Error('微信授权失败')
        message.warn(reason.toString())
      })
    }
  }, [])

  const handlerClick = () => {
    payment.wechatAppPay({}, (res: PaymentProcessResponse) => {
      if(res.ret !== 0) {
        message.warn(res.msg)
      }
    })
    // ret为0,支付成功,自动跳转支付成功页
    // ret为1, 支付未成功,msg: "不在微信环境内" | "支付参数错误" | "支付取消"
    //  | "支付失败" | "微信支付参数错误" | "未知错误"
  }


  return (
    <Button type="primary" onClick={handlerClick}>
      点击微信app内支付
    </Button>
  )
};

thirdPartyId对照表

http://gitlab.ximalaya.com/x-fm/xpassport/wikis/thirdpartyid%E5%AF%B9%E7%85%A7%E8%A1%A8

API

const result: boolean = checkWxAuth(thirdPartyId: number);

const result: Promise = getWxAuth(thirdPartyId: number);

interface PaymentProcessResponse {
  ret: number;
  msg: string;
  data?: any;
}

payment.wechatAppPay(
	payInfo: any,  // 支付接口返回参数,对象类型
	callback: (res: PaymentProcessResponse) => void  // 支付回调
)

结算页

Author: Eleven

封装前往结算页

前往 H5 结算页

import React from 'react';
import { Button } from 'antd';
import { openSettlement, OpenSettlementOptions } from '@activity-maker/payment-process';

export default () => {
  const handlerClick = () => {
    const orderItems = [
      { itemId: '1010000100000452555', quantity: '1' },
      { itemId: '1011700100000120855', quantity: '1' },
      { itemId: '1010000100000551820', quantity: '1' },
      { itemId: '1011700100000222903', quantity: '1' },
      { itemId: '1034200100000226541', quantity: '1' },
      { itemId: '1010000100000550918', quantity: '1' },
    ];
    const params: OpenSettlementOptions = {
      orderItems,
      // 测试的应用标识
      appIdentifier: '9ruj3ol12h9t94kb89bjf0tobunjfurf',
    };

    openSettlement(params, 'h5', false, 'test');
  };

  return (
    <Button type="primary" onClick={handlerClick}>
      点击跳转 H5 结算页
    </Button>
  );
};

前往 RN 结算页

import React from 'react';
import { Button, message } from 'antd';
import { openSettlement } from '@activity-maker/payment-process';

export default () => {
  const handlerClick = () => {
    const isXmlyApp = /iting/i.test(window.navigator.userAgent);
    const orderItems = [
      { itemId: '1010000100000452555', quantity: '1' },
      { itemId: '1011700100000120855', quantity: '1' },
      { itemId: '1010000100000551820', quantity: '1' },
      { itemId: '1011700100000222903', quantity: '1' },
      { itemId: '1034200100000226541', quantity: '1' },
      { itemId: '1010000100000550918', quantity: '1' },
    ];
    const params: OpenSettlementOptions = {
      orderItems,
      // 测试的应用标识
      appIdentifier: '9ruj3ol12h9t94kb89bjf0tobunjfurf',
    };

    if (!isXmlyApp) {
      message.warn('请在喜马拉雅 App 内测试');
      return;
    }
    openSettlement(params, 'rn');
  };

  return (
    <Button type="primary" onClick={handlerClick}>
      点击前往 RN 结算页
    </Button>
  );
};

仅返回 URL,不跳转

import React, { useState } from 'react';
import { Button, message } from 'antd';
import { openSettlement } from '@activity-maker/payment-process';

export default () => {
  const [url, setUrl] = useState<string>();

  const handlerClick = () => {
    const isXmlyApp = /iting/i.test(window.navigator.userAgent);
    const orderItems = [
      { itemId: '1010000100000452555', quantity: '1' },
      { itemId: '1011700100000120855', quantity: '1' },
      { itemId: '1010000100000551820', quantity: '1' },
      { itemId: '1011700100000222903', quantity: '1' },
      { itemId: '1034200100000226541', quantity: '1' },
      { itemId: '1010000100000550918', quantity: '1' },
    ];
    const params: OpenSettlementOptions = {
      orderItems,
      // 测试的应用标识
      appIdentifier: '9ruj3ol12h9t94kb89bjf0tobunjfurf',
    };

    const url = openSettlement(params, 'h5', true, 'test');

    setUrl(url);
  };

  return (
    <>
      <Button type="primary" onClick={handlerClick}>
        点击获取前往 H5 结算页地址
      </Button>
      <div style={{ wordBreak: 'break-all', padding: '8px' }}>{url}</div>
    </>
  );
};

API

前往结算页

const result: undefined | string = openSettlement(options: OpenSettlementOptions, type: 'h5' | 'rn' = 'h5', onlyUrl: boolean = false, env?: Env);

参数

| 参数 | 说明 | 类型 | 必填 | 默认值 | | ------- | ------------------------------------------------------------------------------------------------------------------ | ----------------------- | ---- | ------- | | options | 结算页参数 | OpenSettlementOptions | 是 | - | | type | 类型,H5 或 RN | 'h5' \| 'rn' | 否 | 'h5' | | onlyUrl | 是否仅返回 url,不跳转 | boolean | 否 | false | | env | 指定环境,仅 H5 结算页有效,RN 结算页不需要区分打开环境。若未指定,将自动根据喜马拉雅的域名规则,运行时判断。 | Env | 否 | - |

OpenSettlementOptions

| 参数 | 说明 | 类型 | 必填 | 默认值 | | ------------- | -------------------------------------------------------------------- | ----------- | ---- | ---------------------- | | orderItems | 商品列表 | Goods[] | 是 | - | | appIdentifier | 应用标识 | string | 是 | - | | domain | 下单用户来源 | Domain | 否 | 1 | | returnUrl | 支付成功后跳转地址(无需 encode,函数内部会自动做 encode 处理) | string | 否 | window.location.href | | context | 附带的业务参数,下单时会透传 | Context | 否 | - | | tradeType | 交易类型 | TradeType | 否 | 1 | | tradeOrderNo | 交易订单号(通常不需要,后端自动生成,但是,先拿订单号再下单时必填) | string | 否 | - | | buyVip | 如果希望会员引导购买条,初始状态下是勾选,传 true | boolean | 否 | false |

返回值

当参数 onlyUrl 为 true 时,返回跳转结算页的 url,方便某些场景处理跳转(如:微信授权登录成功后,直接跳往结算页)。

订阅

Author: haoran.zhang

文档

https://notes.dingtalk.com/doc/Y7kmblblZPAN3zLq?orgId=4730678&dd_progress=false&showmenu=false