def test_make_an_in_app_payment(self):

        account = self.create_firefox_account()
        homescreen = self.install_in_app_payments_test_app(self.test_data['app_name'])

        # Verify that the app icon is visible on one of the homescreen pages
        self.assertTrue(
            homescreen.is_app_installed(self.test_data['app_name']),
            'App %s not found on homescreen' % self.test_data['app_name'])

        self.tester_app = InAppPaymentTester(self.marionette, self.test_data['app_name'])
        self.tester_app.launch()
        Wait(self.marionette).until(lambda m: m.title == self.test_data['app_title'])

        fxa = self.tester_app.tap_buy_product(self.test_data['product'])
        fxa.login(account.email, account.password)

        payment = InAppPayment(self.marionette)
        payment.create_pin(self.test_data['pin'])

        self.assertEqual('Confirm Payment', payment.confirm_payment_header_text)
        self.assertEqual(self.test_data['product'], payment.in_app_product_name)

        payment.tap_buy_button()
        self.tester_app.wait_for_bought_products_displayed()
        self.assertEqual(self.test_data['product'], self.tester_app.bought_product_text)
    def test_not_you_logout_from_in_app_payment(self):

        account = self.create_firefox_account()
        homescreen = self.install_in_app_payments_test_app(self.test_data['app_name'])

        # Verify that the app icon is visible on one of the homescreen pages
        self.assertTrue(
            homescreen.is_app_installed(self.test_data['app_name']),
            'App %s not found on homescreen' % self.test_data['app_name'])

        self.tester_app = InAppPaymentTester(self.marionette, self.test_data['app_name'])
        self.tester_app.launch()
        Wait(self.marionette).until(lambda m: m.title == self.test_data['app_title'])

        fxa = self.tester_app.tap_buy_product(self.test_data['product'])
        fxa.login(account.email, account.password)

        payment = InAppPayment(self.marionette)
        payment.tap_cancel_pin()

        fxa = self.tester_app.tap_buy_product(self.test_data['product'])
        self.assertTrue(fxa.is_not_you_logout_link_visible)
        self.assertEqual('You are signed in as: %s' % account.email, 'You are signed in as: %s' % fxa.email_text)

        fxa.tap_not_you()
        fxa.wait_for_password_field_visible()