本文整理汇总了Python中mkt.inapp_pay.models.InappConfig.generate_public_key方法的典型用法代码示例。如果您正苦于以下问题:Python InappConfig.generate_public_key方法的具体用法?Python InappConfig.generate_public_key怎么用?Python InappConfig.generate_public_key使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mkt.inapp_pay.models.InappConfig
的用法示例。
在下文中一共展示了InappConfig.generate_public_key方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: in_app_config
# 需要导入模块: from mkt.inapp_pay.models import InappConfig [as 别名]
# 或者: from mkt.inapp_pay.models.InappConfig import generate_public_key [as 别名]
def in_app_config(request, addon_id, addon, webapp=True):
if addon.premium_type not in amo.ADDON_INAPPS:
messages.error(request, 'Your app does not use payments.')
return redirect(addon.get_dev_url('payments'))
try:
inapp_config = InappConfig.objects.get(addon=addon,
status=amo.INAPP_STATUS_ACTIVE)
except models.ObjectDoesNotExist:
inapp_config = None
inapp_form = InappConfigForm(request.POST or None,
instance=inapp_config)
if request.method == 'POST' and inapp_form.is_valid():
new_inapp = inapp_form.save(commit=False)
new_inapp.addon = addon
new_inapp.status = amo.INAPP_STATUS_ACTIVE
if not new_inapp.public_key:
new_inapp.public_key = InappConfig.generate_public_key()
new_inapp.save()
if not new_inapp.has_private_key():
new_inapp.set_private_key(InappConfig.generate_private_key())
messages.success(request, _('Changes successfully saved.'))
return redirect(addon.get_dev_url('in_app_config'))
return jingo.render(request, 'developers/payments/in-app-config.html',
dict(addon=addon, inapp_form=inapp_form,
inapp_config=inapp_config))
示例2: setUp
# 需要导入模块: from mkt.inapp_pay.models import InappConfig [as 别名]
# 或者: from mkt.inapp_pay.models.InappConfig import generate_public_key [as 别名]
def setUp(self):
self.app = self.get_app()
cfg = self.inapp_config = InappConfig(addon=self.app,
status=amo.INAPP_STATUS_ACTIVE)
cfg.public_key = self.app_id = InappConfig.generate_public_key()
cfg.private_key = self.app_secret = InappConfig.generate_private_key()
cfg.save()
self.app.paypal_id = '[email protected]'
self.app.save()
示例3: setUp
# 需要导入模块: from mkt.inapp_pay.models import InappConfig [as 别名]
# 或者: from mkt.inapp_pay.models.InappConfig import generate_public_key [as 别名]
def setUp(self):
self.app = self.get_app()
cfg = self.inapp_config = InappConfig(addon=self.app,
status=amo.INAPP_STATUS_ACTIVE)
cfg.public_key = self.app_id = InappConfig.generate_public_key()
self.app_secret = InappConfig.generate_private_key()
cfg.save()
cfg.set_private_key(self.app_secret)
self.app.paypal_id = '[email protected]'
self.app.save()
if hasattr(Price, '_currencies'):
del Price._currencies # needed to pick up fixtures.
示例4: test_retry_public_keygen_until_unique
# 需要导入模块: from mkt.inapp_pay.models import InappConfig [as 别名]
# 或者: from mkt.inapp_pay.models.InappConfig import generate_public_key [as 别名]
def test_retry_public_keygen_until_unique(self, fake_filter):
(
fake_filter.expects_call()
.returns_fake()
.expects("count")
.returns(1)
.next_call()
.returns(1)
.next_call()
.returns(0)
)
assert InappConfig.generate_public_key(max_tries=5)
示例5: setUp
# 需要导入模块: from mkt.inapp_pay.models import InappConfig [as 别名]
# 或者: from mkt.inapp_pay.models.InappConfig import generate_public_key [as 别名]
def setUp(self):
super(TestInappIPN, self).setUp()
self.app = self.get_app()
cfg = self.inapp_config = InappConfig(addon=self.app,
status=amo.INAPP_STATUS_ACTIVE)
cfg.public_key = self.app_id = InappConfig.generate_public_key()
cfg.private_key = self.app_secret = InappConfig.generate_private_key()
cfg.save()
self.app.paypal_id = '[email protected]'
self.app.save()
waffle.models.Switch.objects.create(name='in-app-payments-ui',
active=True)
self.user = UserProfile.objects.get(email='[email protected]')
assert self.client.login(username='[email protected]',
password='password')
示例6: reset_in_app_config
# 需要导入模块: from mkt.inapp_pay.models import InappConfig [as 别名]
# 或者: from mkt.inapp_pay.models.InappConfig import generate_public_key [as 别名]
def reset_in_app_config(request, addon_id, addon, config_id, webapp=True):
if addon.premium_type not in amo.ADDON_INAPPS:
messages.error(request, "Your app does not use payments.")
return redirect(addon.get_dev_url("payments"))
cfg = get_object_or_404(InappConfig, addon=addon, status=amo.INAPP_STATUS_ACTIVE)
msg = "user reset in-app payment config %s; " "key: %r; app: %s" % (cfg.pk, cfg.public_key, addon.pk)
log.info(msg)
inapp_cef.log(request, addon, "inapp_reset", msg, severity=6)
cfg.update(status=amo.INAPP_STATUS_REVOKED)
kw = dict(
addon=cfg.addon,
status=amo.INAPP_STATUS_ACTIVE,
postback_url=cfg.postback_url,
chargeback_url=cfg.chargeback_url,
public_key=InappConfig.generate_public_key(),
)
new_cfg = InappConfig.objects.create(**kw)
new_cfg.set_private_key(InappConfig.generate_private_key())
messages.success(request, _("Old credentials revoked; " "new credentials were generated successfully."))
return redirect(addon.get_dev_url("in_app_config"))
示例7: test_exhaust_public_keygen_attempts
# 需要导入模块: from mkt.inapp_pay.models import InappConfig [as 别名]
# 或者: from mkt.inapp_pay.models.InappConfig import generate_public_key [as 别名]
def test_exhaust_public_keygen_attempts(self, fake_filter):
fake_filter.expects_call().returns_fake().expects('count').returns(1)
InappConfig.generate_public_key(max_tries=5)
示例8: test_generate_public_key
# 需要导入模块: from mkt.inapp_pay.models import InappConfig [as 别名]
# 或者: from mkt.inapp_pay.models.InappConfig import generate_public_key [as 别名]
def test_generate_public_key(self):
key = InappConfig.generate_public_key()
assert key