百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
N

node-apple-receipt-verify

> 编程语言
开源

一个用于iOS的In-App-Purchase接收验证的Node.js模块.

99 stars0 点赞3 次浏览
访问官网GitHub

工具介绍

一个用于iOS的In-App-Purchase接收验证的Node.js模块.

node-apple-receipt-verify

A Node.js module for Apple In-App-Purchase receipt validation for iOS.

Note: Storekit Versions:

This works module with the (older) Storekit API, the newer Storekit 2 uses JWT tokens which can be verified without an API call to Apple

Changes

See CHANGELOG

Debug Logging

The module can optionally turn on verbose debug log.

In order to enable the verbose logging, give the following to .config():

javascript
var appleReceiptVerify = require('node-apple-receipt-verify');
appleReceiptVerify.config({
  verbose: true
});

Methods

.config(options [object])

Initializes module. Can be called more than once to reconfigure module.

options: supports following keys:

  • secret [string] [optional] - Apple shared secret (See it in iTunes Connect: Go to My Apps > (select your app) > In-App Purchases > View or generate a shared secret) [required]
  • verbose [boolean] [optional] - verbose logging switch, false by default. [optional]
  • environment [array of strings] [optional] - defines environments used for receipt validation on Apple servers. Supported environments: 'sandbox', 'production'. The sequence is important. Defaults to ['production'].
  • ignoreExpiredError [boolean] [optional] - if true, then does not return error if receipt is expired. Default is false.
  • ignoreExpired [boolean] [optional] - if true, then expired purchases are skipped. Defaults to true.
  • extended [boolean] [optional] - if true, then purchases contains extended information. Defaults to false. (since v1.1.1)
  • excludeOldTransactions [boolean] [optional] - If value is true, response includes only the latest renewal transaction for any subscriptions (Apple Documentation).
  • doNotRemoveNonSubscriptions [boolean] [optional] - If true, then lifetime purchases also will be returned.

.config()

Returns current global config.

.validate(options [object], callback [function (err, purchasedProducts [array of objects ])])

Validates an in-app-purchase receipt.

options: supports keys:

  • receipt [required] - base64 encoded receipt.
  • device [optional] - iOS vendor identifier. NOTE: [deprecated]

You can also add options passed to config(), they override default options.

callback [optional]: receives error or list of purchased products embedded in receipt.

The purchased products list has structure:

[
{
    bundleId: ,
    transactionId: ,
    productId: ,
    purchaseDate: ,
    quantity: ,
    *expirationDate: ,
    *isTrialPeriod: ,              // only for subscriptions and if extented = true
    *isInIntroOfferPeriod: ,       // only for subscriptions and if extented = true, since v1.5.1
    *environment: ,                 // only if extented = true
    *originalPurchaseDate: ,        // only if extented = true
    *applicationVersion: ,          // only if extented = true
    *originalApplicationVersion:    // only if extented = true
},
...
]

Usage

…

Errors

Errors can have additional optional properties:

  • isRetryable (bool) - true if Apple service recommends to retry request a bit more later.
  • appleStatus (number) - status returned by Apple validation service.

Special errors

EmptyError - returned in case of receipt without purchase
const appleReceiptVerify = require('node-apple-receipt-verify');
const EmptyError = appleReceiptVerify.EmptyError;
ServiceUnavailableError - returned when Apple validation service returned, e.g: 503, etc.

You can retry request later.

Author

  • Siarhei Ladzeika >

LICENSE

This project is licensed under the MIT License - see the LICENSE file for details

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

JavaScript

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言