fix(native): App Review findings on buying TREK Cloud in the app

- Orders closed at the cloud: the app shows the plans and that TREK Cloud
  opens soon, and sells only in a test build (TestFlight, App Review), whose
  sandbox purchases the cloud still sets up; a store purchase it would refuse
  is never offered. The plans arrive without prices then, the store's own are
  shown where it gives them.
- A purchase paid but never set up (Ask to Buy approved later, the app closed
  mid-purchase) is picked up by Restore purchases and goes on to the claim with
  that purchase, instead of failing; nothing is bought twice.
- The buy button names the period with the price (guideline 3.1.2).
- The privacy link opens the policy without the site's sales header.
- The privacy manifest declares what TREK Cloud keeps: email, name, the store
  purchase, photos, other user content and saved places, all for the app to
  work, linked to the account, never for tracking.
- The email hint promises messages about the contract, not receipts, which the
  store sends.
This commit is contained in:
Maurice
2026-11-07 11:48:03 +01:00
parent 354e30a075
commit 6e1c9e8e9f
35 changed files with 225 additions and 56 deletions
+11
View File
@@ -58,6 +58,17 @@ describe('native client', () => {
expect(await nativeIapClient.isAvailable()).toBe(false);
});
it('knows a test build from a store one, and takes an error for a store build', async () => {
shell.storeProducts.mockResolvedValue({ products: [], sandbox: true });
expect(await nativeIapClient.isSandbox()).toBe(true);
expect(shell.storeProducts).toHaveBeenCalledWith({ ids: [] });
shell.storeProducts.mockResolvedValue({ products: [] });
expect(await nativeIapClient.isSandbox()).toBe(false);
shell.storeProducts.mockRejectedValue(new Error('no store'));
expect(await nativeIapClient.isSandbox()).toBe(false);
expect(await fakeIapClient.isSandbox()).toBe(true);
});
it('maps the store price strings by product', async () => {
shell.storeProducts.mockResolvedValue({ products: [{ id: 'cloud.plus.monthly', displayPrice: '9,99 €' }] });
const prices = await nativeIapClient.prices(['cloud.plus.monthly', 'cloud.pro.monthly']);
+12
View File
@@ -41,6 +41,8 @@ export interface IapClient {
* prices come from the plan list.
*/
prices(productIds: string[]): Promise<Map<string, string>>;
/** A test build (TestFlight, App Review), whose purchases cost nothing and may go ahead before the opening. */
isSandbox(): Promise<boolean>;
/** Runs the platform's purchase sheet for a product and resolves with what became of it. */
purchase(productId: string): Promise<PurchaseOutcome>;
/** Tells the store a purchase was delivered, once its instance exists. */
@@ -73,6 +75,9 @@ export const fakeIapClient: IapClient = {
async prices() {
return new Map();
},
async isSandbox() {
return true;
},
async purchase(productId) {
await new Promise((resolve) => setTimeout(resolve, 900));
const nonce = String(Date.now());
@@ -110,6 +115,13 @@ export const nativeIapClient: IapClient = {
return new Map();
}
},
async isSandbox() {
try {
return (await TrekShell.storeProducts({ ids: [] })).sandbox === true;
} catch {
return false;
}
},
async purchase(productId) {
try {
const result = await TrekShell.storePurchase({ productId });
+1 -1
View File
@@ -4,7 +4,7 @@
*/
/** The privacy policy the store listings name too. */
export const PRIVACY_URL = 'https://liketrek.com/privacy';
export const PRIVACY_URL = 'https://liketrek.com/privacy?app=1';
/** What a TREK server is and how to run one, for someone who has none yet. */
export const SERVER_DOCS_URL = 'https://github.com/liketrek/TREK#readme';
+3 -1
View File
@@ -74,7 +74,9 @@ export interface TrekShellPlugin {
}): Promise<{ running: boolean }>;
endTripDay(): Promise<void>;
/** iOS, feature storeKit: the App Store's price strings for the products it knows. */
storeProducts(options: { ids: string[] }): Promise<{ products: { id: string; displayPrice: string }[] }>;
storeProducts(options: {
ids: string[];
}): Promise<{ products: { id: string; displayPrice: string }[]; sandbox?: boolean }>;
/** iOS, feature storeKit: the purchase sheet; `jws` is the signed transaction, set when bought. */
storePurchase(options: {
productId: string;