Skip to content

Commit

Permalink
Merge pull request #57 from namecare/feature/support-ASSA1.13
Browse files Browse the repository at this point in the history
feat: Add support for ASSA v1.13 and ASSN v2.13
  • Loading branch information
tikhop authored Aug 9, 2024
2 parents ac1a415 + 4d4f3ee commit b4843fd
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
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

0 comments on commit b4843fd

Please sign in to comment.