Ejemplo n.º 1
0
    def test_doDirectPayment_valid_with_signal(self):
        data = {
            'firstname': 'Brave',
            'lastname': 'Star',
            'street': '1 Main St',
            'city': u'San Jos\xe9',
            'state': 'CA',
            'countrycode': 'US',
            'zip': '95131',
            'expdate': '012019',
            'cvv2': '037',
            'acct': '4797503429879309',
            'creditcardtype': 'visa',
            'ipaddress': '10.0.1.199', }
        data.update(self.item)

        self.got_signal = False
        self.signal_obj = None

        def handle_signal(sender, **kwargs):
            self.got_signal = True
            self.signal_obj = sender

        payment_was_successful.connect(handle_signal)
        self.assertTrue(self.wpp.doDirectPayment(data))
        self.assertTrue(self.got_signal)
Ejemplo n.º 2
0
    def test_doDirectPayment_valid_with_signal(self):
        data = {
            'firstname': 'Brave',
            'lastname': 'Star',
            'street': '1 Main St',
            'city': u'San Jos\xe9',
            'state': 'CA',
            'countrycode': 'US',
            'zip': '95131',
            'acct': '4032039938039650',
            'expdate': '112021',
            'cvv2': '',
            'creditcardtype': 'visa',
            'ipaddress': '10.0.1.199',
        }
        data.update(self.item)

        self.got_signal = False
        self.signal_obj = None

        def handle_signal(sender, **kwargs):
            self.got_signal = True
            self.signal_obj = sender

        payment_was_successful.connect(handle_signal)
        self.assertTrue(self.wpp.doDirectPayment(data))
        self.assertTrue(self.got_signal)
Ejemplo n.º 3
0
    def test_doDirectPayment_valid_with_signal(self):
        wpp = PayPalWPP(make_request())
        data = self.get_valid_doDirectPayment_data()
        data.update(self.item)

        self.got_signal = False
        self.signal_obj = None

        def handle_signal(sender, **kwargs):
            self.got_signal = True
            self.signal_obj = sender

        payment_was_successful.connect(handle_signal)
        self.assertTrue(wpp.doDirectPayment(data))
        self.assertTrue(self.got_signal)
import config
from paypal.pro.signals import payment_was_successful
from paymentspro.listeners import payment_authorized

PAYMENT_PROCESSOR = True

payment_was_successful.connect(payment_authorized)
Ejemplo n.º 5
0
        # TODO: IMPORTANT!
        # Add code to send emails to admins and log the transaction in case of failure
        
        import traceback
        error = traceback.format_exc()
        subject = "ERROR - Failed to completed payment procedure"
        send_error_report(subject, error)
        
    # if ipn_obj.custom == "Upgrade all users!":
    #     print dir(ipn_obj)
    # print dir(ipn_obj)
    # print __file__,1, 'This works'   
         
payment_was_successful.connect(paypal_payment_completed)

"""
def paypal_payment_completed_pro(sender, **kwargs):
    item = sender
    # Undertake some action depending upon `ipn_obj`.
    treatment_id = int(item['custom'])
    
    print item
    
    try:
        treatment = Treatment.objects.get(id = treatment_id)
        treatment.paid = True
        treatment.save()
        
        treatment_status = TreatmentStatus(status="IQ", treatment=treatment)
        treatment_status.save()
    except:
Ejemplo n.º 6
0
from django.utils import unittest
from cratis.app.ecommerce.profile.models import UserProfile

from paypal.pro.signals import payment_was_successful

__author__ = 'alex'

def show_me_the_money(sender, **kwargs):
    item = sender
    order_id = item['inv']

    order = Order.objects.get(pk=order_id)
    order.status = Order.ORDER_STATUS_PAID
    order.save()

payment_was_successful.connect(show_me_the_money)

class Address(models.Model):
    street_address = models.CharField(max_length=250, null=False, default="", blank=False)
    city = models.CharField(max_length=250, null=False, default="", blank=False)
    post_index = models.CharField(max_length=250, null=False, default="", blank=False)
    country = models.CharField(max_length=250, null=False, default="", blank=False)
    recipient = models.CharField(max_length=250, null=False, default="", blank=True)
    firstname = models.CharField(max_length=250, null=False, default="", blank=False)
    lastname = models.CharField(max_length=250, null=False, default="", blank=False)
    email = models.CharField(max_length=250, null=False, default="", blank=False, validators=[validate_email])
    phone = models.CharField(max_length=250, null=False, default="", blank=False)

    temporary = models.BooleanField(default=False, blank=True)

    is_main = models.BooleanField(default=False, blank=True, verbose_name=_('Default address'))
Ejemplo n.º 7
0
    # Generate Order
    order = Order(user_id=ppnvp.user_id,course_id=ipn_obj['course_id'],created_at=datetime.now(),amount=ipn_obj['amt'],is_refund = False, paypal_txn_id = ipn_obj['token'])
    order.save()
    #Enrroll in the course
    enrollment = Enrollment(user_id=ppnvp.user_id,course_id=ipn_obj['course_id'], start_date = datetime.now())
    enrollment.save()

    #Send Email to Teacher
    course = Course.objects.get(pk=ipn_obj['course_id'])
    teacher = User.objects.get(pk = course.user_id)
    student = User.objects.get(pk = ppnvp.user_id)

    ctx_dict = {'course': course,'teacher': teacher, 'student': student}

    message = render_to_string('shop/buy_email.html',ctx_dict)
    subject = _('Someone has purchased your course: ')+course.title
    msg = EmailMessage(subject, message, settings.DEFAULT_FROM_EMAIL, [teacher.email])
    msg.content_subtype = "html"  # Main content is now text/html
    msg.send()

    #Send Email to the New Student
    message = render_to_string('shop/enrroled_email.html',ctx_dict)
    subject = _('You has been enrrolled in ')+course.title
    msg = EmailMessage(subject, message, settings.DEFAULT_FROM_EMAIL, [student.email])
    msg.content_subtype = "html"  # Main content is now text/html
    msg.send()


payment_was_successful.connect(course_has_been_purchased ,dispatch_uid="someone-purchased-course-paypal")
Ejemplo n.º 8
0
from models import Product
from customer.models import Invoice
    
import cart as shcart
    
logger = logging.getLogger('product.views')

@transaction.commit_on_success
def paypal_success_callback(sender, **kwargs):
    logger.debug('paypal_success_callback: sender=%s, kwargs=%s' % (sender, kwargs))
    invnum = sender['invnum']    
    invoice = Invoice.objects.get(pk=invnum)
    invoice.status = Invoice.Const.PAID
    invoice.save()
    register_purchase(invoice.id, invoice.customer, invoice.total, invoice.total_credit)
payment_was_successful.connect(paypal_success_callback)
        
@transaction.commit_on_success
def paypal_failure_callback(sender, **kwargs):
    logger.debug('paypal_failure_callback: sender=%s, kwargs=%s' % (sender, kwargs))
    invnum = sender['invnum']    
    invoice = Invoice.objects.get(pk=invnum)
    invoice.status = Invoice.Const.CANCELLED
    invoice.save()
payment_was_flagged.connect(paypal_failure_callback)


def product_detail(request, prodid):
    user = request.user
    if user is None or not user.is_authenticated():
        return HttpResponseRedirect('/') ## FIXME