Skip to content
Türkçe

Introducing Magic Payments 1.0.2

One entitlement contract over two billing rails.

Multi-rail billing for apps on the Magic framework: a web rail and a store in-app-purchase rail on iOS and Android, read through the same Payments facade.

Runs on

  • Android
  • iOS
  • Web
  • macOS
  • Windows
  • Linux

One contract. Two rails.

Your app asks Payments what the user is entitled to, and the web rail or the store rail does the billing behind it. Each platform gets the rails it supports.

Five entitlement reads

currentEntitlement, getPlans, getUsage, getInvoices and getPaymentMethod work on every platform that has a driver, e.g. Payments.currentEntitlement().

  • The same calls on Payments.billing and as static methods on Payments
  • A failed response or a body of the wrong shape throws BillingException
Read the docs
final BillingEntitlement entitlement = await Payments.currentEntitlement();

if (entitlement.subscribed) {
  // Show the plan, then link to where it is managed.
}

Web rail

Payments.web covers checkout, swap plan, cancel and a customer portal through hosted pages your backend opens. The contract is WebBillingService.

  • Your backend owns the payment vendor and creates the hosted pages
  • Payments.web is null off a web build, so check it before you render the button
Read the docs
final WebBillingService? web = Payments.web;

if (web != null) {
  await web.checkout(
    productKey: 'pro_annual',
    successUrl: 'https://example.com/billing?checkout=success',
    cancelUrl: 'https://example.com/billing?checkout=cancel',
  );
}

Store rail

Payments.store runs iOS and Android purchases through RevenueCat: identify, purchase, products, restore and the store's subscription management.

  • StoreIdentitySync keeps the rail bound to the account that pays
  • purchase answers false when the customer dismisses the sheet
Read the docs
final StoreBillingService? store = Payments.store;
final BillingEntitlement entitlement = await Payments.currentEntitlement();

if (store != null && entitlement.manageVia != ManageVia.portal) {
  final bool bought = await store.purchase('pro_annual');

  if (bought) await Payments.currentEntitlement();
}

Rails are checked

Payments.web and Payments.store are nullable, so the app asks which rail it has before it shows a button.

  • A null rail is a build that cannot serve it
  • No kIsWeb or Platform check in a widget
Read the docs
if (Payments.web != null) {
  // Show the web checkout button.
} else if (Payments.store != null) {
  // Show the store purchase button.
}

Where to manage

manageVia and manageUrl on BillingEntitlement say whether the user manages the plan on the web or in the store.

  • manageVia is portal, appStore, playStore or none
  • It follows the rail that sold the plan, not the platform the app runs on
Read the docs
switch (entitlement.manageVia) {
  case ManageVia.portal:
    await Payments.web?.openPortal();
  case ManageVia.appStore:
  case ManageVia.playStore:
    // Without the store rail, open entitlement.manageUrl.
    await Payments.store?.openStoreManagement();
  case ManageVia.none:
    break;
}

A dowel CLI

payments:install, payments:configure and payments:doctor, plus one read-only MCP tool, payments_doctor, for AI tools.

  • payments:install is idempotent and takes --dry-run
  • payments:doctor checks the wiring and never prints the store key
Read the docs
platforms
6
commands to install
2
license
MIT

Your agent speaks Magic Payments.

The Magic Payments skill teaches your coding assistant to check the Payments.web and Payments.store rails and to read the entitlement before the first line. One command wires it up.

npx skills add anilcancakir/ai --skill magic-payments

run in your project other editors

works with

  • Claude Code
  • Cursor
  • OpenCode
  • VS Code Copilot
  • Codex CLI

And checks the docs.

Skills teach the API. The MCP server at mcp.anilcancakir.com/magic_payments gives your agent live docs lookup while it edits, so it never guesses a signature.

  • Streamable HTTP

    One endpoint, every client.

  • search-docs

    Live query against the source.

  • Public, no auth

    Read-only, free to use.

Connect your editor
mcp.anilcancakir.com/magic_payments preview

# streamable http, the default

claude mcp add --transport http magic_payments https://mcp.anilcancakir.com/magic_payments

# or stdio, for clients without http

npx -y mcp-remote https://mcp.anilcancakir.com/magic_payments

Public, no auth.

Questions, answered.

What people ask before they add Magic Payments to a Flutter app.

What is Magic Payments?

Magic Payments is the subscription billing plugin for Magic apps. The Payments facade reads the entitlement your backend serves and hands you a web rail and a store rail as nullable contracts, so no widget branches on the platform.

How do I install Magic Payments?

Run flutter pub add magic_payments, then dart run magic:dowel plugin:install magic_payments. The installer publishes lib/config/payments.dart and registers PaymentsServiceProvider; dart run magic:dowel payments:doctor checks the result.

Which platforms does Magic Payments support?

The five entitlement reads run on web, iOS, Android, macOS, Windows and Linux. The web rail exists on web builds and the store rail on iOS and Android; on any other platform that rail is null.

What backend does Magic Payments need?

One that serves the /billing endpoints, starting with GET /billing for the entitlement. Your backend owns the payment vendor and the web rail calls your backend, never the vendor. It needs magic ^1.0.0 in the app.

Do I need RevenueCat?

Only for the store rail on iOS and Android. Fill in payments.revenuecat.public_sdk_key in lib/config/payments.dart with the public SDK key, never a secret key. Web and desktop builds never read it.

Does Magic Payments work with AI coding agents?

Yes. Magic Payments ships an agent skill that teaches your assistant to check the Payments.web and Payments.store rails and to read the entitlement, plus a public docs MCP server for live lookup.

Is Magic Payments open source?

Yes. Magic Payments is open source under the MIT license.

Add it in seconds

~/my_app
flutter pub add magic_payments

Or add to pubspec.yaml:

dependencies:
  magic_payments: ^1.0.2

Or give your AI agent this prompt:

Read https://anilcancakir.com/magic/docs/payments/llms.txt and install the Magic Payments package in this project.