예제 #1
0
 def save(self, value, line):
     tenant = self.tenants[value]
     payment = Payment(tenant=tenant,
                       date=line.date,
                       amount=line.amount,
                       description=line.caption)
     payment.save()
예제 #2
0
파일: views.py 프로젝트: oadam/proprio
 def save(self, value, line):
     tenant = self.tenants[value]
     payment = Payment(
         tenant=tenant,
         date=line.date,
         amount=line.amount,
         description=line.caption)
     payment.save()
예제 #3
0
def test_post_model(app, client):
    payment = Payment(amount=150,
                      currency='840',
                      description='test',
                      shop_id=5,
                      shop_order_id='123456')
    db.session.add(payment)
    db.session.commit()
    assert payment.id > 0
    assert payment.__repr__() == '123456'
예제 #4
0
def payment(request):
    product_total = Cart.objects.filter(user=request.user).aggregate(Sum('total'))
    if request.method == "POST":
        p = Payment(
            user=request.user,
            acnumber=request.POST.get('acnumber'),
            expirem=request.POST.get('expirem'),
            expirey=request.POST.get('expirey'),
            ccv=request.POST.get('ccv'),
        )
        messages.success(request, "Payment Confirmed ")
        if Payment.objects.filter(user=request.user).exists():
            return redirect('add_order')
        p.save()
        return redirect('add_order')
    context = {"product_total": product_total['total__sum']}
    return render(request, 'payment.html', context)
def pay_cart(user):
    temp = ShoppingItem.objects.all()\
        .filter(state='activo', user=user.id)
    price = update_number_of_items(temp)
    payment = Payment()
    payment.price = price
    payment.user = user
    payment.date = datetime.datetime.now()
    payment.save()
    return payment
예제 #6
0
 def handle_noargs(self, **options):
     for i in xrange(2400):
         Payment(amount=any_amount(), datetime=any_datetime()).save()
         self.stdout.write('.')
         self.stdout.flush()
     self.stdout.write('\n')
예제 #7
0
def srpoints(request, site):
    """
    On the postback, we send the following query arguments:
    new - user earned by filling out offer 'oid'
    total - total amount of accumulated by this user
    uid - the site's user uid (facebook, myspace, etc)
    oid - SuperRewards offer identifier
    You must reply:
    1 - if you updated your system successfully
    0 - if there is a problem on your end (we'll wait and resend the postback again)
    The reply should be just 1 digit (no xml, no tags, just 1 byte reply)
    Example:
    http://www.domain.com/postback.cgi?app=mygreatapp&new=25&total=1000&uid=1234567&oid=123
    Important
    1. 'oid' + 'uid' is not a unique cominbation. There are offers that users can fill out several times and get credited for them.
    2. Please always rely on total value in your calculations.
    """
    import hashlib

    h = hashlib.md5()
    h.update(request.GET['id'] + ':' + request.GET['new'] + ':' + request.GET['uid'] + ':' + settings.SRPOINTS_SECRET[
        str(site)])
    valid = h.hexdigest()

    from userprofile.models import UserProfile
    from django.core.mail import send_mail

    pay = Payment()
    pay.user_id = request.GET['uid']
    pay.site = site
    pay.provider = 'srpoints'
    pay.details = str(request.GET)
    pay.credits = request.GET['new']
    pay.total_credits = request.GET['total']

    if valid != request.GET['sig']:
        pay.status = 'invalid_transaction'
        pay.save()
        send_mail("Payment failure: invalid_transaction by %s" % request.GET['uid'], '', 'Car Battle <*****@*****.**>',
                  ("*****@*****.**",), fail_silently=True)
        return HttpResponse(0)

    if site == 'fb':
        profile = UserProfile.objects.get_by_fb_id(request.GET['uid'])
    else:
        profile = UserProfile.objects.get_by_id(request.GET['uid'])
    if profile is None:
        pay.status = 'user_not_found'
        pay.save()
        send_mail("Payment failure: user_not_found: %s" % request.GET['uid'], '', 'Car Battle <*****@*****.**>',
                  ("*****@*****.**",), fail_silently=True)
        return HttpResponse(0)

    profile.earn('credit', request.GET['new'])
    pay.status = 'ok'
    pay.save()

    if profile.partner != '':
        try:
            partner = Partner.objects.get(name=profile.partner)
            if partner.pay_share > 0:
                pp = PartnerPayment()
                pp.partner = partner
                pp.payment = pay
                pp.amount = (Decimal(num) / Decimal(10)) * Decimal(str(partner.pay_share))
                pp.share = Decimal(str(partner.pay_share))

                # nie plac, jezeli konto nieaktywne
                if not partner.is_active:
                    pp.is_payable = False
                pp.save()
        except Partner.DoesNotExist:
            logging.error("Received payment with unknown partner=%s" % profile.partner)
        except:
            logging.error("Partner share calculation error with payment_id=%s" % pay.id)

    logging.warning("Dodano %s kredytów" % str(pay.credits))
    if int(pay.credits) > 3:
        send_mail("Payment success at %s by %s" % (pay.site, str(pay.user_id)),
                  "%s credits added. %s do far payed by him" % (str(pay.credits), str(pay.total_credits)),
                  'Car Battle <*****@*****.**>', ("*****@*****.**",), fail_silently=True)
    return HttpResponse(1)
예제 #8
0
def furtumo(request):
    """http://fortumo.com/main/about_premium
    81.20.151.38
    81.20.148.122
    """
    from main.models import Payment, PaymentCode
    from django.core.mail import send_mail

    pay = Payment()
    pay.user_id = 0
    pay.site = 'sms'
    pay.provider = 'furtumo'
    pay.details = str(request.GET)
    pay.credits = 0
    pay.total_credits = 0
    pay.status = 'ok'
    pay.save()

    send_mail("SMS Payment success by %s" % (pay.provider), "%s PLN" % str(request.GET['price']),
              'Car Battle <*****@*****.**>', ("*****@*****.**",), fail_silently=True)

    code = PaymentCode.codes.gen_new_code(value=request.GET['price'])
    return HttpResponse('Car Battle: %s' % code)
예제 #9
0
def webtopay(request):
    """https://www.webtopay.com/specification_sms.html"""
    from main.models import Payment, PaymentCode
    from django.core.mail import send_mail

    pay = Payment()
    pay.user_id = 0
    pay.site = 'sms'
    pay.provider = 'webtopay'
    pay.details = str(request.GET)
    pay.credits = 0
    pay.total_credits = 0
    pay.status = 'ok'
    pay.save()

    if profile.partner != '':
        try:
            partner = Partner.objects.get(name=profile.partner)
            if partner.pay_share > 0:
                pp = PartnerPayment()
                pp.partner = partner
                pp.payment = pay
                pp.amount = (Decimal(num) / Decimal(10)) * Decimal(str(partner.pay_share))
                pp.share = Decimal(str(partner.pay_share))

                # nie plac, jezeli konto nieaktywne
                if not partner.is_active:
                    pp.is_payable = False
                pp.save()
        except Partner.DoesNotExist:
            logging.error("Received payment with unknown partner=%s" % profile.partner)
        except:
            logging.error("Partner share calculation error with payment_id=%s" % pay.id)

    send_mail("SMS Payment success by %s" % (pay.provider), "%s PLN" % str(request.GET['amount']),
              'Car Battle <*****@*****.**>', ("*****@*****.**",), fail_silently=True)

    code = PaymentCode.codes.gen_new_code(value=request.GET['amount'])
    return HttpResponse('Car Battle: %s' % code)
예제 #10
0
def offerpal(request, site):
    """The callback server URL is how our servers ping your servers on offer completions.

    Notes: The callback URL format you will receive from our servers is as shown below:

    http://www.yourserver.com/anypath/reward.php?snuid=[Facebook	 user ID]&currency=[currency credit to user]
    snuid is the users id value of the Facebook	 user ID
    currency is the positive whole number
    Security: For security you can optionally white list Offerpal Media server IPs:

    74.205.58.114
    99.132.162.242
    99.132.162.243
    99.132.162.244
    99.132.162.245
    """

    from main.models import Payment
    from userprofile.models import UserProfile
    from django.core.mail import send_mail

    pay = Payment()
    pay.user_id = request.GET['snuid']
    pay.site = site
    pay.provider = 'offerpal'
    pay.details = str(request.GET)
    pay.credits = request.GET['currency']
    pay.total_credits = 0

    if site == 'fb':
        profile = UserProfile.objects.get_by_fb_id(request.GET['snuid'])
    else:
        profile = UserProfile.objects.get_by_id(request.GET['snuid'])
    if profile is None:
        pay.status = 'user_not_found'
        pay.save()
        send_mail("Payment failure: user_not_found: %s" % request.GET['snuid'], '', 'Car Battle <*****@*****.**>',
                  ("*****@*****.**",), fail_silently=True)
        return HttpResponse(0)

    profile.earn('credit', request.GET['currency'])
    pay.status = 'ok'
    pay.save()

    if profile.partner != '':
        try:
            partner = Partner.objects.get(name=profile.partner)
            if partner.pay_share > 0:
                pp = PartnerPayment()
                pp.partner = partner
                pp.payment = pay
                pp.amount = (Decimal(num) / Decimal(10)) * Decimal(str(partner.pay_share))
                pp.share = Decimal(str(partner.pay_share))

                # nie plac, jezeli konto nieaktywne
                if not partner.is_active:
                    pp.is_payable = False
                pp.save()
        except Partner.DoesNotExist:
            logging.error("Received payment with unknown partner=%s" % profile.partner)
        except:
            logging.error("Partner share calculation error with payment_id=%s" % pay.id)

    logging.warning("Dodano %s kredytów" % str(pay.credits))
    if int(pay.credits) > 3:
        send_mail("Payment success at %s by %s" % (pay.site, str(pay.user_id)),
                  "%s credits added. %s do far payed by him" % (str(pay.credits), str(pay.total_credits)),
                  'Car Battle <*****@*****.**>', ("*****@*****.**",), fail_silently=True)
    return HttpResponse(1)