Skip to content

transformer.js

James ZHANG edited this page Apr 20, 2021 · 2 revisions

Transformer

An Axios customizaton transform.

Kind: global class

Transformer.mchid

Kind: static property of Transformer
Properties

Name Type Description
mchid string The merchant ID

Transformer.secret

Kind: static property of Transformer
Properties

Name Type Description
secret string The merchant secret key string

Transformer.request

Kind: static property of Transformer
Properties

Name Type Description
request array @see {import('axios').AxiosTransformer}

Transformer.response

Kind: static property of Transformer
Properties

Name Type Description
response array @see {import('axios').AxiosTransformer}

Transformer.signer(data) ⇒ object

Compose the pre-request data signature

Note here: While the [MCHID] is set, then checking the input data matching with it.

Kind: static method of Transformer
Returns: object - - With data signature

Param Type Description
data object The API request parameters

Transformer.toXml(data) ⇒ string

Translation the javascript's object to the XML string

Kind: static method of Transformer
Returns: string - - XML string

Param Type Description
data object The API request parameters

Transformer.toObject(xml) ⇒ object

Translation the XML string to the javascript's object.

Kind: static method of Transformer
Returns: object - - Parsed as object for xml

Param Type Description
xml string XML string

Transformer.verifier(data) ⇒ object

Validation the response data with the sign string.

Kind: static method of Transformer
Returns: object - - The API response data

Param Type Description
data object The API response data