mozilla
Los resultados de tu búsqueda

    Building a Paid app

    Nuestros voluntarios aún no han traducido este artículo al Español. ¡Únete a nosotros y ayuda a traducirlo!

    There are two kinds of payments made by app users in Firefox Marketplace apps: a payment made to purchase an app (a paid app) and a payment made to buy digital goods after the app is installed (an in-app payment). This page covers the code and workflow required to create paid apps.

    Building a paid app

    Any app can be a paid app. It can be a hosted app or a packaged app, and it doesn't require special permissions. You can create a paid app simply by choosing to make it a paid app when you submit it to the Firefox Marketplace. However, you should also code your app to validate its sales receipt to ensure it has been paid for. The following sections set out what you need to do.

    Add installs_allowed_from to your manifest.webapp

    First, you should add the installs_allowed_from field to the app manifest. Give it the URL of the Firefox Marketplace, like this:

    "installs_allowed_from": [ "https://marketplace.firefox.com" ]

    This is needed as part of receipt validation so it can be determined if your app came from a store where it was paid for.

    Verify the receipt

    When an app is sold on the Marketplace, a digital receipt for the sale is created. You should code your app so it verifies this sales receipt when it runs. This verification is not required for the app to be sold, but it comes highly recommended. It will stop people from running your app without having paid for it.

    Mozilla-maintained JavaScript helper libraries enable you to verify the receipt with a few lines of code. To use them, include the following libraries in your app:

    Then you can add the following code to your app (with text changes to match your app) to verify the receipt:

    mozmarket.receipts.Prompter({
      storeURL: "https://marketplace.firefox.com/app/your-app",
      supportHTML: '<a href="mailto:you@yourapp.com">email you@yourapp.com</a>',
      verify: true
    });

    The usual time for receipt validation is when the app is started. If the receipt is valid, you release the app's resources to the user. If it isn't valid, you can prevent the app from running.

    Note: For more detail, including building your own receipt verifier, see Validating a receipt.

    See also

    Etiquetas y colaboradores del documento

    Etiquetas: 
    Contributors to this page: rebloor, SpencerG, LRSaunders, markg, chrisdavidmills
    Última actualización por: rebloor,