Skip to content

Commit 65fe74e

Browse files
authored
🤖 Merge PR DefinitelyTyped#72362 chore(node-apple-receipt-verify): Add missing originalTransactionId param by @gutwijir
1 parent a7f478a commit 65fe74e

File tree

2 files changed

+41
-8
lines changed

2 files changed

+41
-8
lines changed

‎types/node-apple-receipt-verify/index.d.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ export interface PurchasedProducts {
6666
originalPurchaseDate?: number | undefined; // only if extended = true
6767
applicationVersion?: string | undefined; // only if extended = true
6868
originalApplicationVersion?: string | undefined; // only if extended = true
69+
originalTransactionId?: string | undefined; // only if extended = true
6970
}
7071

7172
export interface ValidationError extends Error {
Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,56 @@
1-
import { error } from "server/router";
21
import appleReceiptVerify = require("node-apple-receipt-verify");
32

43
appleReceiptVerify.config({
54
secret: "test-secret",
65
});
76

8-
appleReceiptVerify.validate({ receipt: "test-reciept" }, (err, products) => {
7+
appleReceiptVerify.validate({ receipt: "test-receipt" }, (err: appleReceiptVerify.ValidationError, products: appleReceiptVerify.PurchasedProducts[]) => {
98
if (err) {
109
console.error(err.appleStatus);
1110
console.error(err.isRetryable);
1211
return;
1312
}
14-
console.log(products.map((p: appleReceiptVerify.PurchasedProducts) => p.bundleId));
13+
console.log(products.map((p) => p.bundleId));
1514
});
1615

1716
appleReceiptVerify
18-
.validate({ receipt: "test-reciept" })
19-
.then(products => {
20-
console.log(products.map((p: appleReceiptVerify.PurchasedProducts) => p.productId));
21-
})
22-
.catch(err => {
17+
.validate({ receipt: "test-receipt" })
18+
.then((products: appleReceiptVerify.PurchasedProducts[]) => {
19+
products.forEach((p) => {
20+
const {
21+
bundleId,
22+
transactionId,
23+
productId,
24+
purchaseDate,
25+
quantity,
26+
expirationDate,
27+
isTrialPeriod,
28+
isInIntroOfferPeriod,
29+
environment,
30+
originalPurchaseDate,
31+
applicationVersion,
32+
originalApplicationVersion,
33+
originalTransactionId
34+
} = p
35+
36+
console.log({
37+
bundleId,
38+
transactionId,
39+
productId,
40+
purchaseDate,
41+
quantity,
42+
expirationDate,
43+
isTrialPeriod,
44+
isInIntroOfferPeriod,
45+
environment,
46+
originalPurchaseDate,
47+
applicationVersion,
48+
originalApplicationVersion,
49+
originalTransactionId
50+
})
51+
})}
52+
)
53+
.catch((err: appleReceiptVerify.ValidationError) => {
2354
console.error(err);
2455
});
56+

0 commit comments

Comments
 (0)