Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move from applicationUsername to appAccountToken #104

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,10 @@ public class ExampleSignatureCreation {

String productId = "<product_id>";
String subscriptionOfferId = "<subscription_offer_id>";
String applicationUsername = "<application_username>";
String appAccountToken = "<app_account_token>";
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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,17 @@ public PromotionalOfferSignatureCreator(String signingKey, String keyId, String
* @see <a href="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</a>
* @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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
Loading