Пример #1
0
    def get(self, request):
        self.user = request.user
        self.apply_vip = VipRoleUtils.get_apply_vip(self.user)
        if not self.apply_vip:
            return JsonResponse({
                'status': 'apply_error',
                'msg': '没有申请信息',
            })

        order = self.create_order()
        alipay_return_url = request.build_absolute_uri(
            reverse('vip-alipay-return'))
        alipay_notify_url = request.build_absolute_uri(
            reverse('vip-alipay-notify'))
        pay_url = AlipayUtils.submit_order_url(
            order,
            return_url=alipay_return_url,
            notify_url=alipay_notify_url,
            order_price=order.order_price,
        )

        return JsonResponse({
            'status': 'ok',
            'msg': '订单生成成功',
            'pay_url': pay_url,
            'order_id': order.id,
        })
Пример #2
0
    def get(self, request):
        self.user = request.user
        self.apply_vip = VipRoleUtils.get_apply_vip(self.user)
        if not self.apply_vip:
            return JsonResponse({
                'status': 'apply_error',
                'msg': '没有申请信息',
            })

        order = self.create_order()
        alipay_return_url = request.build_absolute_uri(
            reverse('vip-alipay-return')
        )
        alipay_notify_url = request.build_absolute_uri(
            reverse('vip-alipay-notify')
        )
        pay_url = AlipayUtils.submit_order_url(
            order,
            return_url=alipay_return_url,
            notify_url=alipay_notify_url,
            order_price=order.order_price,
        )

        return JsonResponse({
            'status': 'ok',
            'msg': '订单生成成功',
            'pay_url': pay_url,
            'order_id': order.id,
        })
Пример #3
0
    def post(self, request):
        user = request.user
        pid = request.POST.get('pid')
        num = request.POST.get('num', 1)
        payment_terms = request.POST.get('payment_terms')
        is_insurance = request.POST.get('is_insurance')
        product_type = request.POST.get('product_type')

        order = OrderManage.create_order(
            user=user,
            pid=pid,
            num=num,
            product_type=product_type,
            payment_terms=payment_terms,
            is_insurance=is_insurance
        )
        if (int(num) < 1):
            return JsonResponse({
                'status': 'error',
                'msg': '商品数量不能小于1',
            })

        if not order:
            return JsonResponse({
                'status': 'error',
                'msg': '支付失败,请勿重新购买!',
            })

        pay_url = ''
        if payment_terms == 'alipay':

            alipay_return_url = request.build_absolute_uri(
                reverse('order-alipay-return')
            )
            alipay_notify_url = request.build_absolute_uri(
                reverse('order-alipay-notify')
            )

            pay_url = AlipayUtils.submit_order_url(
                order,
                return_url=alipay_return_url,
                notify_url=alipay_notify_url,
                order_price=order.order_price,
                extra_common_param=product_type
            )

        if payment_terms == 'coin':
            pay_url = reverse('vip-coin-paid-order')

        return JsonResponse({
            'status': 'ok',
            'msg': '订单生成成功',
            'pay_url': pay_url,
            'order_id': order.order_id,
            'payment_terms': order.payment_terms,
            'order_price': order.order_price
        })
Пример #4
0
    def get_pay_url(self, order):
        request = self.request
        product_type = 'renew_service'
        alipay_return_url = request.build_absolute_uri(
            reverse('order-alipay-return'))
        alipay_notify_url = request.build_absolute_uri(
            reverse('order-alipay-notify'))

        pay_url = AlipayUtils.submit_order_url(order,
                                               return_url=alipay_return_url,
                                               notify_url=alipay_notify_url,
                                               order_price=order.order_price,
                                               extra_common_param=product_type)
        return pay_url
Пример #5
0
    def post(self, request):
        user = request.user
        order_id = request.POST.get('order_id')

        order = OrderManage.get_order_info(
            order_id=order_id,
            user=user,
        )
        payment_terms = order.payment_terms

        if order.order_status != 'unpay':
            return JsonResponse({
                'status': 'error',
                'msg': '申请重新支付失败',
            })

        pay_url = ''

        if payment_terms == 'alipay':

            alipay_return_url = request.build_absolute_uri(
                reverse('order-alipay-return')
            )
            alipay_notify_url = request.build_absolute_uri(
                reverse('order-alipay-notify')
            )

            pay_url = AlipayUtils.submit_order_url(
                order,
                return_url=alipay_return_url,
                notify_url=alipay_notify_url,
                order_price=order.order_price,
                extra_common_param=order.item.get_product_type
            )

        if payment_terms == 'coin':
            pay_url = reverse('vip-coin-paid-order')

        return JsonResponse({
            'status': 'ok',
            'msg': '申请重新支付订单成功',
            'pay_url': pay_url,
            'order_id': order.order_id,
            'payment_terms': order.payment_terms
        })
Пример #6
0
    def get_pay_url(self, order):
        request = self.request
        product_type = 'renew_service'
        alipay_return_url = request.build_absolute_uri(
            reverse('order-alipay-return')
        )
        alipay_notify_url = request.build_absolute_uri(
            reverse('order-alipay-notify')
        )

        pay_url = AlipayUtils.submit_order_url(
            order,
            return_url=alipay_return_url,
            notify_url=alipay_notify_url,
            order_price=order.order_price,
            extra_common_param=product_type
        )
        return pay_url