def test_too_many(self, get_seller): get_seller.return_value = { 'meta': { 'total_count': 2 }, } with self.assertRaises(ValueError): client.create_seller_paypal(self.addon)
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 # URL for the future. return redirect(settings.PAYPAL_CGI_URL) if waffle.flag_is_active(request, 'solitude-payments'): obj = client.create_seller_paypal(addon) client.patch_seller_paypal(pk=obj['resource_pk'], data={'paypal_id': form.cleaned_data['email']}) addon.update(paypal_id=form.cleaned_data['email']) return redirect('submit.app.payments.bounce', addon.app_slug) return jingo.render(request, 'submit/payments-paypal.html', { 'step': 'payments', 'addon': addon, 'form': form })
def test_nothing(self, post_seller_paypal, post_seller, get_seller): get_seller.return_value = { 'meta': {'total_count': 0}, } post_seller_paypal.return_value = {'resource_pk': 1} eq_(client.create_seller_paypal(self.addon), {'resource_pk': 1}) assert post_seller_paypal.called
def test_no_paypal(self, post_seller_paypal, post_seller, get_seller): get_seller.return_value = { 'meta': {'total_count': 1}, 'objects': [{'resource_uri': 1, 'paypal': None}] } post_seller_paypal.return_value = {'resource_pk': 1} eq_(client.create_seller_paypal(self.addon), {'resource_pk': 1}) assert post_seller_paypal.called
def test_nothing(self, post_seller_paypal, post_seller, get_seller): get_seller.return_value = { 'meta': { 'total_count': 0 }, } post_seller_paypal.return_value = {'resource_pk': 1} eq_(client.create_seller_paypal(self.addon), {'resource_pk': 1}) assert post_seller_paypal.called
def test_create_exists_paypal(self, post_seller, get_seller): get_seller.return_value = { 'meta': { 'total_count': 1 }, 'objects': [{ 'paypal': { 'resource_pk': 1 } }] } eq_(client.create_seller_paypal(self.addon), {'resource_pk': 1})
def test_no_paypal(self, post_seller_paypal, post_seller, get_seller): get_seller.return_value = { 'meta': { 'total_count': 1 }, 'objects': [{ 'resource_uri': 1, 'paypal': None }] } post_seller_paypal.return_value = {'resource_pk': 1} eq_(client.create_seller_paypal(self.addon), {'resource_pk': 1}) assert post_seller_paypal.called
def paypal_setup(request, addon_id, addon, webapp): if addon.premium_type == amo.ADDON_FREE: messages.error(request, 'Your app does not use payments.') return redirect(addon.get_dev_url('payments')) paypal_form = PaypalSetupForm(request.POST or None) currency_form = CurrencyForm(request.POST or None, initial={'currencies': addon.premium.currencies if addon.premium else {}}) context = {'addon': addon, 'paypal_form': paypal_form, 'currency_form': currency_form} if request.POST.get('form') == 'paypal' and paypal_form.is_valid(): existing = paypal_form.cleaned_data['business_account'] if existing != 'yes': # Go create an account. # TODO: this will either become the API or something some better # URL for the future. return redirect(settings.PAYPAL_CGI_URL) else: # Go setup your details on paypal. # TODO(solitude): we will remove this. addon.update(paypal_id=paypal_form.cleaned_data['email']) if waffle.flag_is_active(request, 'solitude-payments'): obj = client.create_seller_paypal(addon) client.patch_seller_paypal(pk=obj['resource_pk'], data={'paypal_id': paypal_form.cleaned_data['email']}) if addon.premium and addon.premium.paypal_permissions_token: addon.premium.update(paypal_permissions_token='') return redirect(addon.get_dev_url('paypal_setup_bounce')) if (waffle.switch_is_active('currencies') and request.POST.get('form') == 'currency' and currency_form.is_valid()): currencies = currency_form.cleaned_data['currencies'] addon.premium.update(currencies=currencies) messages.success(request, _('Currencies updated.')) return redirect(addon.get_dev_url('paypal_setup')) return jingo.render(request, 'developers/payments/paypal-setup.html', context)
def paypal_setup(request, addon_id, addon, webapp): if addon.premium_type == amo.ADDON_FREE: messages.error(request, "Your app does not use payments.") return redirect(addon.get_dev_url("payments")) paypal_form = PaypalSetupForm(request.POST or None) currency_form = CurrencyForm( request.POST or None, initial={"currencies": addon.premium.currencies if addon.premium else {}} ) context = {"addon": addon, "paypal_form": paypal_form, "currency_form": currency_form} if request.POST.get("form") == "paypal" and paypal_form.is_valid(): existing = paypal_form.cleaned_data["business_account"] if existing != "yes": # Go create an account. # TODO: this will either become the API or something some better # URL for the future. return redirect(settings.PAYPAL_CGI_URL) else: # Go setup your details on paypal. # TODO(solitude): we will remove this. addon.update(paypal_id=paypal_form.cleaned_data["email"]) if waffle.flag_is_active(request, "solitude-payments"): obj = client.create_seller_paypal(addon) client.patch_seller_paypal(pk=obj["resource_pk"], data={"paypal_id": paypal_form.cleaned_data["email"]}) if addon.premium and addon.premium.paypal_permissions_token: addon.premium.update(paypal_permissions_token="") return redirect(addon.get_dev_url("paypal_setup_bounce")) if waffle.switch_is_active("currencies") and request.POST.get("form") == "currency" and currency_form.is_valid(): currencies = currency_form.cleaned_data["currencies"] addon.premium.update(currencies=currencies) messages.success(request, _("Currencies updated.")) return redirect(addon.get_dev_url("paypal_setup")) return jingo.render(request, "developers/payments/paypal-setup.html", context)
def test_too_many(self, get_seller): get_seller.return_value = { 'meta': {'total_count': 2}, } with self.assertRaises(ValueError): client.create_seller_paypal(self.addon)
def test_create_exists_paypal(self, post_seller, get_seller): get_seller.return_value = { 'meta': {'total_count': 1}, 'objects': [{'paypal': {'resource_pk': 1}}] } eq_(client.create_seller_paypal(self.addon), {'resource_pk': 1})
def test_nothing(self, post_seller_paypal, post_seller, get_seller): get_seller.return_value = {"meta": {"total_count": 0}} post_seller_paypal.return_value = {"resource_pk": 1} eq_(client.create_seller_paypal(self.addon), {"resource_pk": 1}) assert post_seller_paypal.called
def test_no_paypal(self, post_seller_paypal, post_seller, get_seller): get_seller.return_value = {"meta": {"total_count": 1}, "objects": [{"resource_uri": 1, "paypal": None}]} post_seller_paypal.return_value = {"resource_pk": 1} eq_(client.create_seller_paypal(self.addon), {"resource_pk": 1}) assert post_seller_paypal.called
def test_create_exists_paypal(self, post_seller, get_seller): get_seller.return_value = {"meta": {"total_count": 1}, "objects": [{"paypal": {"resource_pk": 1}}]} eq_(client.create_seller_paypal(self.addon), {"resource_pk": 1})