none
Cannot get store product for current app

    Question

  • I am testing an in-app purchase. My program has been approved for a private audience and is visible in the Store. But when I try to call WindowsStore.PurchaseProduct(Product), it throws an exception: 'Cannot get store product for <g class="gr_ gr_403 gr-alert gr_gramm gr_inline_cards gr_run_anim Grammar only-ins replaceWithoutSep" data-gr-id="403" id="403">current</g> app'.

    I went ahead and purchased the software to see if that made a difference, but no. I mainly want to make sure I am calling the PurchaseProduct <g class="gr_ gr_492 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" data-gr-id="492" id="492">correcly</g>. If I call 'WindowsStore.AppLicense.IsActive', it returns true and false for a trial. So I would think it is there. Since it is Private, could that be the <g class="gr_ gr_906 gr-alert gr_gramm gr_inline_cards gr_run_anim Punctuation multiReplace" data-gr-id="906" id="906">problem.</g>

    Here is my code:

    var
     WindowsStore2: TWindowsStore;
     WinStat: StorePurchaseStatus;
     LMsg: string;
     Product: iStoreProduct;
     sAnsi: AnsiString;
     LRemainingTrialDays: Integer;
     ASL: IStoreAppLicense;
     SL: TStringList;
     //ALic: IAppLicense;
    
    begin         
    
     try
    
                Product := WindowsStore2.StoreProductForCurrentApp;
                WinStat := WindowsStore2.PurchaseProduct(Product);
                case WinStat of
                  StorePurchaseStatus.Succeeded:
                  begin
                    ShowMessage('Purchase Succeeded');
                    Result := true;
                  end;
                  StorePurchaseStatus.AlreadyPurchased: ShowMessage('AlreadyPurchased');
                  StorePurchaseStatus.NotPurchased: ShowMessage('NotPurchased');
                  StorePurchaseStatus.NetworkError: ShowMessage('NetworkError');
                  StorePurchaseStatus.ServerError: ShowMessage('ServerError');
                end;
              except
                on E: Exception do Showmessage(E.Message);
              end;
    
    ...
    end;
    
    What I really could use is an example of purchasing a product. Thanks in advance.

    Thursday, February 7, 2019 8:20 PM

Answers

  • Hi realsol31,

    What kind of project did you publish in the Microsoft Store? Is it a Xamarin.iOS app or others? What the kind of your in-app-purchase? Durable or consumable or Subscription? Did you create the in-app-purchase in your Dev center dashboard? Please provide more details about your app for us to analyze(Don't include any personal information).

    Best regards

    Daisy  Tian


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, February 11, 2019 6:33 AM
    Moderator

All replies

  • Hi realsol31,

    What kind of project did you publish in the Microsoft Store? Is it a Xamarin.iOS app or others? What the kind of your in-app-purchase? Durable or consumable or Subscription? Did you create the in-app-purchase in your Dev center dashboard? Please provide more details about your app for us to analyze(Don't include any personal information).

    Best regards

    Daisy  Tian


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, February 11, 2019 6:33 AM
    Moderator
  • Looks like I really need to check if the Trial is Active. If so, it is still a trial, false when purchased. I was handling it as an add-on. 
    Monday, February 11, 2019 4:05 PM