{"id":28226031,"url":"https://github.com/rh1tech/hiap","last_synced_at":"2025-06-13T00:31:14.159Z","repository":{"id":57263967,"uuid":"303416164","full_name":"rh1tech/hiap","owner":"rh1tech","description":"Huawei In-App Purchase Server Tools","archived":false,"fork":false,"pushed_at":"2020-10-12T17:06:13.000Z","size":23,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-26T18:04:48.988Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rh1tech.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-10-12T14:23:36.000Z","updated_at":"2025-03-11T23:29:13.000Z","dependencies_parsed_at":"2022-08-25T02:51:48.054Z","dependency_job_id":null,"html_url":"https://github.com/rh1tech/hiap","commit_stats":null,"previous_names":["rh1tech/hiap"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/rh1tech/hiap","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rh1tech%2Fhiap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rh1tech%2Fhiap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rh1tech%2Fhiap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rh1tech%2Fhiap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rh1tech","download_url":"https://codeload.github.com/rh1tech/hiap/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rh1tech%2Fhiap/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259554887,"owners_count":22875891,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-05-18T11:10:11.067Z","updated_at":"2025-06-13T00:31:14.151Z","avatar_url":"https://github.com/rh1tech.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Huawei In-App Purchase (IAP) Server Tools\n\nA set of server tools that allows you to check products purchased by the user in the application.\n\nInstall from NPM:\n\n```npm i hiap --save```\n\nUse in your code:\n\n```javascript\nconst HIAP = require(\"hiap\");\nconst hiap = new HIAP({\n    \"authURL\": \"https://oauth-login.cloud.huawei.com/oauth2/v2/token\",\n    \"ordersURL\": \"https://orders-drru.iap.hicloud.com\",\n    \"clientId\": \"123456789\",\n    \"clientSecret\": \"secret key string\",\n    \"publicKey\": \"public key string\"\n});\nconst token = hiap.getAppAccessToken();\nconsole.log(token);\n```\n\nMethods available:\n\n* async **getAppAccessToken()**\n* verifyPurchaseData(data, signature)\n* async **verifyProduct**(productId, purchaseToken, repeat = false)\n* async **getCancelledProducts**(startAt = parseInt(new Date().getTime() / 1000, 10) - 2592000, maxRows = 1000, continuationToken, type = 0, repeat)\n\n## getAppAccessToken\n*Method is async*.\n\nThis method is used to obtain an authorization token from the Huawei server.\n\nParameters:\n\n* No parameters\n\nReturns:\n\n* A token string when operation is successful, error otherwise.  \n\n## verifyPurchaseData\n\nThe method is used to verify the received purchase data and the corresponding signature.\n\nParameters (*all parameters are mandatory*):\n\n* **data** is a data string to verify\n* **signature** is a signature string received on purchase\n\nReturns:\n\n* Either **true** or **false**\n\n## verifyProduct\n\nThe method is used to check the availability of purchase data on the Huawei side.\n*Method is async*.\n\nParameters (*all parameters are mandatory*):\n\n* **productId** is a string which indicates the desired Product ID\n* **purchaseToken** is a purchase token string received from Huawei side\n\nReturns:\n\n* Objects which includes the **purchaseTokenData** if successful, error otherwise\n* More information: [Huawei Developers](https://developer.huawei.com/consumer/en/doc/development/HMS-References/iap-api-order-service-purchase-token-verification-v4)\n\n## getCancelledProducts\n\nThe method is used to get a list of canceled purchases. \n*Method is async*.\n\nParameters (*all parameters are optional*):\n\n* **startAt** is a Timestamp (UTC) of the earliest canceled or refunded purchase that you want to query; if continuationToken is passed, startAt is ignored; the default value is the current timestamp minus 1 month\n* **maxRows** is a maximum number of query result records, the value is greater than 0; the default value and the maximum value are 1000\n* **type** is a query type (0 = query purchase information about consumables and non-consumables, 1 = query information about consumables, non-consumables, and subscriptions); ignored when continuationToken is passed\n* **continuationToken** is a token returned in the last query to query the data on the next page\n\nReturns:\n\n* Objects which includes the **cancelledPurchaseList** array if successful, error otherwise\n* If the token **continuationToken** is returned, another query is required\n* More information: [Huawei Developers](https://developer.huawei.com/consumer/en/doc/development/HMS-References/iap-api-cancel-or-refund-record-v4)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frh1tech%2Fhiap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frh1tech%2Fhiap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frh1tech%2Fhiap/lists"}