Beispiel #1
0
    def get_transaction_parameters(self,
                                   basket,
                                   request=None,
                                   use_client_side_checkout=False,
                                   **kwargs):
        """
        approval_url
        """
        trade_id = create_trade_id(basket.id)
        body = "BUY {amount} {currency}".format(amount=basket.total_incl_tax,
                                                currency=basket.currency)
        subject = "BUY COURSE"
        total_fee = str_to_specify_digits(str(basket.total_incl_tax))
        http_host = request.META.get('HTTP_HOST')
        extra_common_param = urljoin(get_ecommerce_url(),
                                     reverse('alipay:execute'))

        approval_url = create_direct_pay_by_user(
            trade_id,
            body,
            subject,
            total_fee,
            http_host,
            extra_common_param=extra_common_param)
        if not PaymentProcessorResponse.objects.filter(
                processor_name=self.NAME,
                basket=basket).update(transaction_id=trade_id):
            self.record_processor_response({},
                                           transaction_id=trade_id,
                                           basket=basket)

        parameters = {
            'payment_page_url': approval_url,
        }
        return parameters
Beispiel #2
0
class AliPay(BasePaymentProcessor):

    NAME = 'alipay'
    DEFAULT_PROFILE_NAME = 'default'

    def __init__(self, site):
        super(AliPay, self).__init__(site)

    @property
    def cancel_url(self):
        return get_ecommerce_url(self.configuration['cancel_checkout_path'])

    @property
    def error_url(self):
        return get_ecommerce_url(self.configuration['error_path'])

    def get_transaction_parameters(self,
                                   basket,
                                   request=None,
                                   use_client_side_checkout=False,
                                   **kwargs):
        """
        approval_url
        """
        trade_id = create_trade_id(basket.id)
        try:
            course_data = get_course_info_from_catalog(
                request.site,
                basket.all_lines()[0].product)
            subject = body = course_data.get('title')
        except Exception, e:
            logger.exception(e)
            subject = body = 'buy course'
        total_fee = str_to_specify_digits(str(basket.total_incl_tax))
        http_host = request.META.get('HTTP_HOST')
        extra_common_param = urljoin(get_ecommerce_url(),
                                     reverse('alipay:execute'))

        approval_url = create_direct_pay_by_user(
            trade_id,
            body,
            subject,
            total_fee,
            http_host,
            extra_common_param=extra_common_param)
        if not PaymentProcessorResponse.objects.filter(
                processor_name=self.NAME,
                basket=basket).update(transaction_id=trade_id):
            self.record_processor_response({},
                                           transaction_id=trade_id,
                                           basket=basket)

        parameters = {
            'payment_page_url': approval_url,
        }
        return parameters
Beispiel #3
0
 def get_pay_html(self, body, subject, total_fee, http_host, order_id):
     """
     get alipay html
     # 支付信息,订单号必须唯一
     """
     extra_common_param = settings.LMS_ROOT_URL + reverse("vip_purchase")
     total_fee = str_to_specify_digits(str(total_fee))
     trade_id = create_trade_id(order_id)
     pay_html = create_direct_pay_by_user(
         trade_id,
         body,
         subject,
         total_fee,
         http_host,
         extra_common_param=extra_common_param)
     return pay_html