• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python webpay_jwt.get_product_jwt函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中mkt.webpay.webpay_jwt.get_product_jwt函数的典型用法代码示例。如果您正苦于以下问题:Python get_product_jwt函数的具体用法?Python get_product_jwt怎么用?Python get_product_jwt使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_product_jwt函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: debug

def debug(request, addon):
    if not settings.DEBUG:
        raise http.Http404

    context = {
        'app': addon,
        'inapps': [],
        'urls': {'es': '%s/apps/webapp/%s' % (settings.ES_URLS[0], addon.pk)},
    }

    if addon.is_premium():
        contribution = Contribution.objects.create(addon=addon)
        context['app_jwt'] = get_product_jwt(
            WebAppProduct(addon),
            contribution,
        )['webpayJWT']

        for inapp in addon.inappproduct_set.all():
            contribution = Contribution.objects.create(
                addon=addon,
                inapp_product=inapp,
            )
            context['inapps'].append({
                'inapp': inapp,
                'jwt': get_product_jwt(
                    InAppProduct(inapp),
                    contribution,
                )['webpayJWT'],
            })

    return render(request, 'developers/debug.html', context)
开发者ID:patilkr,项目名称:zamboni,代码行数:31,代码来源:views.py


示例2: post

    def post(self, request, *args, **kwargs):
        form = PrepareInAppForm(request.DATA)
        if not form.is_valid():
            app_pay_cef.log(
                request._request,
                'Preparing InApp JWT Failed',
                'preparing_inapp_jwt_failed',
                'Preparing InApp JWT Failed error: {0}'.format(form.errors),
                severity=3
            )
            return Response(form.errors, status=status.HTTP_400_BAD_REQUEST)

        inapp = form.cleaned_data['inapp']

        app_pay_cef.log(
            request._request,
            'Preparing InApp JWT',
            'preparing_inapp_jwt',
            'Preparing InApp JWT for: {0}'.format(inapp.pk), severity=3
        )

        token = get_product_jwt(
            InAppProduct(inapp),
            client_data=ClientData.get_or_create(request._request),
            lang=request._request.LANG,
            source=request._request.REQUEST.get('src', ''),
        )

        return Response(token, status=status.HTTP_201_CREATED)
开发者ID:BIGGANI,项目名称:zamboni,代码行数:29,代码来源:resources.py


示例3: prepare_pay

def prepare_pay(request, addon):
    if addon.is_premium() and addon.has_purchased(request.user):
        log.info('Already purchased: %d' % addon.pk)
        raise AlreadyPurchased

    app_pay_cef.log(request, 'Preparing JWT', 'preparing_jwt',
                    'Preparing JWT for: %s' % (addon.pk), severity=3)

    log.debug('Starting purchase of app: {0} by user: {1}'.format(
        addon.pk, request.user))

    contribution = Contribution.objects.create(
        addon_id=addon.pk,
        amount=addon.get_price(region=request.REGION.id),
        paykey=None,
        price_tier=addon.premium.price,
        source=request.REQUEST.get('src', ''),
        source_locale=request.LANG,
        type=amo.CONTRIB_PENDING,
        user=request.user,
        uuid=str(uuid.uuid4()),
    )

    log.debug('Storing contrib for uuid: {0}'.format(contribution.uuid))

    return get_product_jwt(WebAppProduct(addon), contribution)
开发者ID:kylewu,项目名称:zamboni,代码行数:26,代码来源:webpay.py


示例4: debug

def debug(request, addon):
    if not settings.DEBUG:
        raise http.Http404

    context = {"app": addon, "inapps": [], "urls": {"es": "%s/apps/webapp/%s" % (settings.ES_URLS[0], addon.pk)}}

    if addon.is_premium():
        contribution = Contribution.objects.create(addon=addon)
        context["app_jwt"] = get_product_jwt(WebAppProduct(addon), contribution)["webpayJWT"]

        for inapp in addon.inappproduct_set.all():
            contribution = Contribution.objects.create(addon=addon, inapp_product=inapp)
            context["inapps"].append(
                {"inapp": inapp, "jwt": get_product_jwt(InAppProduct(inapp), contribution)["webpayJWT"]}
            )

    return render(request, "developers/debug.html", context)
开发者ID:ngokevin,项目名称:zamboni,代码行数:17,代码来源:views.py


示例5: setUp

 def setUp(self):
     super(TestInAppProduct, self).setUp()
     self.contribution = Contribution.objects.create(
         user=self.user,
         addon=self.addon,
     )
     self.product = InAppProduct(self.inapp)
     self.token = get_product_jwt(self.product, self.contribution)
开发者ID:jinankjain,项目名称:zamboni,代码行数:8,代码来源:test_webpay_jwt.py


示例6: setUp

    def setUp(self):
        super(TestWebAppProduct, self).setUp()
        self.product = WebAppProduct(self.addon)
        self.token = get_product_jwt(
            self.product,
            region=regions.US,
            user=self.user,
        )

        self.contribution = Contribution.objects.get()
开发者ID:amitdash,项目名称:zamboni,代码行数:10,代码来源:test_webpay_jwt.py


示例7: post

    def post(self, request, *args, **kwargs):
        form = PrepareInAppForm(request.DATA)
        if not form.is_valid():
            app_pay_cef.log(
                request._request,
                'Preparing InApp JWT Failed',
                'preparing_inapp_jwt_failed',
                'Preparing InApp JWT Failed error: {0}'.format(form.errors),
                severity=3
            )
            return Response(form.errors, status=status.HTTP_400_BAD_REQUEST)

        inapp = form.cleaned_data['inapp']

        app_pay_cef.log(
            request._request,
            'Preparing InApp JWT',
            'preparing_inapp_jwt',
            'Preparing InApp JWT for: {0}'.format(inapp.pk), severity=3
        )

        log.debug('Starting purchase of in app: {0}'.format(inapp.pk))

        contribution = Contribution.objects.create(
            addon_id=inapp.webapp and inapp.webapp.pk,
            inapp_product=inapp,
            # In-App payments are unauthenticated so we have no user
            # and therefore can't determine a meaningful region.
            amount=None,
            paykey=None,
            price_tier=inapp.price,
            source=request._request.REQUEST.get('src', ''),
            source_locale=request._request.LANG,
            type=amo.CONTRIB_PENDING,
            user=None,
            uuid=str(uuid.uuid4()),
        )

        log.info('Storing contrib for uuid: {0}'.format(contribution.uuid))

        if inapp.simulate:
            log.info('Preparing in-app JWT simulation for {i}'
                     .format(i=inapp))
            product = SimulatedInAppProduct(inapp)
        else:
            log.info('Preparing in-app JWT for {i}'.format(i=inapp))
            product = InAppProduct(inapp)
        token = get_product_jwt(product, contribution)

        return Response(token, status=status.HTTP_201_CREATED)
开发者ID:MorrisJobke,项目名称:zamboni,代码行数:50,代码来源:views.py


示例8: post

    def post(self, request, *args, **kwargs):
        form = PrepareWebAppForm(request.DATA)
        if not form.is_valid():
            return Response(form.errors, status=status.HTTP_400_BAD_REQUEST)

        app = form.cleaned_data['app']

        region = getattr(request, 'REGION', None)
        if region:
            enabled_regions = app.get_price_region_ids()
            region_can_purchase = region.id in enabled_regions
            restofworld_can_purchase = RESTOFWORLD.id in enabled_regions

            if not region_can_purchase and not restofworld_can_purchase:
                log.info('Region {0} is not in {1}; '
                         'restofworld purchases are inactive'
                         .format(region.id, enabled_regions))
                return Response(
                    {'reason': 'Payments are restricted for this region'},
                    status=status.HTTP_403_FORBIDDEN)

        if app.is_premium() and app.has_purchased(request._request.user):
            log.info('Already purchased: {0}'.format(app.pk))
            return Response({'reason': u'Already purchased app.'},
                            status=status.HTTP_409_CONFLICT)

        app_pay_cef.log(request._request, 'Preparing JWT', 'preparing_jwt',
                        'Preparing JWT for: {0}'.format(app.pk), severity=3)

        log.debug('Starting purchase of app: {0} by user: {1}'.format(
            app.pk, request._request.user))

        contribution = Contribution.objects.create(
            addon_id=app.pk,
            amount=app.get_price(region=request._request.REGION.id),
            paykey=None,
            price_tier=app.premium.price,
            source=request._request.REQUEST.get('src', ''),
            source_locale=request._request.LANG,
            type=mkt.CONTRIB_PENDING,
            user=request._request.user,
            uuid=str(uuid.uuid4()),
        )

        log.debug('Storing contrib for uuid: {0}'.format(contribution.uuid))

        token = get_product_jwt(WebAppProduct(app), contribution)

        return Response(token, status=status.HTTP_201_CREATED)
开发者ID:atiqueahmedziad,项目名称:zamboni,代码行数:49,代码来源:views.py


示例9: prepare_pay

def prepare_pay(request, addon):
    if addon.is_premium() and addon.has_purchased(request.amo_user):
        log.info('Already purchased: %d' % addon.pk)
        raise AlreadyPurchased

    app_pay_cef.log(request, 'Preparing JWT', 'preparing_jwt',
                    'Preparing JWT for: %s' % (addon.pk), severity=3)

    return get_product_jwt(
        WebAppProduct(addon),
        user=request.amo_user,
        region=request.REGION,
        source=request.REQUEST.get('src', ''),
        lang=request.LANG,
        client_data=ClientData.get_or_create(request),
    )
开发者ID:BIGGANI,项目名称:zamboni,代码行数:16,代码来源:webpay.py


示例10: debug

def debug(request, addon):
    if not settings.DEBUG:
        raise http.Http404

    data = {
        'urls': {'es': '%s/apps/webapp/%s' % (settings.ES_URLS[0], addon.pk)},
        'pay_request': ''
    }
    if addon.is_premium():
        data['pay_request'] = get_product_jwt(
            WebAppProduct(addon),
            user=request.amo_user,
            region=request.REGION,
            source=request.REQUEST.get('src', ''),
            lang=request.LANG
        )['webpayJWT']

    return render(request, 'developers/debug.html',
                  {'app': addon, 'data': data})
开发者ID:jinankjain,项目名称:zamboni,代码行数:19,代码来源:views.py


示例11: _prepare_pay

def _prepare_pay(request, webapp):
    app_pay_cef.log(request, 'Preparing JWT', 'preparing_jwt',
                    'Preparing JWT for: %s' % (webapp.pk), severity=3)

    log.debug('Starting purchase of app: {0} by user: {1}'.format(
        webapp.pk, request.user))

    contribution = Contribution.objects.create(
        webapp_id=webapp.pk,
        amount=webapp.get_price(region=request.REGION.id),
        paykey=None,
        price_tier=webapp.premium.price,
        source=request.GET.get('src', ''),
        source_locale=request.LANG,
        type=mkt.CONTRIB_PENDING,
        user=request.user,
        uuid=str(uuid.uuid4()),
    )

    log.debug('Storing contrib for uuid: {0}'.format(contribution.uuid))

    return get_product_jwt(WebAppProduct(webapp), contribution)
开发者ID:shahbaz17,项目名称:zamboni,代码行数:22,代码来源:webpay.py


示例12: decode_token

 def decode_token(self):
     token = get_product_jwt(self.product, self.contribution)
     return jwt.decode(str(token['webpayJWT']), verify=False)
开发者ID:Fjoerfoks,项目名称:zamboni,代码行数:3,代码来源:test_webpay_jwt.py



注:本文中的mkt.webpay.webpay_jwt.get_product_jwt函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python models.Website类代码示例发布时间:2022-05-27
下一篇:
Python utils.es_app_to_dict函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap