From 4d4f3ee1d049ca589d9bbfdfef8cba803e1c91c0 Mon Sep 17 00:00:00 2001 From: tikhop Date: Fri, 9 Aug 2024 18:01:08 +0200 Subject: [PATCH] feat: Add support for ASSA v1.13 and ASSN v2.13 --- assets/signedRenewalInfo.json | 6 +++++- .../jws_renewal_info_decoded_payload.rs | 8 +++++++- src/primitives/offer_type.rs | 1 + src/signed_data_verifier.rs | 15 +++++++++++++++ 4 files changed, 28 insertions(+), 2 deletions(-) diff --git a/assets/signedRenewalInfo.json b/assets/signedRenewalInfo.json index 3bc565b..6da29ed 100644 --- a/assets/signedRenewalInfo.json +++ b/assets/signedRenewalInfo.json @@ -15,5 +15,9 @@ "renewalDate": 1698148850000, "renewalPrice": 9990, "currency": "USD", - "offerDiscountType": "PAY_AS_YOU_GO" + "offerDiscountType": "PAY_AS_YOU_GO", + "eligibleWinBackOfferIds": [ + "eligible1", + "eligible2" + ] } \ No newline at end of file diff --git a/src/primitives/jws_renewal_info_decoded_payload.rs b/src/primitives/jws_renewal_info_decoded_payload.rs index f746f83..abcc8bb 100644 --- a/src/primitives/jws_renewal_info_decoded_payload.rs +++ b/src/primitives/jws_renewal_info_decoded_payload.rs @@ -118,5 +118,11 @@ pub struct JWSRenewalInfoDecodedPayload { /// ///[offerDiscountType](https://developer.apple.com/documentation/appstoreserverapi/offerdiscounttype) #[serde(rename = "offerDiscountType")] - pub offer_discount_type: Option + pub offer_discount_type: Option, + + ///An array of win-back offer identifiers that a customer is eligible to redeem, which sorts the identifiers to present the better offers first. + /// + ///[eligibleWinBackOfferIds](https://developer.apple.com/documentation/appstoreserverapi/eligiblewinbackofferids) + #[serde(rename = "eligibleWinBackOfferIds")] + pub eligible_win_back_offer_ids: Option> } diff --git a/src/primitives/offer_type.rs b/src/primitives/offer_type.rs index c0c911b..338e13f 100644 --- a/src/primitives/offer_type.rs +++ b/src/primitives/offer_type.rs @@ -9,4 +9,5 @@ pub enum OfferType { IntroductoryOffer = 1, PromotionalOffer = 2, SubscriptionOfferCode = 3, + WinBackOffer = 4, } diff --git a/src/signed_data_verifier.rs b/src/signed_data_verifier.rs index 388e63b..89e30fb 100644 --- a/src/signed_data_verifier.rs +++ b/src/signed_data_verifier.rs @@ -386,6 +386,21 @@ mod tests { .verify_and_decode_renewal_info(RENEWAL_INFO) .unwrap(); assert_eq!(renewal_info.environment, Some(Environment::Sandbox)); + // TODO: Implement TestingUtility to generate signed data from json + // assert_eq!( + // "USD", + // renewal_info.currency.as_deref().expect("Expect currency") + // ); + // assert_eq!( + // OfferDiscountType::PayAsYouGo, + // renewal_info + // .offer_discount_type + // .expect("Expect offer_discount_type") + // ); + // assert_eq!( + // vec!["eligible1", "eligible2"], + // renewal_info.eligible_win_back_offer_ids.unwrap() + // ); } #[test]