npm package: @sandpaycash/scfp-sdk
Description: 杉德全支付收银台 JS_SDK
Author: SUXH
Latest version: 0.0.1

<div align="center">
      <a href="https://www.sandpay.com.cn/">
        <img
          style="padding: 100px 0"
          src="https://raw.githubusercontent.com/SUXHK/MyPic/main/sandLogo.png"
        />
      </a>
      <h1>@sandpaycash/scfp-sdk</h1>
      <p>@sandpaycash/scfp-sdk For JavaScript/TypeScript</p>
      <p>
        <a href="https://www.sandpay.com.cn/">杉德支付官网</a> |
        <a href="https://www.yuque.com/sd_cw/xfq1vq/egqbokagas6o1vtr"
          >语雀中文文档</a
        >
      </p>
      <p>
        <img
          src="https://img.shields.io/npm/v/@sandpaycash/scfp-sdk?style=flat-square"
          alt="version"
        />
        <img
          src="https://img.shields.io/npm/l/@sandpaycash/scfp-sdk.svg"
          alt="licence"
        />
        <img
          src="https://img.badgesize.io/https:/unpkg.com/@sandpaycash/scfp-sdk/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=@sandpaycash/scfp-sdk&query=$.install.pretty&label=install%20size&style=flat-square
"
          alt="install size"
        />
        <img
          src="https://img.shields.io/bundlephobia/minzip/@sandpaycash/scfp-sdk?style=flat-square)](https://bundlephobia.com/package/@sandpaycash/scfp-sdk@latest"
          alt="minzipped size"
        />
        <img
          src="https://img.shields.io/npm/dm/@sandpaycash/scfp-sdk.svg?style=flat-square)](https://npm-stat.com/charts.html?package=@sandpaycash/scfp-sdk"
          alt="downloads"
        />
        <img
          src="https://nodei.co/npm/@sandpaycash/scfp-sdk.png?mini=true"
          alt="install"
        />
      </p>
    </div>






## Browser Support

| ![Chrome](https://raw.githubusercontent.com/alrra/browser-logos/main/src/chrome/chrome_48x48.png) | ![Firefox](https://raw.githubusercontent.com/alrra/browser-logos/main/src/firefox/firefox_48x48.png) | ![Safari](https://raw.githubusercontent.com/alrra/browser-logos/main/src/safari/safari_48x48.png) | ![Opera](https://raw.githubusercontent.com/alrra/browser-logos/main/src/opera/opera_48x48.png) | ![Edge](https://raw.githubusercontent.com/alrra/browser-logos/main/src/edge/edge_48x48.png) | ![IE](https://raw.githubusercontent.com/alrra/browser-logos/master/src/archive/internet-explorer_9-11/internet-explorer_9-11_48x48.png) |
| ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ |
| Latest ✔                                                     | Latest ✔                                                     | Latest ✔                                                     | Latest ✔                                                     | Latest ✔                                                     | 11 ❌                                                         |



## Installing

### Package manager

Using npm:

```bash
$ npm install @sandpaycash/scfp-sdk
```


Using yarn:

```bash
$ yarn add @sandpaycash/scfp-sdk
```

Using pnpm:

```bash
$ pnpm add @sandpaycash/scfp-sdk
```

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

```js
import { 
  queryTradeRecordInfo, // 查询订单信息
  getH5FastPayment, // H5快捷(WAP支付) 06030001 SDK/H5
  getQuickPayment, // 一键快捷 05030001 SDK/H5
  getSandPayTN, // 杉德宝扫码 02040001 SDK/H5
  getWeChatPublicPayment, // 微信公众号 02010002 H5
  getCloudFunction, // H5包装云函数 02010006 H5
  getAliPayUrl, // H5包装支付宝生活号 02020002 H5
  getAliPayCodeUrl // H5包装支付宝码付 02020005 H5
} from '@sandpaycash/scfp-sdk'
```



If you use `require` for importing

```js
const { queryTradeRecordInfo, ... }  = require('@sandpaycash/scfp-sdk')
```



You can import the library using `browser`

```html
<script src="https://unpkg.com/@sandpaycash/scfp-sdk/dist/index.iife.js"></script>

<script>
  console.log(window.ScfpSdk)
  /**
   * {
   *	getAliPayCodeUrl: ƒ ()
   *	getAliPayUrl: ƒ ()
   *	getCloudFunction: ƒ ()
   *	getH5FastPayment: ƒ ()
   *	getQuickPayment: ƒ ()
   *	getSandPayTN: ƒ ()
   *	getWeChatPublicPayment: ƒ ()
   *	queryTradeRecordInfo: ƒ ()
   * }
   */
</script>

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

```



### CDN

Using unpkg CDN (ES5 UMD browser):

```html
<script src="https://unpkg.com/@sandpaycash/scfp-sdk/dist/index.iife.js"></script>
```

Using jsdelivr CDN:

```html
<script src="https://cdn.jsdelivr.net/npm/@sandpaycash/scfp-sdk/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 { getAliPayCodeUrl } from '@sandpaycash/scfp-sdk'

// the `tokenId` is required
getAliPayCodeUrl({ 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

@sandpaycash/sandpay-sdk depends on a native ES5/6 Promise implementation to be [supported](https://caniuse.com/promises).



## Handling Errors

Below is a list of potential axios identified error
| Function               | Definition                      | ReturnPromises  |
| ---------------------- | ------------------------------- | --------------- |
| getH5FastPayment       | H5快捷(WAP支付) 06030001 SDK/H5 | Promise<Html>   |
| getQuickPayment        | 一键快捷 05030001 SDK/H5        | Promise<Url>    |
| getSandPayTN           | 杉德宝扫码 02040001 SDK/H5      | Promise<SandTn> |
| getWeChatPublicPayment | 微信公众号 02010002 H5          | Promise<any>    |
| getCloudFunction       | H5包装云函数 02010006 H5        | Promise<any>    |
| getAliPayUrl           | H5包装支付宝生活号 02020002 H5  | Promise<Scheme> |
| getAliPayCodeUrl       | H5包装支付宝码付 02020005 H5    | Promise<Scheme> |
| queryTradeRecordInfo   | 查询订单信息                    | Promise<Info>   |



## License

[MIT](LICENSE)



## Thanks