From dcea06f1b5ee2ecde99af85bac8efabff67a5003 Mon Sep 17 00:00:00 2001 From: Alex Baker Date: Mon, 10 Jun 2024 17:07:58 -0700 Subject: [PATCH] Move from applicationUsername from appAccountToken --- README.md | 4 ++-- .../storekit/offers/PromotionalOfferSignatureCreator.java | 6 +++--- .../offers/PromotionalOfferSignatureCreatorTest.java | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 765c1989..be3adf39 100644 --- a/README.md +++ b/README.md @@ -181,10 +181,10 @@ public class ExampleSignatureCreation { String productId = ""; String subscriptionOfferId = ""; - String applicationUsername = ""; + String appAccountToken = ""; UUID nonce = UUID.randomUUID(); long timestamp = System.currentTimeMillis(); - String encodedSignature = signatureCreator.createSignature(productId, subscriptionOfferId, applicationUsername, nonce, timestamp); + String encodedSignature = signatureCreator.createSignature(productId, subscriptionOfferId, appAccountToken, nonce, timestamp); System.out.println(encodedSignature); } } diff --git a/src/main/java/com/apple/itunes/storekit/offers/PromotionalOfferSignatureCreator.java b/src/main/java/com/apple/itunes/storekit/offers/PromotionalOfferSignatureCreator.java index 33980850..6954866d 100644 --- a/src/main/java/com/apple/itunes/storekit/offers/PromotionalOfferSignatureCreator.java +++ b/src/main/java/com/apple/itunes/storekit/offers/PromotionalOfferSignatureCreator.java @@ -43,17 +43,17 @@ public PromotionalOfferSignatureCreator(String signingKey, String keyId, String * @see 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 String createSignature(String productIdentifier, String subscriptionOfferID, String applicationUsername, UUID nonce, long timestamp) { + public String createSignature(String productIdentifier, String subscriptionOfferID, String appAccountToken, UUID nonce, long timestamp) { String payload = this.bundleId + '\u2063' + this.keyId + '\u2063' + productIdentifier + '\u2063' + subscriptionOfferID + '\u2063' + - applicationUsername.toLowerCase() + '\u2063'+ + appAccountToken.toLowerCase() + '\u2063'+ nonce.toString().toLowerCase() + '\u2063' + timestamp; try { diff --git a/src/test/java/com/apple/itunes/storekit/offers/PromotionalOfferSignatureCreatorTest.java b/src/test/java/com/apple/itunes/storekit/offers/PromotionalOfferSignatureCreatorTest.java index dbc8184b..efb891b3 100644 --- a/src/test/java/com/apple/itunes/storekit/offers/PromotionalOfferSignatureCreatorTest.java +++ b/src/test/java/com/apple/itunes/storekit/offers/PromotionalOfferSignatureCreatorTest.java @@ -15,7 +15,7 @@ void testSignatureCreator() throws Exception { try (InputStream key = this.getClass().getClassLoader().getResourceAsStream("certs/testSigningKey.p8")) { Assertions.assertNotNull(key); PromotionalOfferSignatureCreator signatureCreator = new PromotionalOfferSignatureCreator(new String(key.readAllBytes()), "keyId", "bundleId"); - String signature = signatureCreator.createSignature("productId", "offerId", "applicationUsername", UUID.fromString("20fba8a0-2b80-4a7d-a17f-85c1854727f8"), 1698148900000L); + String signature = signatureCreator.createSignature("productId", "offerId", "appAccountToken", UUID.fromString("20fba8a0-2b80-4a7d-a17f-85c1854727f8"), 1698148900000L); Assertions.assertNotNull(signature); } }