Test-case pay-service/setup-staging-account
<dl>
    <dt>Ensure that no U1 accounts are configured on the device</dt>
        <dd>Going to System Settings → Accounts shouldn't have any "Ubuntu One" entries shown</dd>
        <dd>Delete the account if there is one shown and exit system settings</dd>
    <dt>Set up the device to use the staging servers for Ubuntu One</dt>
        <dd>Execute the script: /usr/lib/*/pay-service/setup-staging.sh (log in via <tt>phablet-shell</tt>)</dd>
        <dd>It should run to completion without error</dd>
        <dd>This is just setting the variables to staging during the session, it might happend that some processes are restarted and the variables get lost, in that situation you will need to run the script again.</dd>
    <dt>Create an Ubuntu One account: ${your name}@canonical.com</dt>
        <dd>NOTE: This is only currently available to Canonical employees. There is work underway to make it more widely available but it is not complete yet.</dd>
        <dd>The System Settings app should allow creating the account and the account will show up in the list of accounts on the device.</dd>
    <dt>Add a testing credit card to your account</dt>
        <dd>Go to: https://staging.pay.ubuntu.com/account/ (Use the same Canonical Account to login).</dd>
        <dd>Click on "Add a new credit card" and complete the Credit Card info, using the following:</dd>
        <dd><tt>Name on Card: Test</tt></dd>
        <dd><tt>Card Type: Visa</tt></dd>
        <dd><tt>Card Number: 4111 1111 1111 1111</tt></dd>
        <dd><tt>CCV Number: 111</tt></dd>
        <dd><tt>Expiration date: 12/2021</tt></dd>
</dl>

Test-case pay-service/purchase-application
<dl>
    <dt>Create a new account with no previously purchased items</dt>
        <dd>The instructions in <tt>pay-service/setup-staging-account</tt> pass without error</dd>
    <dt>Find the "Delta" app in the application scope</dt>
        <dd>By searching for "Delta" an app should be listed and clicking on it show its preview</dd>
    <dt>Ensure that the Delta app has not been previously purchased</dt>
        <dd>The button in the preview should show the price of the app and not "Open" or "Install"</dd>
    <dt>Wait 10 minutes for the token to expire</dt>
        <dd>Take a nice walk on a sunny day</dd>
    <dt>Select the "Purchase" button for the "Delta" application</dt>
        <dd>The button should depress and a window should appear asking for your Ubuntu One password</dd>
    <dt>Enter your password and confirm the purchase</dt>
        <dd>The window should close and the application should begin downloading and install</dd>
</dl>

Test Plan: Pay UI - Procedure 

This test plan is not supposed to be complete; use it to guide your manual testing.

<dl>
    <dt>Make sure you completed the steps in {{{pay-service/setup-staging-account}}} before proceeding.</dt>
    <dt>Remove any registered Ubuntu One Account from the device.</dt>
    <dt>Find the "Delta" app in the application scope</dt>
         <dd>By searching for "Delta" an app should be listed and clicking on it show its preview</dd>
    <dt>Ensure that the Delta app has not been previously purchased</dt>
         <dd>The button in the preview should show the price of the app and not "Open" or "Install"</dd>
    <dt>Select the "Purchase" button for the "Delta" application</dt>
         <dd>The button should depress and a window should appear.</dd>
</dl>

-- No Account
<dl>
    <dt>Tap on the "Purchase" button in the Preview. It should shown a Loading dialog.</dt>
        <dd>Check the Online Accounts application is launched.</dd>
        <dd>Register your Ubuntu One account.</dd>
        <dd>Check that Online Accounts close itself after registering your account.</dd>
        <dd>Verify the Payment page is shown.</dd>
        <dd>Verify you see a "Cancel" and "Buy now" button, and the "Add credit/debit card" link.</dd>
</dl>

- Cancel button flow
<dl>
    <dt>Continues from the "No Account" flow</dt>
        <dd>Tap the "Cancel" button</dd>
        <dd>Verify that the application gets closed.</dd>
</dl>

- Buy Now button flow: case 1 
<dl>
    <dt>Continues from the "No Account" flow</dt>
        <dd>Tap the "Buy Now" button</dd>
        <dd>Verify the application gets closed and you receive an email indicating the app was purchased.</dd>
</dl>

- Buy Now button flow: case 2 
<dl>
    <dt>Continues from the "No Account" flow</dt>
        <dd>Wait for more than 3 minutes.</dd>
        <dd>Tap the "Buy Now" button.</dd>
        <dd>Verify that a dialog prompting the user to enters the Ubuntu One account password is shown.</dd>
        <dd>Type in the correct password for the registerd account.</dd>
        <dd>Verify the "Buy now" button gets enabled and the "View wallet" link is shown once you enter at least 8 characters.</dd>
        <dd>Tap the "Buy Now" button.</dd>
        <dd>Verify the application gets closed and you receive an email indicating the app was purchased.</dd>
</dl>

- Buy Now button flow: case 3 
<dl>
    <dt>Continues from the "No Account" flow</dt>
        <dd>Wait for more than 3 minutes.</dd>
        <dd>Tap the "Buy Now" button.</dd>
        <dd>Verify that a dialog prompting the user to enters the Ubuntu One account password is shown.</dd>
        <dd>Type in an incorrect password for the registerd account.</dd>
        <dd>Verify the "Buy now" button gets enabled and the "View wallet" link is shown once you enter at least 8 characters.</dd>
        <dd>Tap the "Buy Now" button.</dd>
        <dd>Verify a message appear under the password text field indicating the password was incorrect.</dd>
</dl>

-- With Account 

- Show Payments page flow: case 1 
<dl>
    <dt>With a registered account, Tap on the "Purchase" button in the Preview. It should shown a Loading dialog.</dt>
        <dd>Verify that a dialog prompting the user to enters the Ubuntu One account password is shown.</dd>
        <dd>Type in the correct password for the registerd account.</dd>
        <dd>Tap the "View wallet" link.</dd>
        <dd>Verify the Payment page appear showing the user payment methods.</dd>
</dl>

- Show Payments page flow: case 2 
<dl>
    <dt>With a registered account, Tap on the "Purchase" button in the Preview. It should shown a Loading dialog.</dt>
        <dd>Verify that a dialog prompting the user to enters the Ubuntu One account password is shown.</dd>
        <dd>Type an incorrect password for the registerd account (longer than 8 characters).</dd>
        <dd>Tap the "View wallet" link.</dd>
        <dd>Verify a message appear under the password text field indicating the password was incorrect.</dd>
</dl>

- Add credit/debig card flow: case 1 
<dl>
    <dt>With a registered account, Tap on the "Purchase" button in the Preview. It should shown a Loading dialog.</dt>
        <dd>Verify that a dialog prompting the user to enters the Ubuntu One account password is shown.</dd>
        <dd>Type an incorrect password for the registerd account (longer than 8 characters).</dd>
        <dd>Tap the "View wallet" link.</dd>
        <dd>Verify the Payment page appear showing the user payment methods.</dd>
        <dd>Tap the "Add credit/debit card" link.</dd>
        <dd>Verify the Add Credit Card webpage is displayed embedded in the application.</dd>
        <dd>Tap the "Cancel" button at the end</dd>
        <dd>Verify that you are back to the Payments page.</dd>
</dl>

- Add credit/debig card flow: case 2 
<dl>
    <dt>With a registered account, Tap on the "Purchase" button in the Preview. It should shown a Loading dialog.</dt>
        <dd>Verify that a dialog prompting the user to enters the Ubuntu One account password is shown.</dd>
        <dd>Type an incorrect password for the registerd account (longer than 8 characters).</dd>
        <dd>Tap the "View wallet" link.</dd>
        <dd>Verify the Payment page appear showing the user payment methods.</dd>
        <dd>Tap the "Add credit/debit card" link.</dd>
        <dd>Verify the Add Credit Card webpage is displayed embedded in the application.</dd>
        <dd>Enter a valid credit card info.</dd>
        <dd>Tap the "Add card" button at the end</dd>
        <dd>Verify that you are back to the Payments page and the new credit card is shown in the list.</dd>
</dl>

- Buy Now flow: case 1 
<dl>
    <dt>Wait more than 3 minutes before any previous purchase</dt>
    <dt>With a registered account, Tap on the "Purchase" button in the Preview. It should shown a Loading dialog.</dt>
        <dd>Verify that a dialog prompting the user to enters the Ubuntu One account password is shown.</dd>
        <dd>Type in the correct password for the registerd account.</dd>
        <dd>Tap the "Buy now" button.</dd>
        <dd>Verify the application gets closed and you receive an email indicating the app was purchased.</dd>
</dl>

- Buy Now flow: case 2 
<dl>
    <dt>Wait more than 3 minutes before any previous purchase</dt>
    <dt>With a registered account, Tap on the "Purchase" button in the Preview. It should shown a Loading dialog.</dt>
        <dd>Verify that a dialog prompting the user to enters the Ubuntu One account password is shown.</dd>
        <dd>Type an incorrect password for the registerd account (longer than 8 characters).</dd>
        <dd>Tap the "Buy now" button.</dd>
        <dd>Verify a message appear under the password text field indicating the password was incorrect.</dd>
</dl>
  
- Show Direct purchase dialog
<dl>
    <dt>With a registered account, Tap on the "Purchase" button in the Preview. It should shown a Loading dialog. </dt>
        <dd>Verify that a dialog prompting the user to enters the Ubuntu One account password is shown.</dd>
        <dd>Type in the correct password for the registerd account.</dd>
        <dd>Tap the "View wallet" link.</dd>
        <dd>Verify the Payment page appear showing the user payment methods.</dd>
        <dd>Press the Cancel button</dd>
        <dd>Tap on the "Purchase" button in the Preview again.</dd>
        <dd>Verify that a dialog with the app info and price appear, and the password text field and labels indicating to enter the password don't.</dd>
        <dd>Verify the "View Wallet" link is visible.</dd>
</dl>

- Show Direct purchase without preferred payment method dialog
<dl>
 <dt>With a registered account, and using it for the first time in the device, Tap on the "Purchase" button in the Preview. It should shown a Loading dialog.</dt>
  <dd>Verify that a dialog prompting the user to enters the Ubuntu One account password is shown.</dd>
  <dd>Type in the correct password for the registerd account.</dd>
  <dd>Tap the "Confirm" button.</dd>
  <dd>Verify the Payment page appear showing the user payment methods.</dd>
  <dd>Press the "Buy now" button</dd>
  <dd>Press the "Cancel" button to cancel the transaction (the selected payment method has been stored locally at this point already).</dd>
  <dd>Tap on the "Purchase" button in the Preview again.</dd>
  <dd>Verify that a dialog with the app info and price appear, and the password text field and labels indicating to enter the password don't.</dd>
  <dd>Verify the "View Wallet" link is visible.</dd>
  <dd>Verify the button says now "Buy now" instead of "Confirm"</dd>
  <dd>Tap the "Buy Now" button</dd>
  <dd>Verify the process proceed with the purchase and not showing the Wallet.</dd>
</dl>
