Skip to content

Commit b77fbac

Browse files
Merge pull request #163 from alexanderjordanbaker/ASSAv1.13
Add support for App Store Server API v1.13 and App Store Server Notif…
2 parents bf45596 + 75a2e15 commit b77fbac

4 files changed

Lines changed: 25 additions & 2 deletions

File tree

models/JWSRenewalInfoDecodedPayload.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,13 @@ export interface JWSRenewalInfoDecodedPayload extends DecodedSignedData {
134134
* {@link https://developer.apple.com/documentation/appstoreserverapi/offerdiscounttype offerDiscountType}
135135
**/
136136
offerDiscountType?: OfferDiscountType | string
137+
138+
/**
139+
* An array of win-back offer identifiers that a customer is eligible to redeem, which sorts the identifiers to present the better offers first.
140+
*
141+
* {@link https://developer.apple.com/documentation/appstoreserverapi/eligiblewinbackofferids eligibleWinBackOfferIds}
142+
**/
143+
eligibleWinBackOfferIds?: string[];
137144
}
138145

139146

@@ -196,6 +203,16 @@ export class JWSRenewalInfoDecodedPayloadValidator implements Validator<JWSRenew
196203
if ((typeof obj['offerDiscountType'] !== 'undefined') && !(JWSRenewalInfoDecodedPayloadValidator.offerDiscountTypeValidator.validate(obj['offerDiscountType']))) {
197204
return false
198205
}
206+
if (typeof obj['eligibleWinBackOfferIds'] !== 'undefined') {
207+
if (!Array.isArray(obj['eligibleWinBackOfferIds'])) {
208+
return false
209+
}
210+
for (const eligibleWinBackOfferId of obj['eligibleWinBackOfferIds']) {
211+
if (!(typeof eligibleWinBackOfferId === "string" || eligibleWinBackOfferId instanceof String)) {
212+
return false
213+
}
214+
}
215+
}
199216
return true
200217
}
201218
}

models/OfferType.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export enum OfferType {
1111
INTRODUCTORY_OFFER = 1,
1212
PROMOTIONAL_OFFER = 2,
1313
SUBSCRIPTION_OFFER_CODE = 3,
14+
WIN_BACK_OFFER = 4,
1415
}
1516

1617
export class OfferTypeValidator extends NumberValidator {}

tests/resources/models/signedRenewalInfo.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,9 @@
1515
"renewalDate": 1698148850000,
1616
"renewalPrice": 9990,
1717
"currency": "USD",
18-
"offerDiscountType": "PAY_AS_YOU_GO"
19-
}
18+
"offerDiscountType": "PAY_AS_YOU_GO",
19+
"eligibleWinBackOfferIds": [
20+
"eligible1",
21+
"eligible2"
22+
]
23+
}

tests/unit-tests/transaction_decoding.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ describe('Testing decoding of signed data', () => {
5757
expect(9990).toBe(renewalInfo.renewalPrice)
5858
expect("USD").toBe(renewalInfo.currency)
5959
expect(OfferDiscountType.PAY_AS_YOU_GO).toBe(renewalInfo.offerDiscountType)
60+
expect(["eligible1", "eligible2"]).toStrictEqual(renewalInfo.eligibleWinBackOfferIds)
6061
})
6162
it('should decode a transaction info', async () => {
6263
const signedTransaction = createSignedDataFromJson("tests/resources/models/signedTransaction.json")

0 commit comments

Comments
 (0)