diff --git a/README.md b/README.md index 1efbe0b..e9e21f6 100644 --- a/README.md +++ b/README.md @@ -125,12 +125,12 @@ const encodedKey = readFile(filePath) // Specific implementation may vary const productId = "" const subscriptionOfferId = "" -const applicationUsername = "" +const appAccountToken = "" const nonce = "" const timestamp = Date.now() const signatureCreator = new PromotionalOfferSignatureCreator(encodedKey, keyId, bundleId) -const signature = signatureCreator.createSignature(productId, subscriptionOfferId, applicationUsername, nonce, timestamp) +const signature = signatureCreator.createSignature(productId, subscriptionOfferId, appAccountToken, nonce, timestamp) console.log(signature) ``` diff --git a/promotional_offer.ts b/promotional_offer.ts index 94e32aa..cf1c4c0 100644 --- a/promotional_offer.ts +++ b/promotional_offer.ts @@ -20,17 +20,17 @@ export class PromotionalOfferSignatureCreator { * {@link https://developer.apple.com/documentation/storekit/in-app_purchase/original_api_for_in-app_purchase/subscriptions_and_offers/generating_a_signature_for_promotional_offers Generating a signature for promotional offers} * @param productIdentifier The subscription product identifier * @param subscriptionOfferID The subscription discount identifier - * @param applicationUsername An optional string value that you define; may be an empty string + * @param appAccountToken An optional string value that you define; may be an empty string * @param nonce A one-time UUID value that your server generates. Generate a new nonce for every signature. * @param timestamp A timestamp your server generates in UNIX time format, in milliseconds. The timestamp keeps the offer active for 24 hours. * @return The Base64 encoded signature */ - public createSignature(productIdentifier: string, subscriptionOfferID: string, applicationUsername: string, nonce: string, timestamp: number): string { + public createSignature(productIdentifier: string, subscriptionOfferID: string, appAccountToken: string, nonce: string, timestamp: number): string { const payload = this.bundleId + '\u2063' + this.keyId + '\u2063' + productIdentifier + '\u2063' + subscriptionOfferID + '\u2063' + - applicationUsername.toLowerCase() + '\u2063'+ + appAccountToken.toLowerCase() + '\u2063'+ nonce.toLowerCase() + '\u2063' + timestamp; const sign = createSign('SHA256') diff --git a/tests/unit-tests/promotional_offer_signature_creator.test.ts b/tests/unit-tests/promotional_offer_signature_creator.test.ts index f577ab5..87d9a59 100644 --- a/tests/unit-tests/promotional_offer_signature_creator.test.ts +++ b/tests/unit-tests/promotional_offer_signature_creator.test.ts @@ -7,7 +7,7 @@ import { readFile } from "../util" describe('Promotional Offer Signature Creation Test', () => { it('should create a non-null signature', async () => { const signatureCreator = new PromotionalOfferSignatureCreator(readFile('tests/resources/certs/testSigningKey.p8'), "keyId", "bundleId"); - const signature = signatureCreator.createSignature('productId', 'offerId', 'applicationUsername', "20fba8a0-2b80-4a7d-a17f-85c1854727f8", 1698148900000) + const signature = signatureCreator.createSignature('productId', 'offerId', 'appAccountToken', "20fba8a0-2b80-4a7d-a17f-85c1854727f8", 1698148900000) expect(signature).toBeTruthy() }) }) \ No newline at end of file