npm package: @suxhk/pay-platform-js
Description: 直聚通JS
Author: SUXH
Latest version: 0.0.2

<div align="center">
      <h1>@suxhk/pay-platform-js</h1>
      <p>PayPlatform For JavaScript/TypeScript</p>
      <p>
        <a href="https://www.yuque.com/sd_cw/xfq1vq/mbzcb6?singleDoc#"
          >语雀中文文档 - 密码 hze9</a
        >
      </p>
      <p>
        <img
          src="https://img.shields.io/npm/v/@suxhk/pay-platform-js?style=flat-square"
          alt="version"
        />
        <img
          src="https://img.shields.io/npm/l/@suxhk/pay-platform-js.svg"
          alt="licence"
        />
        <img
          src="https://img.badgesize.io/https:/unpkg.com/@suxhk/pay-platform-js/dist/index.iife.js?label=gzip&compression=gzip"
          alt="gzip"
        />
        <img
          src="https://img.shields.io/badge/dynamic/json?url=https://packagephobia.com/v2/api.json?p=@suxhk/pay-platform-js&query=$.install.pretty&label=install%20size&style=flat-square
"
          alt="install size"
        />
        <img
          src="https://img.shields.io/bundlephobia/minzip/@suxhk/sandpay-sdk?style=flat-square)](https://bundlephobia.com/package/@suxhk/pay-platform-js@latest"
          alt="minzipped size"
        />
        <img
          src="https://img.shields.io/npm/dm/@suxhk/pay-platform-js.svg?style=flat-square)](https://npm-stat.com/charts.html?package=@suxhk/pay-platform-js"
          alt="downloads"
        />
        <img
          src="https://nodei.co/npm/@suxhk/pay-platform-js.png?mini=true"
          alt="install"
        />
      </p>
    </div>



## Installing

### Package manager

Using npm:

```bash
$ npm install @suxhk/pay-platform-js
```


Using yarn:

```bash
$ yarn add @suxhk/pay-platform-js
```

Using pnpm:

```bash
$ pnpm add @suxhk/pay-platform-js
```

Once the package is installed, you can import the library using `import` or `require` approach:

```js
import { getCloudFunction } from '@suxhk/pay-platform-js'
```



If you use `require` for importing

```js
const { getCloudFunction }  = require('@suxhk/pay-platform-js')
```



You can import the library using `browser`

```html
<script src="https://unpkg.com/@suxhk/pay-platform-js/dist/index.iife.js"></script>

<script>
  console.log(window.PayPlatformJs)
  /**
   * {
   *	getCloudFunction: ƒ ()
   * }
   */
</script>

<script>
  // For Example
  window.PayPlatformJs.getCloudFunction({ 
      token_id: '2023******1234',
      resourceAppid: 'wx***',
      resourceEnv: 'wx***'
  	})
    .then((result) => {
      console.log('🚀', result)
    })
    .catch((error) => {
      console.log('❌', error)
    })
</script>

```



### CDN

Using unpkg CDN (ES5 UMD browser):

```html
<script src="https://unpkg.com/@suxhk/pay-platform-js/dist/index.iife.js"></script>
```
or jsdelivr CDN 
```html
<script src="https://cdn.jsdelivr.net/npm/@suxhk/pay-platform-js/dist/index.iife.js"></script>
```


## Example

> **Note** CommonJS usage
> In order to gain the TypeScript typings (for intellisense / autocomplete) while using CommonJS imports with `require()`, use the following approach:

```js
import { getCloudFunction } from '@suxhk/pay-platform-js'

// the `tokenId` is required
getCloudFunction({ 
    token_id: '2023******1234',
    resourceAppid: 'wx***',
    resourceEnv: 'wx***' 
  })
  .then(result => {
    // handle success
    console.log('🚀', result)
  })
  .catch(error => {
    // handle error
    console.log('❌', error)
  })
  .finally(()=> {
    // always executed
  })
```





## Use Function Config

These are the available config options for making requests. Only the `tokenId resourceAppid resourceEnv` is required. 

```js
{
  // `tokenId resourceAppid resourceEnv`  is returned when the order is ordered
  
  token_id: '2023******1234', // token id
  resourceAppid: 'wx***', // 资源方 AppID
  resourceEnv: 'wx***' // 资源方环境 ID
      
}

```





## Promises

@suxhk/pay-platform-js depends on a native ES5/6 Promise implementation to be [supported](https://caniuse.com/promises).



## Method

function call
| Function         | Definition       | Return value |
| ---------------- | ---------------- | ------------ |
| getCloudFunction | H5拉起微信云函数 | Promise<any> |


## Wechat  Documents

<a href="https://developers.weixin.qq.com/miniprogram/dev/wxcloud/guide/web/sdk.html"
          >Web SDK</a
        >



## License

[MIT](LICENSE)



## Thanks