npm package: @suxhk/hmp-jssdk
Description: 河马付收银台 JS_SDK
Author: SUXH
Latest version: 0.0.2

<div align="center">
      <a href="https://www.sandpay.com.cn/">
        <img
          style="padding: 100px 0"
          src="https://www.hmpay.com.cn/template/default/index/img/product/gywm_img_02.png"
        />
      </a>
      <h1>河马付收银台JSSDK</h1>
      <p></p>
      <p>
        <a href="https://www.hmpay.com.cn/">河马付官网</a> |
        <a href="https://www.yuque.com/luokefeile/qf3ln5/yhgshl7umc6wsqar?singleDoc#"
          >语雀中文文档</a
        >
      </p>
      <p>
        <img
          src="https://img.shields.io/npm/v/@suxhk/hmp-jssdk?style=flat-square"
          alt="version"
        />
        <img
          src="https://img.shields.io/npm/l/@suxhk/hmp-jssdk.svg"
          alt="licence"
        />
        <img
          src="https://img.badgesize.io/https:/unpkg.com/@suxhk/hmp-jssdk/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/hmp-jssdk&query=$.install.pretty&label=install%20size&style=flat-square
"
          alt="install size"
        />
        <img
          src="https://img.shields.io/bundlephobia/minzip/@suxhk/hmp-jssdk?style=flat-square)](https://bundlephobia.com/package/@suxhk/hmp-jssdk@latest"
          alt="minzipped size"
        />
        <img
          src="https://img.shields.io/npm/dm/@suxhk/hmp-jssdk.svg?style=flat-square)](https://npm-stat.com/charts.html?package=@suxhk/hmp-jssdk"
          alt="downloads"
        />
        <img
          src="https://nodei.co/npm/@suxhk/hmp-jssdk.png?mini=true"
          alt="install"
        />
      </p>
    </div>

# Useing For Vue React Html



| **Vue2↓**
<img style="width:100%;margin: 0 auto;" src="https://faspay-oss.sandpay.com.cn/public/hmp/img/vue2.png" /><img style="width:100%;margin: 0 auto;" src="https://faspay-oss.sandpay.com.cn/public/hmp/img/vue21.png" /> |
| ------------------------------------------------------------ |
| **Vue3↓**
<img style="width:100%;margin: 0 auto;" src="https://faspay-oss.sandpay.com.cn/public/hmp/img/vue3.png" /><img style="width:100%;margin: 0 auto;" src="https://faspay-oss.sandpay.com.cn/public/hmp/img/vue31.png" /> |
| **React↓**
<img style="width:100%;margin: 0 auto;" src="https://faspay-oss.sandpay.com.cn/public/hmp/img/react.png" /><img style="width:100%;margin: 0 auto;" src="https://faspay-oss.sandpay.com.cn/public/hmp/img/react1.png" />  |
| **Html+JS↓**
<img style="width:100%;margin: 0 auto;" src="https://faspay-oss.sandpay.com.cn/public/hmp/img/html.png" /><img style="width:100%;margin: 0 auto;" src="https://faspay-oss.sandpay.com.cn/public/hmp/img/html1.png" /> |











## FrameworkSupport

| <img style="width:200px; margin: 0 auto;" src="https://faspay-oss.sandpay.com.cn/public/hmp/img/logo-vue.png" /> | <img style="width:200px; margin: 0 auto;" src="https://faspay-oss.sandpay.com.cn/public/hmp/img/logo-react.png" alt="React" /> | <img style="width:200px; margin: 0 auto;" src="https://faspay-oss.sandpay.com.cn/public/hmp/img/logo-html.png" alt="Html+JS" /> |
| :----------------------------------------------------------: | ------------------------------------------------------------ | ------------------------------------------------------------ |
|      <div style="text-align: center;">Vue2-Vue3✔</div>       | <div style="text-align: center;">React16 -18✔</div>          | <div style="text-align: center;">HTML + JavaScript✔</div>    |



## Installing

### Package manager

```bash
$ npm install @suxhk/hmp-jssdk
$ yarn add @suxhk/hmp-jssdk
$ pnpm add @suxhk/hmp-jssdk
```

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

```js
import {
  queryTradeRecordInfo, // 查询订单信息
  getSandPayTN, // 杉德宝扫码 01040001 H5
  getAggregateCode, // 聚合码 01000001 H5
  getWeChatPublicPayment, // 微信公众号 01010002 H5
  getCloudFunction, // H5包装云函数 01010006 H5
  getAliPayUrl, // H5包装支付宝生活号 01020002 H5
  getUnionPayCloudFunction, // 云函数H5（云微） 01030006 H5
  // 银联快捷H5 01030003 H5 暂不支持
} from '@suxhk/hmp-jssdk'
```



If you use `require` for importing

```js
const { queryTradeRecordInfo, ... }  = require('@suxhk/hmp-jssdk')
```



You can import the library using `browser`

```html
<script src="https://faspay-oss.sandpay.com.cn/public/hmp/index.iife.js"></script>

<script>
  console.log(window.SandpaySdk)
</script>

<script>
  // For Example
  window.SandpaySdk.queryTradeRecordInfo({
    tokenId: '2023*****************1234'
  	}).then((result) => {
      console.log('🚀', result)
    }).catch((error) => {
      console.log('❌', error)
    })
</script>

```



### CDN

Using sandpay CDN:

```html
<script src="https://faspay-oss.sandpay.com.cn/public/hmp/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 { queryTradeRecordInfo } from '@suxhk/hmp-jssdk'

// the `tokenId` is required
queryTradeRecordInfo({ tokenId: '2023*****************1234' })
  .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` is required.

```js
{
  // `tokenId`  is returned when the order is ordered
  tokenId: '2023*****************1234'
}

```


## Promises

@suxhk/hmp-jssdk depends on a native ES5/6 Promise implementation to be supported.



## Handling Errors

Below is a list of potential axios identified error
| Function               | Definition                      | ReturnPromises  |
| ---------------------- | ------------------------------- | --------------- |
| getSandPayTN       | 杉德宝扫码 01040001 SDK/H5 | Promise<Html>   |
| getAggregateCode        | 聚合码 01000001 H5        | Promise<Url>    |
| getWeChatPublicPayment           | 微信公众号 01010002 H5     | Promise<SandTn> |
| getCloudFunction | H5包装云函数 01010006 H5          | Promise<any>    |
| getAliPayUrl       | H5包装支付宝生活号 01020002 H5       | Promise<any>    |
| getUnionPayCloudFunction           | 云函数H5（云微） 01030006 H5  | Promise<Scheme> |
| queryTradeRecordInfo   | 查询订单信息                    | Promise<Info>   |
| 暂不支持       | 银联快捷H5 01030003 H5    | Promise<Scheme> |



## License

[MIT](LICENSE)



## Thanks