@@ -4,7 +4,6 @@ import Yosemite
44
55@MainActor
66struct InAppPurchasesDebugView : View {
7- let siteID : Int64
87 private let inAppPurchasesForWPComPlansManager = InAppPurchasesForWPComPlansManager ( )
98 @State var products : [ WPComPlanProduct ] = [ ]
109 @State var entitledProductIDs : Set < String > = [ ]
@@ -31,7 +30,8 @@ struct InAppPurchasesDebugView: View {
3130 Text ( " No products " )
3231 } else if isPurchasing {
3332 ActivityIndicator ( isAnimating: . constant( true ) , style: . medium)
34- } else {
33+ } else if let stringSiteID = ProcessInfo . processInfo. environment [ Constants . siteIdEnvironmentVariableName] ,
34+ let siteID = Int64 ( stringSiteID) {
3535 ForEach ( products, id: \. id) { product in
3636 Button ( entitledProductIDs. contains ( product. id) ? " Entitled: \( product. description) " : product. description) {
3737 Task {
@@ -47,6 +47,10 @@ struct InAppPurchasesDebugView: View {
4747 }
4848 . alert ( isPresented: $presentAlert, error: purchaseError, actions: { } )
4949 }
50+ } else {
51+ Text ( " No valid site id could be retrieved to purchase product. " +
52+ " Please set your Int64 test site id to the Xcode environment variable with name \( Constants . siteIdEnvironmentVariableName) . " )
53+ . foregroundColor ( . red)
5054 }
5155 }
5256
@@ -129,6 +133,10 @@ private struct PurchaseError: LocalizedError {
129133
130134struct InAppPurchasesDebugView_Previews : PreviewProvider {
131135 static var previews : some View {
132- InAppPurchasesDebugView ( siteID : 0 )
136+ InAppPurchasesDebugView ( )
133137 }
134138}
139+
140+ private enum Constants {
141+ static let siteIdEnvironmentVariableName = " iap-debug-site-id "
142+ }
0 commit comments