diff --git a/media/js/devreg/paypal.js b/media/js/devreg/paypal.js index 929faa56d8..af0db2fc6d 100644 --- a/media/js/devreg/paypal.js +++ b/media/js/devreg/paypal.js @@ -10,10 +10,10 @@ exports.email_setup = function() { } $('div.paypal-inline input[type=radio]').click(function(e) { - if ($(this).val() === 'no') { - $('#id_email').closest('div').hide(); - } else { + if ($(this).val() === 'yes') { $('#id_email').closest('div').show(); + } else { + $('#id_email').closest('div').hide(); } }); } diff --git a/mkt/developers/forms.py b/mkt/developers/forms.py index aa6d8ee2e1..77c0ac5435 100644 --- a/mkt/developers/forms.py +++ b/mkt/developers/forms.py @@ -1198,13 +1198,18 @@ class AppFormBasic(addons.forms.AddonFormBase): class PaypalSetupForm(happyforms.Form): business_account = forms.ChoiceField(widget=forms.RadioSelect, - choices=(('no', _('No')), - ('yes', _('Yes'))), - label="""Do you already have a PayPal + choices=[], + label="""Do you already have a PayPal Premier or Business account?""") email = forms.EmailField(required=False, label='PayPal email address') + + def __init__(self, *args, **kw): + super(PaypalSetupForm, self).__init__(*args, **kw) + self.fields['business_account'].choices = (('yes', _lazy('Yes')), + ('no', _lazy('No'))) + def clean(self): data = self.cleaned_data if data.get('business_account') == 'yes' and not data.get('email'): diff --git a/mkt/developers/views.py b/mkt/developers/views.py index feb5c3df99..3151409b39 100644 --- a/mkt/developers/views.py +++ b/mkt/developers/views.py @@ -41,7 +41,8 @@ from addons.models import Addon, AddonUser from addons.views import BaseFilter from mkt.developers.decorators import dev_required from mkt.developers.forms import (CheckCompatibilityForm, InappConfigForm, - AppFormBasic, AppFormDetails) + AppFormBasic, AppFormDetails, + PaypalSetupForm) from mkt.developers.models import ActivityLog, SubmitStep from mkt.developers import perf from mkt.submit.decorators import submit_step @@ -260,7 +261,7 @@ def paypal_setup(request, addon_id, addon, webapp): messages.error(request, 'Your app does not use payments.') return redirect(addon.get_dev_url('payments')) - form = forms.PaypalSetupForm(request.POST or None) + form = PaypalSetupForm(request.POST or None) context = {'addon': addon, 'form': form} if form.is_valid(): existing = form.cleaned_data['business_account'] diff --git a/mkt/submit/forms.py b/mkt/submit/forms.py index c0cc4ec936..ee3e44d20f 100644 --- a/mkt/submit/forms.py +++ b/mkt/submit/forms.py @@ -16,6 +16,7 @@ from amo.utils import raise_required from devhub import tasks as devhub_tasks from files.models import FileUpload from market.models import AddonPremium, Price +from mkt.developers.forms import PaypalSetupForm as OriginalPaypalSetupForm from mkt.site.forms import AddonChoiceField, APP_UPSELL_CHOICES from translations.widgets import TransInput, TransTextarea from translations.fields import TransField @@ -54,6 +55,16 @@ class NewWebappForm(happyforms.Form): return upload +class PaypalSetupForm(OriginalPaypalSetupForm): + + def __init__(self, *args, **kw): + super(PaypalSetupForm, self).__init__(*args, **kw) + self.fields['business_account'].choices = ( + ('yes', _lazy('Yes')), + ('no', _lazy('No')), + ('later', _lazy("I'll link my PayPal account later."))) + + class PremiumTypeForm(happyforms.Form): premium_type = forms.TypedChoiceField(coerce=lambda x: int(x), choices=amo.ADDON_PREMIUM_TYPES.items(), diff --git a/mkt/submit/tests/test_views.py b/mkt/submit/tests/test_views.py index 10877aaa53..7b6ac2021e 100644 --- a/mkt/submit/tests/test_views.py +++ b/mkt/submit/tests/test_views.py @@ -737,6 +737,13 @@ class TestPaymentsAdvanced(TestSubmit): eq_(res.status_code, 302) eq_(res._headers['location'][1], settings.PAYPAL_CGI_URL) + def test_later_paypal(self): + self.webapp.update(premium_type=amo.ADDON_PREMIUM) + res = self.client.post(self.get_url('payments.paypal'), + {'business_account': 'later'}) + eq_(res.status_code, 302) + self.assertRedirects(res, self.get_url('done')) + def test_bad_paypal(self): # some tests for when it goes wrong raise SkipTest diff --git a/mkt/submit/views.py b/mkt/submit/views.py index bf32dceeff..d8bc5ed6cc 100644 --- a/mkt/submit/views.py +++ b/mkt/submit/views.py @@ -11,8 +11,9 @@ from addons.models import Addon, AddonUser from market.models import AddonPaymentData from mkt.developers import tasks from mkt.developers.decorators import dev_required -from mkt.developers.forms import PaypalSetupForm, PaypalPaymentData -from mkt.submit.forms import AppDetailsBasicForm, PreviewFormSet +from mkt.developers.forms import PaypalPaymentData +from mkt.submit.forms import (AppDetailsBasicForm, PaypalSetupForm, + PreviewFormSet) from mkt.submit.models import AppSubmissionChecklist import paypal from files.models import Platform @@ -174,6 +175,12 @@ def payments_paypal(request, addon_id, addon): form = PaypalSetupForm(request.POST or None) if request.POST and form.is_valid(): existing = form.cleaned_data['business_account'] + if existing == 'later': + # We'll have a premium or similar account with no PayPal id + # at this point. + (AppSubmissionChecklist.objects.get(addon=addon) + .update(payments=True)) + return redirect('submit.app.done', addon.app_slug) if existing != 'yes': # Go create an account. # TODO: this will either become the API or something some better