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

feat: Add support for ASSA v1.13 and ASSN v2.13 #57

Merged
merged 1 commit into from
Aug 9, 2024
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
6 changes: 5 additions & 1 deletion assets/signedRenewalInfo.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,9 @@
"renewalDate": 1698148850000,
"renewalPrice": 9990,
"currency": "USD",
"offerDiscountType": "PAY_AS_YOU_GO"
"offerDiscountType": "PAY_AS_YOU_GO",
"eligibleWinBackOfferIds": [
"eligible1",
"eligible2"
]
}
8 changes: 7 additions & 1 deletion src/primitives/jws_renewal_info_decoded_payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,5 +118,11 @@ pub struct JWSRenewalInfoDecodedPayload {
///
///[offerDiscountType](https://developer.apple.com/documentation/appstoreserverapi/offerdiscounttype)
#[serde(rename = "offerDiscountType")]
pub offer_discount_type: Option<OfferDiscountType>
pub offer_discount_type: Option<OfferDiscountType>,

///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<Vec<String>>
}
1 change: 1 addition & 0 deletions src/primitives/offer_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ pub enum OfferType {
IntroductoryOffer = 1,
PromotionalOffer = 2,
SubscriptionOfferCode = 3,
WinBackOffer = 4,
}
15 changes: 15 additions & 0 deletions src/signed_data_verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
Loading