Commit 8980fc87 by Dmitry Stepanets

Working on verify subscription

parent 7b9c9f69
...@@ -60,7 +60,16 @@ ...@@ -60,7 +60,16 @@
"referenceName" : "Premium Subscription Yearly", "referenceName" : "Premium Subscription Yearly",
"subscriptionGroupID" : "AC6BEB61", "subscriptionGroupID" : "AC6BEB61",
"type" : "RecurringSubscription" "type" : "RecurringSubscription"
}, }
]
},
{
"id" : "4BDB84FF",
"localizations" : [
],
"name" : "Premium Subscription (for Pro)",
"subscriptions" : [
{ {
"adHocOffers" : [ "adHocOffers" : [
...@@ -68,19 +77,19 @@ ...@@ -68,19 +77,19 @@
"displayPrice" : "1.49", "displayPrice" : "1.49",
"familyShareable" : false, "familyShareable" : false,
"groupNumber" : 1, "groupNumber" : 1,
"internalID" : "06580AD5", "internalID" : "9E811EB0",
"introductoryOffer" : null, "introductoryOffer" : null,
"localizations" : [ "localizations" : [
{ {
"description" : "Test Description 1W Monthly (Pro)", "description" : "",
"displayName" : "1Weather Premium Monthly (Pro)", "displayName" : "1Weather Premium Monthly (Pro)",
"locale" : "en_US" "locale" : "en_US"
} }
], ],
"productID" : "com.onelouder.oneweather.subscription.premium.forPro", "productID" : "com.onelouder.oneweather.subscription.forPro.premium",
"recurringSubscriptionPeriod" : "P1M", "recurringSubscriptionPeriod" : "P1M",
"referenceName" : "Premium Subscription Monthly (for Pro)", "referenceName" : "Premium Subscription Monthly (for Pro)",
"subscriptionGroupID" : "AC6BEB61", "subscriptionGroupID" : "4BDB84FF",
"type" : "RecurringSubscription" "type" : "RecurringSubscription"
}, },
{ {
...@@ -90,19 +99,19 @@ ...@@ -90,19 +99,19 @@
"displayPrice" : "6.99", "displayPrice" : "6.99",
"familyShareable" : false, "familyShareable" : false,
"groupNumber" : 1, "groupNumber" : 1,
"internalID" : "FE3C47E9", "internalID" : "0EE8019B",
"introductoryOffer" : null, "introductoryOffer" : null,
"localizations" : [ "localizations" : [
{ {
"description" : "Test Description 1W Yearly (Pro)", "description" : "",
"displayName" : "1Weather Premium Yearly (Pro)", "displayName" : "1Weather Premium Yearly (Pro)",
"locale" : "en_US" "locale" : "en_US"
} }
], ],
"productID" : "com.onelouder.oneweather.subscription.premium.yearly.forPro", "productID" : "com.onelouder.oneweather.subscription.pro.premium.yearly",
"recurringSubscriptionPeriod" : "P1Y", "recurringSubscriptionPeriod" : "P1Y",
"referenceName" : "Premium Subscription Yearly (for Pro)", "referenceName" : "Premium Subscription Yearly (for Pro)",
"subscriptionGroupID" : "AC6BEB61", "subscriptionGroupID" : "4BDB84FF",
"type" : "RecurringSubscription" "type" : "RecurringSubscription"
} }
] ]
......
...@@ -200,13 +200,15 @@ public class StoreManager { ...@@ -200,13 +200,15 @@ public class StoreManager {
SwiftyStoreKit.verifyReceipt(using: appleValidator) { result in SwiftyStoreKit.verifyReceipt(using: appleValidator) { result in
switch result { switch result {
case .success(let receipt): case .success(let receipt):
let purchaseResult = SwiftyStoreKit.verifySubscriptions(productIds: self.allSubscriptionIds, inReceipt: receipt) let purchaseResult = SwiftyStoreKit.verifySubscriptions(ofType: .autoRenewable, productIds: self.allSubscriptionIds, inReceipt: receipt)
switch purchaseResult { switch purchaseResult {
case .purchased(let expiryDate, let items): case .purchased(let expiryDate, let items):
log.debug("Verify: purchased subscription (valid until \(expiryDate))! Items: \(items)") log.debug("Verify: purchased subscription (valid until \(expiryDate))! Items: \(items)")
self.hasSubscription = true self.hasSubscription = true
self.everHadSubscription = true self.everHadSubscription = true
self.subscriptionExpirationDate = expiryDate if let expDate = items.first?.subscriptionExpirationDate {
self.subscriptionExpirationDate = expDate
}
case .expired(let expiryDate, let items): case .expired(let expiryDate, let items):
log.debug("Subscription expired since \(expiryDate)\n\(items)\n") log.debug("Subscription expired since \(expiryDate)\n\(items)\n")
self.everHadSubscription = true self.everHadSubscription = true
......
...@@ -15,7 +15,6 @@ public struct SubscriptionsListConfig { ...@@ -15,7 +15,6 @@ public struct SubscriptionsListConfig {
public let yearlyDiscounted: SubscriptionConfig public let yearlyDiscounted: SubscriptionConfig
public init(subscriptionsEnabled: Bool, monthly: SubscriptionConfig, yearly: SubscriptionConfig, monthlyDiscounted: SubscriptionConfig, yearlyDiscounted: SubscriptionConfig) { public init(subscriptionsEnabled: Bool, monthly: SubscriptionConfig, yearly: SubscriptionConfig, monthlyDiscounted: SubscriptionConfig, yearlyDiscounted: SubscriptionConfig) {
self.subscriptionsEnabled = subscriptionsEnabled self.subscriptionsEnabled = subscriptionsEnabled
self.monthly = monthly self.monthly = monthly
self.yearly = yearly self.yearly = yearly
...@@ -27,8 +26,8 @@ public struct SubscriptionsListConfig { ...@@ -27,8 +26,8 @@ public struct SubscriptionsListConfig {
self.subscriptionsEnabled = true self.subscriptionsEnabled = true
self.monthly = SubscriptionConfig(productId: "com.onelouder.oneweather.subscription.premium") self.monthly = SubscriptionConfig(productId: "com.onelouder.oneweather.subscription.premium")
self.yearly = SubscriptionConfig(productId: "com.onelouder.oneweather.subscription.premium.yearly") self.yearly = SubscriptionConfig(productId: "com.onelouder.oneweather.subscription.premium.yearly")
self.monthlyDiscounted = SubscriptionConfig(productId: "com.onelouder.oneweather.subscription.premium.forPro") self.monthlyDiscounted = SubscriptionConfig(productId: "com.onelouder.oneweather.subscription.forPro.premium")
self.yearlyDiscounted = SubscriptionConfig(productId: "com.onelouder.oneweather.subscription.premium.yearly.forPro") self.yearlyDiscounted = SubscriptionConfig(productId: "com.onelouder.oneweather.subscription.pro.premium.yearly")
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment