@@ -11,10 +11,11 @@ struct InAppPurchasesDebugView: View {
1111 @State var isPurchasing = false
1212 @State private var purchaseError : PurchaseError ? {
1313 didSet {
14- presentAlert = purchaseError != nil
14+ presentErrorAlert = purchaseError != nil
1515 }
1616 }
17- @State var presentAlert = false
17+ @State var presentErrorAlert = false
18+ @State var presentPurchaseProductAlert = false
1819
1920 var body : some View {
2021 List {
@@ -34,18 +35,24 @@ struct InAppPurchasesDebugView: View {
3435 let siteID = Int64 ( stringSiteID) {
3536 ForEach ( products, id: \. id) { product in
3637 Button ( entitledProductIDs. contains ( product. id) ? " Entitled: \( product. description) " : product. description) {
37- Task {
38- isPurchasing = true
39- do {
40- try await inAppPurchasesForWPComPlansManager. purchaseProduct ( with: product. id, for: siteID)
41- } catch {
42- purchaseError = PurchaseError ( error: error)
38+ presentPurchaseProductAlert = true
39+ }
40+ . alert ( " Did you setup your sandbox environment? " , isPresented: $presentPurchaseProductAlert) {
41+ Button ( " Yes " ) {
42+ Task {
43+ isPurchasing = true
44+ do {
45+ try await inAppPurchasesForWPComPlansManager. purchaseProduct ( with: product. id, for: siteID)
46+ } catch {
47+ purchaseError = PurchaseError ( error: error)
48+ }
49+ await loadUserEntitlements ( )
50+ isPurchasing = false
4351 }
44- await loadUserEntitlements ( )
45- isPurchasing = false
4652 }
53+ Button ( " No " ) { }
4754 }
48- . alert ( isPresented: $presentAlert , error: purchaseError, actions: { } )
55+ . alert ( isPresented: $presentErrorAlert , error: purchaseError, actions: { } )
4956 }
5057 } else {
5158 Text ( " No valid site id could be retrieved to purchase product. " +
@@ -66,6 +73,12 @@ struct InAppPurchasesDebugView: View {
6673 . foregroundColor ( . red)
6774 }
6875 }
76+
77+ Section ( " Warning " ) {
78+ Text ( " ⚠️ Please make sure before testing a purchase that the IAP requests are pointing " +
79+ " to your WPCOM sandbox environment and you have the billing system sandbox-mode enabled. " )
80+ . foregroundColor ( Color ( . accent) )
81+ }
6982 }
7083 . navigationTitle ( " IAP Debug " )
7184 . task {
0 commit comments