Пример #1
0
    def process_payment(self, bundle):
        verify_call = call_authorizedotnet(
            bundle.data.get('amount'), 
            bundle.data.get('card_number'), 
            '%s-%s' % (bundle.data.get('exp_date_0'), bundle.data.get('exp_date_1')),
            bundle.data.get('cvv'),
            '',
            '',
            '',
            '', 
            '',
            bundle.data.get('first_name'),
            bundle.data.get('last_name'),
            '',
            bundle.data.get('email'),
            'Donation', 
        )

        if verify_call.split('|')[0] == '1':
            bundle.data['authorize_transaction_id'] = verify_call.split('|')[6]
            bundle.data['authorize_transaction_raw_response'] = verify_call
        else:   
            bundle.errors[self._meta.resource_name] = verify_call.split('|')[3]
        return bundle
Пример #2
0
def job_payment(request):
    context = RequestContext(request)
    user = request.user
    notice = ''
    try:
        job = Job.objects.filter(user=user).latest('created')
    except:
        HttpResponseRedirect("/announce/")
            
    breadcrumb = (("Announce","/announce"),("Job Posting",""))
    job_amount = 25.00

    job_payment_form = JobPaymentForm(initial= {"first_name":user.first_name, 
                                                "last_name":user.last_name, 
                                                "amount":job_amount})
    
    billing_address_form = UserBillingAddressForm(initial= {"user":user,
                                                            "address_type":'billing'},
                                                            prefix="billing")
        
    if request.method == 'POST':
        job_payment_form = JobPaymentForm(request.POST,initial= {"amount":job_amount})
        billing_address_form = UserBillingAddressForm(request.POST, prefix="billing")

        if job_payment_form.is_valid() and billing_address_form.is_valid():
            payment = job_payment_form.save(user, job, commit=False)
            billing_address = billing_address_form.save(user)            

            verify_call = call_authorizedotnet(
                            "%s" % unicode(job_payment_form.cleaned_data["amount"]), 
                            job_payment_form.cleaned_data["cc_number"], 
                            job_payment_form.cleaned_data["cc_exp_date"], 
                            job_payment_form.cleaned_data["cc_card_code"], 
                            "%s %s" %(billing_address.street1, billing_address.street2),
                            billing_address.city,
                            billing_address.state,
                            billing_address.zip_postal_code, 
                            billing_address.country,
                            user.first_name, 
                            user.last_name, 
                            user.id, 
                            user.email, 
                            "Job Payment", 
                            )
                        
            ##VERIFICATION WORKED, NOW CAPTURE THE TRANSACTION
            if verify_call.split('|')[0] == '1':
                job.status = True
                job.save()
                payment.save()
                payment.send_receipt()
                return HttpResponseRedirect(reverse(job_payment_thanks, kwargs={'job_id':job.id}))
           
            #VERIFICATION DIDN'T WORK
            else:   
               notice = verify_call.split('|')[3]
                    
        #ONE OF THE FORMS DIDN'T VALIDATE (DJANGO VALIDATION) 
        else:
            notice = "There were problems with the information you submitted."
    
    return render_to_response("announce/job_payment.html", {
                              "job":job,
                              "job_payment_form":job_payment_form,
                              "breadcrumb":breadcrumb,
                              "notice":notice,
                              "job_amount":job_amount,
                              "paypal_email":settings.PAYPAL_RECEIVER_EMAIL,
                              "paypal_url":settings.PAYPAL_POSTBACK_URL,
                              "billing_address_form":billing_address_form
                              }, 
                            context) 
Пример #3
0
def job_payment(request):
    context = RequestContext(request)
    user = request.user
    notice = ''
    try:
        job = Job.objects.filter(user=user).latest('created')
    except:
        HttpResponseRedirect("/announce/")

    breadcrumb = (("Announce", "/announce"), ("Job Posting", ""))
    job_amount = 25.00

    job_payment_form = JobPaymentForm(
        initial={
            "first_name": user.first_name,
            "last_name": user.last_name,
            "amount": job_amount
        })

    billing_address_form = UserBillingAddressForm(initial={
        "user": user,
        "address_type": 'billing'
    },
                                                  prefix="billing")

    if request.method == 'POST':
        job_payment_form = JobPaymentForm(request.POST,
                                          initial={"amount": job_amount})
        billing_address_form = UserBillingAddressForm(request.POST,
                                                      prefix="billing")

        if job_payment_form.is_valid() and billing_address_form.is_valid():
            payment = job_payment_form.save(user, job, commit=False)
            billing_address = billing_address_form.save(user)

            verify_call = call_authorizedotnet(
                "%s" % unicode(job_payment_form.cleaned_data["amount"]),
                job_payment_form.cleaned_data["cc_number"],
                job_payment_form.cleaned_data["cc_exp_date"],
                job_payment_form.cleaned_data["cc_card_code"],
                "%s %s" % (billing_address.street1, billing_address.street2),
                billing_address.city,
                billing_address.state,
                billing_address.zip_postal_code,
                billing_address.country,
                user.first_name,
                user.last_name,
                user.id,
                user.email,
                "Job Payment",
            )

            ##VERIFICATION WORKED, NOW CAPTURE THE TRANSACTION
            if verify_call.split('|')[0] == '1':
                job.status = True
                job.save()
                payment.save()
                payment.send_receipt()
                return HttpResponseRedirect(
                    reverse(job_payment_thanks, kwargs={'job_id': job.id}))

            #VERIFICATION DIDN'T WORK
            else:
                notice = verify_call.split('|')[3]

        #ONE OF THE FORMS DIDN'T VALIDATE (DJANGO VALIDATION)
        else:
            notice = "There were problems with the information you submitted."

    return render_to_response(
        "announce/job_payment.html", {
            "job": job,
            "job_payment_form": job_payment_form,
            "breadcrumb": breadcrumb,
            "notice": notice,
            "job_amount": job_amount,
            "paypal_email": settings.PAYPAL_RECEIVER_EMAIL,
            "paypal_url": settings.PAYPAL_POSTBACK_URL,
            "billing_address_form": billing_address_form
        }, context)