App payments testing

  • Revision slug: Web/Apps/Publishing/App_payments_testing
  • Revision title: App payments testing
  • Revision id: 404399
  • Created:
  • Creator: MarkGiffin
  • Is current revision? No
  • Comment

Revision Content

If your app will use payments, either to buy the app on the Firefox Marketplace (a prepaid app) or to do in-app payments, you will need to be able to do an end-to-end test of it.

The following is a summary of the code you need to write for testing, followed by the testing steps. The information is organized in sections based on whether the app is hosted or packaged, and whether it is a prepaid app or it uses in-app payments. An app can also be a prepaid app that uses in-app payments.

  In-app payments Prepaid app
Hosted Hosted app with in-app payments Hosted app that is prepaid
Packaged Packaged app with in-app payments Packaged app that is prepaid

Hosted app with in-app payments

Test code

  • The hosted app invokes navigator.mozPay().
  • Your server creates an in-app payment JWT (JSON Web Token) with the simulate flag.
  • Your server gets a simulated in-app payment postback. A postback is a notification of a successful payment transaction.

Install and launch

  • Self-install your app on a device, or sideload it using the Firefox OS Simulator.
  • Test your server logic with the simulated postback.

Hosted app that is prepaid

Test code

  • The hosted app accesses its receipt and checks the issuer, type and product.
  • The hosted app uploads its receipt to your server.
  • Your server verifies the receipt against the verification URL.

Install and launch

  • Use the test receipts page to install your app with a test receipt.
  • Launch the app and test its receipt validation.

Packaged app with in-app payments

Test code

This assumes your packaged app has a server for handling in-app payments.

  • The packaged app invokes navigator.mozPay().
  • Your server creates an in-app payment JWT with the simulate flag.
  • Your server gets a simulated in-app payment postback.

Install and launch

  • Self-install your app on a device, or sideload it using the Firefox OS Simulator.
  • Test your server logic with the simulated postback.

Packaged app that is prepaid

Test code

  • The packaged app accesses its receipt and checks the issuer, type and product.
  • The packaged app verifies the receipt against the verification URL.

Install and launch

  • Use the Simulator to install your app with a test receipt.
  • Launch the app and test its receipt validation.

See also

Payments

Introducing navigator.mozPay() for web payments

Building a paid app for Firefox OS

Validating a receipt

Marketplace payments FAQ

Revision Source

<p><span style="line-height: 1.572;">If your app will use payments, either to buy the app on the Firefox Marketplace (a prepaid app) or to do in-app payments, you will need to be able to do an end-to-end test of it.</span></p>
<p><span style="line-height: 1.572;">The following is a summary of the code you need to write for testing, followed by the testing steps. The information is organized in sections based on whether the app is hosted or packaged, and whether it is a prepaid app or it uses in-app payments. An app can also be a prepaid app that uses in-app payments.</span></p>
<table align="left" class="standard-table">
  <thead>
    <tr>
      <th scope="col">&nbsp;</th>
      <th scope="col">In-app payments</th>
      <th scope="col">Prepaid app</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td style="background-color: rgb(240, 238, 238);"><strong>Hosted</strong></td>
      <td><a href="/en-US/docs/Apps/Publishing/App_payments_testing#Hosted_app_with_in-app_payments" title="/en-US/docs/Apps/Publishing/App_payments_testing#Hosted_app_with_in-app_payments">Hosted app with in-app payments</a></td>
      <td><a href="/en-US/docs/Apps/Publishing/App_payments_testing#Hosted_app_that_is_prepaid" title="/en-US/docs/Apps/Publishing/App_payments_testing#Hosted_app_that_is_prepaid">Hosted app that is prepaid</a></td>
    </tr>
    <tr>
      <td style="background-color: rgb(240, 238, 238);"><strong>Packaged</strong></td>
      <td><a href="/en-US/docs/Apps/Publishing/App_payments_testing#Packaged_app_with_in-app_payments" title="/en-US/docs/Apps/Publishing/App_payments_testing#Packaged_app_with_in-app_payments">Packaged app with in-app payments</a></td>
      <td><a href="/en-US/docs/Apps/Publishing/App_payments_testing#Packaged_app_that_is_prepaid" title="/en-US/docs/Apps/Publishing/App_payments_testing#Packaged_app_that_is_prepaid">Packaged app that is prepaid</a></td>
    </tr>
  </tbody>
</table>
<h2 id="Hosted_app_with_in-app_payments"><span style="line-height: 1.572;">Hosted app with in-app payments</span></h2>
<h3 id="Test_code">Test code</h3>
<ul>
  <li>The hosted app invokes <a href="/en-US/docs/DOM/window.navigator.mozPay" title="/en-US/docs/DOM/window.navigator.mozPay"><code>navigator.mozPay()</code></a>.</li>
  <li>Your server creates an in-app payment JWT (<a href="http://openid.net/specs/draft-jones-json-web-token-07.html" title="http://openid.net/specs/draft-jones-json-web-token-07.html">JSON Web Token</a>) with the <code>simulate</code> flag.</li>
  <li>Your server gets a simulated in-app payment postback. A postback is a notification of a successful payment transaction.</li>
</ul>
<h3 id="Install_and_launch">Install and launch</h3>
<ul>
  <li>Self-install your app on a device, or sideload it using the <a href="/en-US/docs/Tools/Firefox_OS_Simulator" title="/en-US/docs/Tools/Firefox_OS_Simulator">Firefox OS Simulator</a>.</li>
  <li>Test your server logic with the simulated postback.</li>
</ul>
<h2 id="Hosted_app_that_is_prepaid">Hosted app that is prepaid</h2>
<h3 id="Test_code">Test code</h3>
<ul>
  <li>The hosted app accesses its receipt and checks the issuer, type and product.</li>
  <li>The hosted app uploads its receipt to your server.</li>
  <li>Your server verifies the receipt against the verification URL.</li>
</ul>
<h3 id="Install_and_launch">Install and launch</h3>
<ul>
  <li>Use the test receipts page to install your app with a test receipt.</li>
  <li>Launch the app and test its&nbsp;receipt validation.</li>
</ul>
<h2 id="Packaged_app_with_in-app_payments">Packaged app with in-app payments</h2>
<h3 id="Test_code">Test code</h3>
<p>This assumes your packaged app has a server for handling in-app payments.</p>
<ul>
  <li><span style="line-height: 1.572;">The packaged app invokes </span><a href="/en-US/docs/DOM/window.navigator.mozPay" style="line-height: 1.572;" title="/en-US/docs/DOM/window.navigator.mozPay"><code>navigator.mozPay()</code></a><span style="line-height: 1.572;">.</span></li>
  <li>Your server creates an in-app payment JWT with the <code>simulate</code>&nbsp;flag.</li>
  <li>Your server gets a simulated in-app payment postback.</li>
</ul>
<h3 id="Install_and_launch">Install and launch</h3>
<ul>
  <li>Self-install your app on a device, or sideload it using the Firefox OS Simulator.</li>
  <li>Test your server logic with the simulated postback.</li>
</ul>
<h2 id="Packaged_app_that_is_prepaid">Packaged app that is prepaid</h2>
<h3 id="Test_code">Test code</h3>
<ul>
  <li>The packaged app accesses its receipt and checks the issuer, type and product.</li>
  <li>The packaged app verifies the receipt against the verification URL.</li>
</ul>
<h3 id="Install_and_launch">Install and launch</h3>
<ul>
  <li>Use the Simulator to install your app with a test receipt.</li>
  <li>Launch the app and test its receipt validation.</li>
</ul>
<h2 id="See_also">See also</h2>
<p><a href="https://marketplace.firefox.com/developers/docs/payments" title="https://marketplace.firefox.com/developers/docs/payments">Payments</a></p>
<p><a href="https://hacks.mozilla.org/2013/04/introducing-navigator-mozpay-for-web-payments/" title="https://hacks.mozilla.org/2013/04/introducing-navigator-mozpay-for-web-payments/">Introducing navigator.mozPay() for web payments</a></p>
<p><a href="https://hacks.mozilla.org/2013/02/building-a-paid-app-for-firefox-os/" title="https://hacks.mozilla.org/2013/02/building-a-paid-app-for-firefox-os/">Building a paid app for Firefox OS</a></p>
<p><a href="/en-US/docs/Apps/Publishing/Validating_a_receipt" title="/en-US/docs/Apps/Publishing/Validating_a_receipt">Validating a receipt</a></p>
<p><a href="/en-US/docs/Apps/FAQs/Marketplace_payments" title="/en-US/docs/Apps/FAQs/Marketplace_payments">Marketplace payments FAQ</a></p>
Revert to this revision