Beispiel #1
0
 def refuse_money(self):
     base_url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
     url = self.acquirer_id.form_url
     valus = {
         '_input_charset': 'UTF-8',
         'notify_url': '%s' % urlparse.urljoin(base_url, '/payment/chanpay/refuse/'),
         'orig_outer_trade_no': self.acquirer_reference,
         'outer_trade_no': self.reference,
         'partner_id': self.acquirer_id.partner_id,
         'refund_amount': self.amount,
         'service': 'cjt_create_refund',
         'sign_type': 'RSA',
         'version': '1.0',
     }
     params, sign = func.buildRequestMysign(valus, self.acquirer_id.private_key)
     valus.update({
         'sign': sign,
     })
     _, prestr = func.params_filter_add(valus)
     geturl = url + prestr
     # raise osv.except_osv(u'警告', geturl)
     request = urllib2.Request(geturl)
     data = urllib2.urlopen(request).read()
     get_data = json.loads(data)
     if get_data:
         if 'error_message' in get_data:
             raise osv.except_osv(u'警告', get_data.get('error_message') + "====" + get_data.get('memo'))
         else:
             self.refund_status = '1'
Beispiel #2
0
    def alipay_form_generate_values(self, values):
        base_url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')

        alipay_tx_values = dict(values)
        alipay_tx_values.update({
            #basic parameters
            'service': self.alipay_service,
            'partner': self.alipay_partner,
            '_input_charset': 'utf-8',
            'sign_type': self.alipay_sign_type,
            'return_url': '%s' % urlparse.urljoin(base_url, AlipayController._return_url),
            'notify_url': '%s' % urlparse.urljoin(base_url, AlipayController._notify_url),
            #buiness parameters
            'out_trade_no': values['reference'],
            'subject': '%s: %s' % (self.company_id.name, values['reference']),
            'payment_type': '1',
            'total_fee': values['amount'],
            'seller_id': self.alipay_seller_id,
            'seller_email': self.alipay_seller_id,
            'seller_account_name': self.alipay_seller_id,
            'body':'',
        })
        subkey = ['service','partner','_input_charset','return_url','notify_url','out_trade_no','subject','payment_type','total_fee','seller_id','body']
        need_sign = {key:alipay_tx_values[key] for key in subkey}
        directory_path = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
        path = os.path.join(directory_path, 'private_key.pem')
        params,sign = func.buildRequestMysign(need_sign,open(path,'r').read())
        alipay_tx_values.update({
            'sign':sign,
            })
        return alipay_tx_values
Beispiel #3
0
    def chanpay_form_generate_values(self, values):
        print values
        base_url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
        _return_url = 'chanpay/_return_url'
        chanpay_tx_values = dict(values)
        order = self.env['sale.order'].sudo().search([('name', '=', values['reference'])])
        name = ""
        if order:
            for line in order.order_line:
                name += line.product_id.name + ";"
        else:
            name = "Pay Product"
        chanpay_tx_values = ({
            # basic parameters
            'is_anonymous': 'Y',
            '_input_charset': 'UTF-8',
            'is_returnpayurl': 'N',
            'notify_url': '%s' % urlparse.urljoin(base_url, '/payment/chanpay/ipn/'),
            'out_trade_no': values['reference'],
            'partner_id': self.partner_id,
            'product_name': name,
            'return_url': '%s' % urlparse.urljoin(base_url, '/shop/payment/validate'),
            'service': self.service,
            'sign_type': 'RSA',
            'trade_amount': float(values['amount']),
            'version': '1.0',
        })

        sign_values = {
            'is_anonymous': 'Y',
            '_input_charset': 'UTF-8',
            'is_returnpayurl': 'N',
            'notify_url': '%s' % urlparse.urljoin(base_url, '/payment/chanpay/ipn/'),
            'out_trade_no': values['reference'],
            'partner_id': self.partner_id,
            'product_name': name,
            'return_url': '%s' % urlparse.urljoin(base_url, '/shop/payment/validate'),
            'service': self.service,
            'trade_amount': float(values['amount']),
            'version': '1.0',
        }
        params, sign = func.buildRequestMysign(sign_values, self.private_key)
        chanpay_tx_values.update({
            'sign': sign,
        })
        # url = self._get_chanpay_urls(self.environment)['form_url']
        #
        # _, prestr = func.params_filter_add(chanpay_tx_values)
        # geturl=url+prestr
        # request = urllib2.Request(geturl)
        # get_data = urllib2.urlopen(request).read()
        #
        # print get_data
        return chanpay_tx_values