Merge pull request #17915 from mozilla/fxa-10549-apple-iap-more-fields

feat(iap): add new apple iap fields to firestore
This commit is contained in:
Reino Muhl 2024-10-29 14:27:47 -04:00 коммит произвёл GitHub
Родитель ffd4e0d55a 0d78e8cc1d
Коммит 9adaaec4ab
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
8 изменённых файлов: 47 добавлений и 14 удалений

Просмотреть файл

@ -84,6 +84,7 @@
"@type-cacheable/core": "^14.1.0", "@type-cacheable/core": "^14.1.0",
"@type-cacheable/ioredis-adapter": "^10.0.4", "@type-cacheable/ioredis-adapter": "^10.0.4",
"agentkeepalive": "^4.5.0", "agentkeepalive": "^4.5.0",
"app-store-server-api": "^0.15.3",
"axios": "^1.7.5", "axios": "^1.7.5",
"base64url": "^3.0.1", "base64url": "^3.0.1",
"bn.js": "^5.2.1", "bn.js": "^5.2.1",

Просмотреть файл

@ -133,6 +133,11 @@ export class PurchaseManager extends PurchaseManagerBase {
originalTransactionId: string; originalTransactionId: string;
}> { }> {
const decodedPayload = await decodeNotificationPayload(payload); const decodedPayload = await decodeNotificationPayload(payload);
if (!decodedPayload.data) {
throw new Error('Decoded payload contains no data');
}
const { bundleId, originalTransactionId } = await decodeTransaction( const { bundleId, originalTransactionId } = await decodeTransaction(
decodedPayload.data.signedTransactionInfo decodedPayload.data.signedTransactionInfo
); );

Просмотреть файл

@ -75,7 +75,6 @@
"@types/mjml": "^4.7.4", "@types/mjml": "^4.7.4",
"agentkeepalive": "^4.5.0", "agentkeepalive": "^4.5.0",
"ajv": "^8.17.1", "ajv": "^8.17.1",
"app-store-server-api": "^0.7.0",
"aws-sdk": "^2.1691.0", "aws-sdk": "^2.1691.0",
"buf": "0.1.1", "buf": "0.1.1",
"commander": "2.18.0", "commander": "2.18.0",

Просмотреть файл

@ -1,4 +1,5 @@
{ {
"currency": "USD",
"transactionId": "2000000000000000", "transactionId": "2000000000000000",
"originalTransactionId": "1000000000000000", "originalTransactionId": "1000000000000000",
"webOrderLineItemId": "2000000000000000", "webOrderLineItemId": "2000000000000000",
@ -6,11 +7,13 @@
"productId": "skydiving.with.foxkeh", "productId": "skydiving.with.foxkeh",
"subscriptionGroupIdentifier": "22222222", "subscriptionGroupIdentifier": "22222222",
"purchaseDate": 1649329745000, "purchaseDate": 1649329745000,
"price": 999,
"originalPurchaseDate": 1627306493000, "originalPurchaseDate": 1627306493000,
"expiresDate": 1649330045000, "expiresDate": 1649330045000,
"quantity": 1, "quantity": 1,
"type": "Auto-Renewable Subscription", "type": "Auto-Renewable Subscription",
"inAppOwnershipType": "PURCHASED", "inAppOwnershipType": "PURCHASED",
"signedDate": 1649792142801, "signedDate": 1649792142801,
"storefront": "USA",
"environment": "Production" "environment": "Production"
} }

Просмотреть файл

@ -42,6 +42,9 @@ describe('SubscriptionPurchase', () => {
const decodedTransactionInfo = deepCopy(transactionInfo); const decodedTransactionInfo = deepCopy(transactionInfo);
const decodedRenewalInfo = deepCopy(renewalInfo); const decodedRenewalInfo = deepCopy(renewalInfo);
const verifiedAt = Date.now(); const verifiedAt = Date.now();
const currency = 'USD';
const price = 999;
const storefront = 'USA';
describe('fromApiResponse', () => { describe('fromApiResponse', () => {
const expected = { const expected = {
autoRenewStatus, autoRenewStatus,
@ -60,6 +63,9 @@ describe('SubscriptionPurchase', () => {
originalPurchaseDate, originalPurchaseDate,
autoRenewProductId, autoRenewProductId,
purchaseDate, purchaseDate,
currency,
price,
storefront,
}; };
it('parses an active subscription correctly', () => { it('parses an active subscription correctly', () => {

Просмотреть файл

@ -290,7 +290,6 @@
"@fluent/langneg": "^0.7.0", "@fluent/langneg": "^0.7.0",
"accept-language-parser": "^1.5.0", "accept-language-parser": "^1.5.0",
"ajv": "^8.17.1", "ajv": "^8.17.1",
"app-store-server-api": "^0.7.0",
"aws-sdk": "^2.1691.0", "aws-sdk": "^2.1691.0",
"buf": "^0.1.1", "buf": "^0.1.1",
"celebrate": "^15.0.1", "celebrate": "^15.0.1",

Просмотреть файл

@ -109,6 +109,11 @@ export class AppStoreSubscriptionPurchase {
private renewalOfferIdentifier?: string; private renewalOfferIdentifier?: string;
private revocationDate?: number; private revocationDate?: number;
private revocationReason?: number; private revocationReason?: number;
private currency!: string;
private price!: number;
private storefront!: string;
private renewalCurrency?: string;
private renewalPrice?: number;
// Library-managed properties // Library-managed properties
userId?: string; // hex string for FxA user id userId?: string; // hex string for FxA user id
@ -136,6 +141,9 @@ export class AppStoreSubscriptionPurchase {
purchase.transactionId = transactionInfo.transactionId; purchase.transactionId = transactionInfo.transactionId;
purchase.type = transactionInfo.type; purchase.type = transactionInfo.type;
purchase.verifiedAt = verifiedAt; purchase.verifiedAt = verifiedAt;
purchase.currency = transactionInfo.currency;
purchase.price = transactionInfo.price;
purchase.storefront = transactionInfo.storefront;
if (renewalInfo.expirationIntent) { if (renewalInfo.expirationIntent) {
purchase.expirationIntent = renewalInfo.expirationIntent; purchase.expirationIntent = renewalInfo.expirationIntent;
@ -179,6 +187,12 @@ export class AppStoreSubscriptionPurchase {
if (transactionInfo.hasOwnProperty('revocationReason')) { if (transactionInfo.hasOwnProperty('revocationReason')) {
purchase.revocationReason = transactionInfo.revocationReason; purchase.revocationReason = transactionInfo.revocationReason;
} }
if (renewalInfo.currency) {
purchase.renewalCurrency = renewalInfo.currency;
}
if (renewalInfo.renewalPrice) {
purchase.renewalPrice = renewalInfo.renewalPrice;
}
return purchase; return purchase;
} }

Просмотреть файл

@ -28145,14 +28145,14 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"app-store-server-api@npm:^0.7.0": "app-store-server-api@npm:^0.15.3":
version: 0.7.0 version: 0.15.3
resolution: "app-store-server-api@npm:0.7.0" resolution: "app-store-server-api@npm:0.15.3"
dependencies: dependencies:
jose: ^4.8.1 jose: ^4.15.7
node-fetch: ^2.6.6 node-fetch: ^2.7.0
uuid: ^8.3.2 uuid: ^9.0.1
checksum: 8d02759b0f94b7729ecf72544707d2702ec1b7ea7463591c00665db7be9aeaa8c8e7e30b56b2fab055ff9be2eec827c500dc7e217d5c57d0a1daec61dae01cfc checksum: 201452c27f5d22c598d205dcc5573f07dfb6d3d6181a08567a6a29b9347a5a2eb780ba739a26222ef0959982fecac6d43f8496d4b397aee911091c472d4bf132
languageName: node languageName: node
linkType: hard linkType: hard
@ -41186,7 +41186,6 @@ fsevents@~2.1.1:
"@types/webpack": 5.28.5 "@types/webpack": 5.28.5
agentkeepalive: ^4.5.0 agentkeepalive: ^4.5.0
ajv: ^8.17.1 ajv: ^8.17.1
app-store-server-api: ^0.7.0
async-retry: ^1.3.3 async-retry: ^1.3.3
audit-filter: ^0.5.0 audit-filter: ^0.5.0
aws-sdk: ^2.1691.0 aws-sdk: ^2.1691.0
@ -42021,7 +42020,6 @@ fsevents@~2.1.1:
"@types/uuid": ^10.0.0 "@types/uuid": ^10.0.0
accept-language-parser: ^1.5.0 accept-language-parser: ^1.5.0
ajv: ^8.17.1 ajv: ^8.17.1
app-store-server-api: ^0.7.0
audit-filter: ^0.5.0 audit-filter: ^0.5.0
aws-sdk: ^2.1691.0 aws-sdk: ^2.1691.0
buf: ^0.1.1 buf: ^0.1.1
@ -42166,6 +42164,7 @@ fsevents@~2.1.1:
"@typescript-eslint/eslint-plugin": ^5.59.1 "@typescript-eslint/eslint-plugin": ^5.59.1
"@typescript-eslint/parser": ^7.1.1 "@typescript-eslint/parser": ^7.1.1
agentkeepalive: ^4.5.0 agentkeepalive: ^4.5.0
app-store-server-api: ^0.15.3
autoprefixer: ^10.4.14 autoprefixer: ^10.4.14
axios: ^1.7.5 axios: ^1.7.5
babel-jest: ^29.7.0 babel-jest: ^29.7.0
@ -49518,7 +49517,7 @@ fsevents@~2.1.1:
languageName: node languageName: node
linkType: hard linkType: hard
"jose@npm:^4.11.4, jose@npm:^4.8.1": "jose@npm:^4.11.4":
version: 4.14.4 version: 4.14.4
resolution: "jose@npm:4.14.4" resolution: "jose@npm:4.14.4"
checksum: 2d820a91a8fd97c05d8bc8eedc373b944a0cd7f5fe41063086da233d0473c73fb523912a9f026ea870782bd221f4a515f441a2d3af4de48c6f2c76dac5082377 checksum: 2d820a91a8fd97c05d8bc8eedc373b944a0cd7f5fe41063086da233d0473c73fb523912a9f026ea870782bd221f4a515f441a2d3af4de48c6f2c76dac5082377
@ -49532,6 +49531,13 @@ fsevents@~2.1.1:
languageName: node languageName: node
linkType: hard linkType: hard
"jose@npm:^4.15.7":
version: 4.15.9
resolution: "jose@npm:4.15.9"
checksum: 41abe1c99baa3cf8a78ebbf93da8f8e50e417b7a26754c4afa21865d87527b8ac2baf66de2c5f6accc3f7d7158658dae7364043677236ea1d07895b040097f15
languageName: node
linkType: hard
"jose@npm:^5.1.3": "jose@npm:^5.1.3":
version: 5.2.4 version: 5.2.4
resolution: "jose@npm:5.2.4" resolution: "jose@npm:5.2.4"
@ -54505,7 +54511,7 @@ fsevents@~2.1.1:
languageName: node languageName: node
linkType: hard linkType: hard
"node-fetch@npm:^2.6.6, node-fetch@npm:^2.6.7": "node-fetch@npm:^2.6.7":
version: 2.6.7 version: 2.6.7
resolution: "node-fetch@npm:2.6.7" resolution: "node-fetch@npm:2.6.7"
dependencies: dependencies:
@ -54519,7 +54525,7 @@ fsevents@~2.1.1:
languageName: node languageName: node
linkType: hard linkType: hard
"node-fetch@npm:^2.6.9": "node-fetch@npm:^2.6.9, node-fetch@npm:^2.7.0":
version: 2.7.0 version: 2.7.0
resolution: "node-fetch@npm:2.7.0" resolution: "node-fetch@npm:2.7.0"
dependencies: dependencies: