79670588

Date: 2025-06-18 12:03:44
Score: 0.5
Natty:
Report link

As @remy-lebeau rightly pointed out, the code sample I originally found wasn't the best example to follow.
The following code works nice in my case and allows me to set up an in-app subscription for the add-on:

procedure TfSubsriptions.btnSubscribe(Sender: TObject);
var
  Status: StorePurchaseStatus;
begin
  try
    WindowsStore1.RefreshInfo;
  except
    // 
  end;

  for var i := 0 to WindowsStore1.AppProducts.Count - 1 do
    begin
      if WindowsStore1.AppProducts[i].StoreId.ToString = 'XXXXXXXXXXXX' then 
        begin
          try
            Status := WindowsStore1.PurchaseProduct(WindowsStore1.AppProducts[i]);
            case Status of
              StorePurchaseStatus.Succeeded:
                begin
                  SUBSCRIPTION := True;
          UpdateUI;
                  Break;
                end;
              StorePurchaseStatus.AlreadyPurchased:
                //
              StorePurchaseStatus.NotPurchased:
                //
              StorePurchaseStatus.NetworkError:
                //
              StorePurchaseStatus.ServerError:
                //
            else
              //
            end;
          except
            On e : Exception do
              begin
                //
                Break;
              end;
          end;
        end;
    end;
end;
Reasons:
  • Long answer (-1):
  • Has code block (-0.5):
  • User mentioned (1): @remy-lebeau
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: Taras