Palbase IAP
Palbase's IAP module: what a project sells and what each of its customers has, in one shared, multi-tenant service; every project is isolated by row security in its database, and every key it keeps is sealed with the project's own data key.
One catalog, three channels. Each product is defined once — its kind, its plans and prices, its names in each language, what it gives (entitlements, credits, a quota) — and sold on the App Store, Google Play and the web through the project's own Stripe account, each channel configured with what is its own there: Apple's shorter names, a web price without the stores' commission. The stores are brought to the catalog by a plan a person sees and confirms; nothing is written store by store. Every purchase, from every channel, lands in one ledger, and a customer's apps read one answer, CustomerInfo — entitlements, subscriptions, IAP, credit balances and quota use — whatever store they bought in. Credits are spent in one step, or held for a job and committed after it; a quota counts use in a window and can overflow into credits. A guest's IAP go to the account it signs in to.
Three doors. A customer's own app reads the offerings with any of the project's keys, and what the customer has, buys on the web, reports what StoreKit gave it in the App Store and merges a guest with the publishable key and the user's access token (a guest's too). The project's backend, Studio and the CLI reach everything else with the secret key (apikey, role service_role): the catalog, the Stripe account and the App Store connection, every customer, credits and quotas. Stripe's and the App Store's notifications (signed by the provider) and the pages a Stripe key or an In-App Purchase key is handed over on (a one-time grant) take no key. Changes emit iap.* events to the project's webhooks (x-palbase-events); the customer's apps hear of their own changes on the realtime channel iap:<project ref>:<user id> (theirs alone, read-only), whose state and changed broadcast carry {"revision": N}: a revision above the one read means reading GET /iap/me again.
The contract itself: /openapi/iap.openapi.json
AppleAccount
/iap/appleRead the App Store connectionDELETE/iap/appleDisconnect the In-App Purchase keyPOST/iap/apple/grantsGrant an In-App Purchase key's connectionGET/iap/apple/readinessCheck readiness to sell in the App StorePUT/iap/apple/xcode-certificateTake Xcode's StoreKit Testing purchasesDELETE/iap/apple/xcode-certificateStop taking Xcode's purchasesPUT/iap/apple/xcode-offer-keySet Xcode’s offer keyAppStore
Connect
Catalog
/iap/catalogRead the catalogPUT/iap/catalogSave the catalogPOST/iap/catalog/plansPlan bringing the stores to the catalogGET/iap/catalog/plans/{plan_id}Read a planPOST/iap/catalog/plans/{plan_id}/confirmConfirm a planPOST/iap/catalog/plans/{plan_id}/declineDecline a planGET/iap/catalog/revisionsList the catalog's revisionsGET/iap/catalog/revisions/{revision}Read a revision of the catalogPOST/iap/catalog/revisions/{revision}/restorePut an older revision backPOST/iap/catalog/validateCheck a catalogCharts
Web
Coupons
Customers
/iap/customersFind customersGET/iap/customers/{customer_id}Read a customerGET/iap/customers/{customer_id}/grantsList a customer's grantsPOST/iap/customers/{customer_id}/grantsGrant an entitlementDELETE/iap/customers/{customer_id}/grants/{grant_id}Revoke a granted entitlementGET/iap/customers/{customer_id}/historyRead a customer's historyPOST/iap/customers/{customer_id}/subscriptions/{subscription_id}/cancelCancel a subscription's renewalPOST/iap/customers/{customer_id}/subscriptions/{subscription_id}/extendExtend a subscriptionPOST/iap/customers/{customer_id}/subscriptions/{subscription_id}/refundRefund a subscriptionGET/iap/meRead what the customer hasPUT/iap/me/refund-data-consentRecord the customer's consent to refund dataCredits
/iap/customers/{customer_id}/creditsGrant creditsGET/iap/customers/{customer_id}/credits/entriesList credit movementsPOST/iap/customers/{customer_id}/credits/forgiveForgive a debtPOST/iap/customers/{customer_id}/holdsHold credits or a quota for a jobPUT/iap/customers/{customer_id}/limits/{limit_key}Set a customer's own limitDELETE/iap/customers/{customer_id}/limits/{limit_key}Clear a customer's own limitPOST/iap/customers/{customer_id}/limits/{limit_key}/grantsGrant more of a limitPOST/iap/customers/{customer_id}/spendSpend credits or a quotaPOST/iap/customers/{customer_id}/spends/{spend_id}/commitCommit a holdPOST/iap/customers/{customer_id}/spends/{spend_id}/extendGive a hold more timePOST/iap/customers/{customer_id}/spends/{spend_id}/releaseRelease a holdPOST/iap/customers/{customer_id}/spends/{spend_id}/reverseReverse a spendExperiments
/iap/experimentsList the experimentsPOST/iap/experimentsStart an experimentGET/iap/experiments/{experiment_id}Read an experimentGET/iap/experiments/{experiment_id}/resultsRead an experiment's resultsPOST/iap/experiments/{experiment_id}/stopStop an experimentPOST/iap/experiments/{experiment_id}/winnerDeclare an experiment's winnerGoogleAccount
GooglePlay
Guests
Offerings
Offers
Paywalls
/iap/paywallsList the paywallsPOST/iap/paywallsMake a paywallGET/iap/paywalls/assetsList the paywall assetsPOST/iap/paywalls/assetsRegister a paywall assetDELETE/iap/paywalls/assets/{asset_id}Delete a paywall assetGET/iap/paywalls/templatesList the paywall templatesGET/iap/paywalls/templates/{key}/assets/{asset_id}Download a template assetPOST/iap/paywalls/validateCheck a paywallGET/iap/paywalls/{paywall_id}Read a paywallDELETE/iap/paywalls/{paywall_id}Delete a paywallPUT/iap/paywalls/{paywall_id}/draftSave a paywall's draftPOST/iap/paywalls/{paywall_id}/publishPublish a paywallGET/iap/paywalls/{paywall_id}/versionsList a paywall's versionsGET/iap/paywalls/{paywall_id}/versions/{version}Read a paywall's versionPlacements
/iap/placementsList the placementsGET/iap/placements/attributesList the attribute keys apps sendPUT/iap/placements/{placement}Give a placement a paywallDELETE/iap/placements/{placement}Delete a placementPOST/iap/placements/{placement}/exposuresReport a paywall shownGET/iap/placements/{placement}/paywallRead a placement's paywallPOST/iap/placements/{placement}/resolve-previewPreview what a placement shows a viewerGET/iap/placements/{placement}/resultsRead a placement's results by ruleGET/iap/placements/{placement}/rulesRead a placement's rulesPUT/iap/placements/{placement}/rulesReplace a placement's rules