Beispiel #1
0
    def get(self, request, *args, **kwargs):

        method = self.load_method(kwargs['method'])
        settings = method.behavior().config

        order = Order.objects.get(pk=request.session['order_id'])

        detalisation = order.get_detalisation()

    #    for row in detalisation['rows']:
    #        ulink_order.items.append(UlinkOrderItem(smart_str(row['title']), '', str(row['price'])))

        order_total = int(detalisation['full_total'] * 100)
        order_id = order.id


    #    key = """

    #"""
    #    oid = 'EB00310653'
        oid = settings['id']

        ecuno = str(order_id + 100000)
        ver = '004'
        eamount = str(order_total)
        cur = 'EUR'
        datetime = time.strftime("%Y%m%d%H%M%S")
        feedbackurl = 'http://' + request.META['HTTP_HOST'] + reverse('kardikeskus_payment_callback',
                                                                      kwargs={'method': method.slug})
        delivery = 'S'

        # padding
        feedbackurl = feedbackurl.ljust(128)
        ecuno = ecuno.zfill(12)
        eamount = eamount.zfill(12)

        data = ver + oid + ecuno + eamount + cur + datetime + feedbackurl + delivery

        signed = ssl_sign(data, load_pem_private_key(settings['pkey']))

        mac = signed.encode('hex')

        data = {
            'lang': 'et', # get_language(),
            'action': 'gaf',
            'ver': ver,
            'id': oid,
            'ecuno': ecuno,
            'eamount': eamount,
            'cur': 'EUR',
            'datetime': datetime,
            'charEncoding': 'UTF-8',
            'feedBackUrl': feedbackurl.strip(),
            'delivery': delivery,
            'mac': mac
        }

        log_payment(request, 'kardikeskus', 'pay_start', data)

        return render(request, 'payment/post_redirect.html', {'url': settings['url'], 'fields': data.items()})
Beispiel #2
0
    def get(self, request, *args, **kwargs):

        method = self.load_method(kwargs['method'])
        settings = method.behavior().config

        order = Order.objects.get(pk=request.session['order_id'])

        detalisation = order.get_detalisation()

        order_total = detalisation['full_total']
        order_id = order.id


        oid = settings['id']

        ecuno = str(order_id + 100000)
        eamount = str(order_total)
        feedbackurl = 'http://' + request.META['HTTP_HOST'] + reverse('pangalink_payment_callback',
                                                                      kwargs={'method': method.slug})
        cancelurl = 'http://' + request.META['HTTP_HOST'] + reverse('pangalink_payment_callback',
                                                                      kwargs={'method': method.slug})

        # padding
        feedbackurl = feedbackurl.ljust(128)
        ecuno = ecuno.zfill(12)
        eamount = eamount.zfill(12)

        data = {
            'VK_SERVICE': '1001',
            'VK_VERSION': '008',
            'VK_SND_ID': oid,
            'VK_STAMP': ecuno,
            'VK_AMOUNT': eamount,
            'VK_CURR': 'EUR',
            'VK_ACC': settings['account'],
            'VK_NAME': settings['owner'],
            'VK_REF': '',
            'VK_MSG': 'Order id ' + str(order_id),
            'VK_RETURN': feedbackurl,
            'VK_ENCODING': 'utf-8',
        }

        mac_data = ''
        for field in ['VK_SERVICE', 'VK_VERSION', 'VK_SND_ID',
                'VK_STAMP', 'VK_AMOUNT', 'VK_CURR',
                'VK_ACC', 'VK_NAME', 'VK_REF', 'VK_MSG']:
            v = data[field]
            vlen = len(v)
            mac_data += str(vlen).zfill(3) + v

        signed = ssl_sign(mac_data.encode('utf-8'), load_pem_private_key(settings['pkey']))

        data['VK_MAC'] = re.sub('\s+', '', signed.encode('base64'))

        log_payment(request, 'pangalink', 'pay_start', data)

        return render(request, 'payment/post_redirect.html', {'url': settings['url'], 'fields': data.items()})