Esempio n. 1
0
 def get(self, request, *args, **kwargs):
     if request.user.is_authenticated:
         customer = Customer.objects.get(user=request.user)
     else:
         session_key=request.session.session_key
         name=str(session_key)
         user= User.objects.filter(username=name).first()
         customer = Customer.objects.filter(user=user).first()
     orders = Order.objects.filter(customer=customer).order_by('-id')[:1].first()
     # /
     if orders:
         liqpay = LiqPay(settings.LIQPAY_PUBLIC_KEY, settings.LIQPAY_PRIVATE_KEY)
         params = {
             'action': 'pay',
             'amount': int(orders.cart.final_price) ,
             'currency': 'UAH',
             'description': 'Payment for clothes',
             'version': '3',
             'order_id':  orders.id ,
             'sandbox': 0, # sandbox mode, set to 1 to enable it
             'result_url':'https://mysite123456.herokuapp.com/',
             'server_url': 'https://mysite123456.herokuapp.com/pay-callback/', # url to callback view
         }
         signature = liqpay.cnb_signature(params)
         data = liqpay.cnb_data(params)
         return render(request, self.template_name, {'signature': signature, 'data': data})
     else:
         return HttpResponseRedirect('/')
Esempio n. 2
0
def get(self, request, *args, **kwargs):
    liqpay = LiqPay(settings.sandbox_i26660223217, settings.sandbox_u3BM9ppkXfPn0Phd5ZNhpkzieRiVWHmq12iJUJYb)
    params = {
        'action': 'pay',
        'amount': '100',
        'currency': 'USD',
        'description': 'Payment for medicines',
        'order_id': 'order_id_1',
        'version': '3',
        'sandbox': 1, # sandbox mode, set to 1 to enable it
        'server_url': 'https://test.com/billing/pay-callback/', # url to callback view
    }
    signature = liqpay.cnb_signature(params)
    data = liqpay.cnb_data(params)
    return render(request, self.template_name, {'signature': signature, 'data': data})
Esempio n. 3
0
 def get(self, request, *args, **kwargs):
     liqpay = LiqPay(LIQPAY_PUBLIC_KEY, LIQPAY_PRIVATE_KEY)
     amount = Replanishment.objects.get(id=request.session['payment_id']).ammount
     print request.user
     params = {
         'action': 'pay',
         'amount': amount,
         'currency': 'UAH',
         'description': 'Пополнение аккаунта',
         'order_id': request.session['payment_id'],
         'version': '3',
         'sandbox': '1',
         'server_url': 'https://%s/pay-callback/' % DOMAIN_NAME,
     }
     signature = liqpay.cnb_signature(params)
     data = liqpay.cnb_data(params)
     return render(request, self.template_name, {'signature': signature, 'data': data})
Esempio n. 4
0
class CheckoutForm(CallbackForm):
    method = 'POST'

    def __init__(self, params, *args, **kwargs):
        self.params = {} if params is None else deepcopy(params)
        self.liqpay = LiqPay(settings.LIQPAY_PUBLIC_KEY,
                             settings.LIQPAY_PRIVATE_KEY)
        self.action_url = urljoin(self.liqpay._host, constants.CHECKOUT_URL)
        self.params.update(
            version=constants.API_VERSION,
            sandbox=str(
                int(bool(params.get('sandbox', settings.LIQPAY_SANDBOX)))),
        )
        initial = {
            'data': self.liqpay.cnb_data(self.params),
            'signature': self.liqpay.cnb_signature(self.params),
        }
        super().__init__(initial=initial, *args, **kwargs)
Esempio n. 5
0
 def get(self, request, *args, **kwargs):
     task = Task.objects.get(pk=kwargs['pk'])
     liqpay = LiqPay(settings.LIQPAY_PUBLIC_KEY, settings.LIQPAY_PRIVATE_KEY)
     params = {
         'action': 'p2p',
         'amount': str(task.estimated_price),
         'order_id': str(task.pk),
         'currency': 'UAH',
         'description': 'Оплата за завдання #{}'.format(task.pk),
         'version': '3',
         'sandbox': settings.LIQPAY_SANDBOX_MODE,
         'receiver_card': task.executor.worker_profile.card_number,
         'server_url': settings.LIQPAY_SERVER_URL,
     }
     signature = liqpay.cnb_signature(params)
     data = liqpay.cnb_data(params)
     return render(request, self.template_name, {'signature': signature,
                                                 'data': data,
                                                 'task': task})
Esempio n. 6
0
    def get(self, request, bill: int):
        bill_pk = self.kwargs['bill']
        # get the apartment
        try:
            bill = Bill.objects.get(pk=bill_pk)
        # return error HTTP_400_BAD_REQUEST if apartment does not exist
        except Bill.DoesNotExist:
            return Response(_('Bill with such id does not exist'),
                            status=status.HTTP_400_BAD_REQUEST)

        # prepearing Liqpay data
        liqpay = LiqPay(settings.LIQPAY_PUBLIC_KEY,
                        settings.LIQPAY_PRIVATE_KEY)
        params = {
            'action':
            settings.LIQPAY_DEFAULT_ACTION,
            'currency':
            settings.LIQPAY_DEFAULT_CURRENCY,
            'language':
            settings.LIQPAY_DEFAULT_LANGUAGE,
            'amount':
            str(bill.total_value),
            'description':
            f'Payment for bill {bill.number}',
            'order_id':
            bill_pk,
            'version':
            '3',
            'sandbox':
            1,  # sandbox mode, set to 1 to enable it
            'server_url':
            'https://dimonline.pp.ua:8443/payments/api/v1/pay_callback/',  # url to callback view
        }
        signature = liqpay.cnb_signature(params)
        data = liqpay.cnb_data(params)

        return Response({
            'signature': signature,
            'data': data
        },
                        status=status.HTTP_200_OK)
Esempio n. 7
0
 def get(self, request, *args, **kwargs):
     liqpay = LiqPay(settings.LIQPAY_PUBLIC_KEY,
                     settings.LIQPAY_PRIVATE_KEY)
     params = {
         'action': 'pay',
         'amount': self.kwargs['price'],
         # 'amount': '0.01',
         'currency': 'UAH',
         'description':
         'Оплата обуви, отправка с магазина Kicks Industry, г. Ужгород, ул. Льва Толстого, 5',
         'order_id': 'order_id_1',
         'version': '3',
         'sandbox': 0,  # sandbox mode, set to 1 to enable it
         'server_url':
         'https://test.com/billing/pay-callback/',  # url to callback view
     }
     signature = liqpay.cnb_signature(params)
     data = liqpay.cnb_data(params)
     return render(request, self.template_name, {
         'signature': signature,
         'data': data
     })