예제 #1
0
 def __init__(self, shop):
     self.shop = shop
     # Hook the payment was successful listener on the appropriate signal sent
     # by django-paypal (success_signal)
     assert settings.PAYPAL_RECEIVER_EMAIL, "You need to define a PAYPAL_RECEIVER_EMAIL in settings with the money recipient's email addresss"
     assert settings.PAYPAL_CURRENCY_CODE, "You need to define a PAYPAL_CURRENCY_CODE in settings with the currency code"
     success_signal.connect(self.payment_was_successful, weak=False)
     flagged_signal.connect(self.payment_was_flagged, weak=False)
     subscription_cancel_signal.connect(self.subscription_cancelled, weak=False)
     subscription_eot_signal.connect(self.subscription_expired, weak=False)
     subscription_modify_signal.connect(self.subscription_modified, weak=False)
     subscription_signup_signal.connect(self.subscription_signup_success, weak=False)
     recurring_create_signal.connect(self.recurring_created, weak=False)
     recurring_payment_signal.connect(self.recurring_payment, weak=False)
     recurring_cancel_signal.connect(self.recurring_cancelled, weak=False)
예제 #2
0
def show_me_the_money(sender, **kwargs):
    ipn_obj = sender
    # Undertake some action depending upon `ipn_obj`.
    if ipn_obj.payment_status == ST_PP_COMPLETED:
        print('Payment is completed')
        user_infor = ast.literal_eval(ipn_obj.custom)
        if ipn_obj.receiver_email == settings.PAYPAL_RECEIVER_EMAIL:
            print('And Payment is valid')
            # generate and send an email with pdf certificate file to the user's email
            user_infor = ast.literal_eval(ipn_obj.custom)
            user_info = {
                "name": user_infor['name'],
                "hours": user_infor['hours'],
                "taggedArticles": user_infor['taggedArticles'],
                "email": user_infor['email'],
                "date": user_infor['date'],
            }
            html = render_to_string('users/certificate_template.html',
                                    {'user': user_info})
            response = HttpResponse(content_type='application/pdf')
            response['Content-Disposition'] = 'filename=certificate_{}'.format(
                user_info['name']) + '.pdf'
            pdf = weasyprint.HTML(
                string=html, base_url=settings.host +
                '/users/process/').write_pdf(stylesheets=[
                    weasyprint.CSS(string='body { font-family: serif}')
                ])
            to_emails = [str(user_infor['email'])]
            subject = "Certificate from Nami Montana"
            email = EmailMessage(subject,
                                 body=pdf,
                                 from_email=settings.EMAIL_HOST_USER,
                                 to=to_emails)
            email.attach("certificate_{}".format(user_infor['name']) + '.pdf',
                         pdf, "application/pdf")
            email.content_subtype = "pdf"  # Main content is now text/html
            email.encoding = 'us-ascii'
            email.send()
        else:
            payment_was_flagged.connect(do_not_show_me_the_money)
예제 #3
0
            digits.append(d)
        return digits
    
    def __unicode__(self):
        return "%s: %s" % (str(self.date), str(self.value))

def successful_payment(sender, **kwargs):
    ipn_obj = sender
    deal_pk = ipn_obj.custom
    deal = Deal.objects.get(pk=deal_pk)
    payer_email = ipn_obj.payer_email
    purchase = Purchase(deal=deal, first_name=ipn_obj.first_name,
                        last_name=ipn_obj.last_name,
                        email=payer_email,
                        purchase_complete=True)
    purchase.save()

def flagged_payment(sender, **kwargs):
    ipn_obj = sender
    deal_pk = ipn_obj.custom
    deal = Deal.objects.get(pk=deal_pk)
    payer_email = ipn_obj.payer_email
    purchase = Purchase(deal=deal, first_name=ipn_obj.first_name,
                        last_name=ipn_obj.last_name,
                        email=payer_email,
                        purchase_complete=False)
    purchase.save()
    
payment_was_successful.connect(successful_payment)
payment_was_flagged.connect(flagged_payment)
예제 #4
0
        }

    @property
    def service_url(self):
        if self.test_mode:
            return SANDBOX_POSTBACK_ENDPOINT
        return POSTBACK_ENDPOINT

    def get_urls(self):
        urlpatterns = patterns(
            '',
            (r'^', include('paypal.standard.ipn.urls')),
        )
        return urlpatterns


def unsuccessful_txn_handler(sender, **kwargs):
    transaction_was_unsuccessful.send(sender=sender.__class__,
                                      type="purchase",
                                      response=None)


def successful_txn_handler(sender, **kwargs):
    transaction_was_successful.send(sender=sender.__class__,
                                    type="purchase",
                                    response=None)


payment_was_flagged.connect(unsuccessful_txn_handler)
payment_was_successful.connect(successful_txn_handler)
예제 #5
0
    payment_date = ipn_obj.payment_date
    if created:
        profile.first_name = ipn_obj.first_name
        profile.last_name = ipn_obj.last_name
        start_date = datetime.date(payment_date.year, payment_date.month, payment_date.day)
        profile.member_since = start_date
    end_date = datetime.date(payment_date.year, (payment_date.month + 1) % 12, payment_date.day)
    if payment_date.month == 12:
        end_date = end_date.replace(year=payment_date.year + 1)
    profile.member_until = end_date
    profile.save()


payment_was_successful.connect(paypal_to_profile, dispatch_uid="paypal_to_profile_unique_string")


def email_admins(sender, **kwargs):
    send_mail(
        "[psone] flagged payment",
        "A payment was flagged, go investigate.  http://psone-manager.herokuapp.com/admin/",
        "*****@*****.**",
        [a[1] for a in settings.ADMINS],
        fail_silently=False,
    )


payment_was_flagged.connect(email_admins, dispatch_uid="email_admins_unique_string")


# class Membership(models.Model):
예제 #6
0
    user_profile.credits += payment.credits
    user_profile.save()

    payment.set_paid()
    payment.save()

    if payment.coupon:
        log.info("Coupon code %s has been used by user %s" %
                 (payment.coupon.code, payment.user))
        if payment.coupon.used:
            log.error("It was already used by someone else. Fraud warning!")
        coupon = payment.coupon
        coupon.set_used()
        coupon.save()

    log.info("User %s has paid at price %s" % (payment.user, payment.price))

    #if sub.price != pay.price:
    #log.error("Payment price is different than subscription price. Fraud warning!")

    #send_mail('Tariff changed', Template(open('./tariff.txt').read()).render(Context({'user':u})), settings.DEFAULT_FROM_EMAIL, [user.user.email], fail_silently=False)


def payment_flagged(sender, **kwargs):
    log.warning("Paypal flagged transaction %s, please investigate!" %
                sender.invoice)


payment_was_successful.connect(payment_ok)
payment_was_flagged.connect(payment_flagged)
예제 #7
0
from django.db import models
from paypal.standard.ipn.signals import payment_was_flagged
import logging


def flagged_signal(sender, **kwargs):
    log = logging.getLogger("dev.ttagit.logger")
    log.debug("SIGNAL!!!!-----FLAGGED SIGNAL")


payment_was_flagged.connect(flagged_signal)
예제 #8
0
    send_confirmation_email(purchase)
purchase_paid.connect(send_mail_on_paiement)

# ~~~ Payment handling
class IPNHandler(object):
    import logging
    log = logging.getLogger("IPN handler")

    def __init__(self, sender=None, **kwargs):
        self.ERROR = None
        self.ipn = sender
        purchase = TicketPurchase.objects.get( invoice_id = self.ipn.invoice)
        if self.ipn.test_ipn:
          return
        #assert not purchase.paid, "This ticket is already marked as paid..."
        assert self.ipn.payment_status == "Completed", \
            "Payment status is " + self.ipn.payment_status
        assert purchase.price() <= self.ipn.mc_gross, "Wrong amount: %f instead of %d" % (self.ipn.mc_gross, purchase.price())
        purchase.mark_as_paid()
        self.log.info("TicketPurchase %i paid with paypal" % purchase.pk )

payment_was_successful.connect(IPNHandler)

def alert_flagged_payment(sender,**kwargs):
    mail_admins("Flagged IPN",
      "Paypal IPN has been flagged.\n" + \
      "https://tickets.fscons.org/admin/ipn/paypalipn/%d/\n" % sender.pk + \
      "https://tickets.fscons.org/admin/ticketapp/ticketpurchase/?q=%s\n" % sender.invoice
      )
payment_was_flagged.connect(alert_flagged_payment)
예제 #9
0
파일: listeners.py 프로젝트: potar/lfs
    ipn_obj = sender    
    if ipn_obj:        
        order = None
        if ipn_obj.payment_status == ST_PP_COMPLETED:
            order = mark_payment(ipn_obj, PAYMENT_FLAGGED)
        else:
            order = mark_payment(ipn_obj, PAYMENT_FAILED)    
        if order is not None:
            transaction, created = PayPalOrderTransaction.objects.get_or_create(order=order)
            transaction.ipn.add(ipn_obj)
            transaction.save()
        else:
            logging.warning("unsuccessful ipn payment, no order found for uuid %s"%ipn_obj.custom)
    else:
        logging.warning("unsuccessful ipn payment signal with no ipn object")

def successful_pdt(sender, **kwargs):    
    logging.info("successful pdt payment")
    pdt_obj = sender    
    order = mark_payment(pdt_obj, True)
    
def unsuccesful_pdt(sender, **kwargs):
    logging.info("unsuccessful pdt payment")
    pdt_obj = sender
    order = mark_payment(pdt_obj, False)    
    
payment_was_successful.connect(successful_payment, dispatch_uid="Order.ipn_successful")
payment_was_flagged.connect(unsuccessful_payment, dispatch_uid="Order.ipn_unsuccessful")
pdt_successful.connect(successful_pdt, dispatch_uid="Order.pdt_successful")
pdt_failed.connect(unsuccesful_pdt, dispatch_uid="Order.pdt_unsuccessful")
    
예제 #10
0
        return HttpResponse('OKAY')

def confirm_payment(sender, **kwargs):
    # make Order, put in db
    # look for invoice_id
    try:
        send_mail('confirm_payment', str(sender), '*****@*****.**', ['*****@*****.**'], fail_silently=False)
        unpaid_order = UnpaidOrder.objects.get(invoice_id=sender.invoice)
        dropoff_pickup_time = unpaid_order.dropoff_pickup_time
        dropoff_pickup_time.n_boxes_bought += unpaid_order.n_boxes_bought
        dropoff_pickup_time.save()
        order = Order(user=unpaid_order.user,
                      cell_number=unpaid_order.cell_number,
                      dropoff_pickup_time=unpaid_order.dropoff_pickup_time,
                      proxy_name=unpaid_order.proxy_name,
                      proxy_email=unpaid_order.proxy_email,
                      n_boxes_bought=unpaid_order.n_boxes_bought,
                      invoice_id=unpaid_order.invoice_id,
                      signature=unpaid_order.signature)
        order.save()        
    except Exception as e:
        send_mail('confirm_payment', 'something went wrong sending: ' + str(e), '*****@*****.**', ['*****@*****.**'], fail_silently=False)

payment_was_successful.connect(confirm_payment)

def handle_flagged(sender, **kwargs):
    send_mail('Subject here', 'Here is the message. (Flagged!)', '*****@*****.**',
              ['*****@*****.**'], fail_silently=False)

payment_was_flagged.connect(handle_flagged)
예제 #11
0
파일: views.py 프로젝트: bnprks/USG-srv-dev
    # make Order, put in db
    # look for invoice_id
    try:
        send_mail('confirm_payment', str(sender), '*****@*****.**', ['*****@*****.**'], fail_silently=False)
        unpaid_order = UnpaidOrder.objects.get(invoice_id=sender.invoice)
        '''
        # THIS IS NOW DONE ABOVE
        dropoff_pickup_time = unpaid_order.dropoff_pickup_time
        dropoff_pickup_time.n_boxes_bought += unpaid_order.n_boxes_bought
        dropoff_pickup_time.save()
        '''
        order = Order(user=unpaid_order.user,
                      cell_number=unpaid_order.cell_number,
                      dropoff_pickup_time=unpaid_order.dropoff_pickup_time,
                      proxy_name=unpaid_order.proxy_name,
                      proxy_email=unpaid_order.proxy_email,
                      n_boxes_bought=unpaid_order.n_boxes_bought,
                      invoice_id=unpaid_order.invoice_id,
                      signature=unpaid_order.signature)
        order.save()        
    except Exception as e:
        send_mail('confirm_payment', 'something went wrong sending: ' + str(e), '*****@*****.**', ['*****@*****.**'], fail_silently=False)

payment_was_successful.connect(confirm_payment)

def handle_flagged(sender, **kwargs):
    send_mail('Subject here', 'Here is the message. (Flagged!)', '*****@*****.**',
              ['*****@*****.**'], fail_silently=False)

payment_was_flagged.connect(handle_flagged)
예제 #12
0
        valid = False
    elif ipn_obj.mc_amount3 != trans.gross_amount:
        valid = False

    if not valid:
        subject, from_email = 'DA admin - Paypal subscription error', 'Directo al Artista <*****@*****.**>'
        message = render_to_string('email/paypal_subs_error.html', {
            'trans': trans, 'object': ipn_obj.item_name,
        })

        html_content = render_to_string('email/global/template.html', {
            'email_title': 'DA admin - Paypal subscription error',
            'email_content': message,
        })

        html_content = transform(html_content)
        text_content = strip_tags(html_content)

        msg = EmailMultiAlternatives(subject, text_content, from_email, ['*****@*****.**'])
        msg.attach_alternative(html_content, "text/html")
        msg.send(fail_silently=True)

    return valid

payment_was_successful.connect(payment_success)
payment_was_flagged.connect(payment_success_flagged)
payment_was_refunded.connect(paypal_refund_payment)

subscription_cancel.connect(paypal_subscription_canceled)
subscription_signup.connect(paypal_validate_plan_signup)
subscription_eot.connect(paypal_subscription_eot)
예제 #13
0
        update_order(request, order, cart)

    order.total = 0

    for line in order.orderline_set.all():
        order.total += line.line_price

    order.total =+ order.total + Decimal(order.delivery.price)

    order.save()

    return order

def play_signals(sender, **kwargs):
    ipn = sender
    order = Order.objects.get(pk=ipn.invoice)
    order.transaction_id = str(ipn.txn_id)
    order.payment_status = str(ipn.payment_status)
    order.payer_email = str(ipn.payer_email)
    order.payer_full_name = "%s %s" % (ipn.first_name, ipn.last_name)
    if order.payment_status == "Completed":
        if not ipn.flag:
            send_order_confirmation_email(order)
    order.save()
    return
payment_was_successful.connect(play_signals)
payment_was_flagged.connect(play_signals)

def paypal_signal(ipn):
    pass
예제 #14
0
    for line in order.orderline_set.all():
        order.total += line.line_price

    order.total = +order.total + Decimal(order.delivery.price)

    order.save()

    return order


def play_signals(sender, **kwargs):
    ipn = sender
    order = Order.objects.get(pk=ipn.invoice)
    order.transaction_id = str(ipn.txn_id)
    order.payment_status = str(ipn.payment_status)
    order.payer_email = str(ipn.payer_email)
    order.payer_full_name = "%s %s" % (ipn.first_name, ipn.last_name)
    if order.payment_status == "Completed":
        if not ipn.flag:
            send_order_confirmation_email(order)
    order.save()
    return


payment_was_successful.connect(play_signals)
payment_was_flagged.connect(play_signals)


def paypal_signal(ipn):
    pass
예제 #15
0

def paypal_payment_was_flagged_handler(sender, **kwargs):
    logger = logging.getLogger("cardstories.paypal")
    logger.error("Paypal Payment Failed! %r; %r" % (sender.flag_code, sender.flag_info))


def send_bought_cards_confirmation_mail(user_id):
    """
    Builds and sends the 'Thank you for buying cards' email
    to user specified by `user_id`.

    """
    user = User.objects.get(id=user_id)
    email = user.username
    template = "bought_cards_confirmation"
    subject = "Thank you for purchasing a deck of cards!"
    message = mailing.message.build_mail(template, subject, email)

    smtp = get_connection(fail_silently=False)
    smtp.open()
    smtp.send_messages([message])
    smtp.close()


# Registers creation of user profile on post_save signal.
post_save.connect(create_user_profile, sender=User)
# Registers Paypal's IPN signals.
payment_was_successful.connect(paypal_payment_was_successful_handler)
payment_was_flagged.connect(paypal_payment_was_flagged_handler)
예제 #16
0
from paypal.standard.ipn.signals import payment_was_flagged

def show_me_the_flag(sender, **kwargs):
    ipn_obj = sender
    # You need to check 'payment_status' of the IPN
    print str(ipn_obj.flag) + " --- " + str(ipn_obj.flag_info)

payment_was_flagged.connect(show_me_the_flag)
예제 #17
0
        logger.error("Error handling transaction from %r" % sender.payer_email)
        logger.error('-'*60 + '\n' + traceback.format_exc() + '\n' + '-'*60)
        return False

def paypal_payment_was_flagged_handler(sender, **kwargs):
    logger = logging.getLogger('cardstories.paypal')
    logger.error("Paypal Payment Failed! %r; %r" % (sender.flag_code, sender.flag_info))

def send_bought_cards_confirmation_mail(user_id):
    """
    Builds and sends the 'Thank you for buying cards' email
    to user specified by `user_id`.

    """
    user = User.objects.get(id=user_id)
    email = user.username
    template = 'bought_cards_confirmation'
    subject = 'Thank you for purchasing a deck of cards!'
    message = mailing.message.build_mail(template, subject, email)

    smtp = get_connection(fail_silently=False)
    smtp.open()
    smtp.send_messages([message])
    smtp.close()

# Registers creation of user profile on post_save signal.
post_save.connect(create_user_profile, sender=User)
# Registers Paypal's IPN signals.
payment_was_successful.connect(paypal_payment_was_successful_handler)
payment_was_flagged.connect(paypal_payment_was_flagged_handler)
예제 #18
0
def reset_by_upgrade_variant_or_choice_set(sender,
                                           instance,
                                           created=False,
                                           **kwargs):
    if instance.item:
        reset_menu_json(instance.item.site)


def reset_by_choice(sender, instance, created=False, **kwargs):
    if instance.group.item:
        reset_menu_json(instance.group.item.site)


payment_was_successful.connect(register_paypal_payment)
payment_was_flagged.connect(register_paypal_payment)
post_save.connect(new_site_setup)
post_save.connect(item_social_handler, sender=Item)
post_save.connect(pdf_caching_handler, sender=Item)
post_save.connect(create_defaults, sender=Item)

post_save.connect(reset_by_section_or_item, sender=Item)
post_save.connect(reset_by_section_or_item, sender=Section)
post_save.connect(reset_by_upgrade_variant_or_choice_set, sender=Upgrade)
post_save.connect(reset_by_upgrade_variant_or_choice_set, sender=Variant)
post_save.connect(reset_by_upgrade_variant_or_choice_set, sender=SideDishGroup)
post_save.connect(reset_by_choice, sender=SideDish)

pre_delete.connect(reset_by_section_or_item, sender=Item)
pre_delete.connect(reset_by_section_or_item, sender=Section)
pre_delete.connect(reset_by_upgrade_variant_or_choice_set, sender=Upgrade)
예제 #19
0
    
    # IF THERE WAS A SINGLE USE DISCOUNT, UPDATE IT
    if order.discount:
        if order.discount.single_use == True:
            order.discount.is_active = False
            order.discount.save()
    
    # SEND THE EMAILS
    if ipn_obj.flag == True:
        from emailer.views import _payment_flagged
        _payment_flagged(order)
    else:
        from emailer.views import _payment_success 
        _payment_success(order)
        
            
    # NOW CREATE A CUSTOMER PACKAGE
    from logistics.views import _create_customer_package
    _create_customer_package(order)
    
        
        
payment_was_successful.connect(show_me_the_money)  
payment_was_flagged.connect(show_me_the_money)  






예제 #20
0
파일: models.py 프로젝트: VinceRafale/tiger
def reset_menu_json(site):
    KeyChain.menu_json.invalidate(site.id)

def reset_by_section_or_item(sender, instance, created=False, **kwargs):
    reset_menu_json(instance.site)

def reset_by_upgrade_variant_or_choice_set(sender, instance, created=False, **kwargs):
    if instance.item:
        reset_menu_json(instance.item.site)

def reset_by_choice(sender, instance, created=False, **kwargs):
    if instance.group.item:
        reset_menu_json(instance.group.item.site)

payment_was_successful.connect(register_paypal_payment)
payment_was_flagged.connect(register_paypal_payment)
post_save.connect(new_site_setup)
post_save.connect(item_social_handler, sender=Item)
post_save.connect(pdf_caching_handler, sender=Item)
post_save.connect(create_defaults, sender=Item)

post_save.connect(reset_by_section_or_item, sender=Item)
post_save.connect(reset_by_section_or_item, sender=Section)
post_save.connect(reset_by_upgrade_variant_or_choice_set, sender=Upgrade)
post_save.connect(reset_by_upgrade_variant_or_choice_set, sender=Variant)
post_save.connect(reset_by_upgrade_variant_or_choice_set, sender=SideDishGroup)
post_save.connect(reset_by_choice, sender=SideDish)

pre_delete.connect(reset_by_section_or_item, sender=Item)
pre_delete.connect(reset_by_section_or_item, sender=Section)
pre_delete.connect(reset_by_upgrade_variant_or_choice_set, sender=Upgrade)
예제 #21
0
    if order.status == Order.STATUS_PAID or order.status == Order.STATUS_PAYMENT_FLAGGED:
        return

    # UPDATE THE ORDER DETAILS
    order.status = Order.STATUS_PAID
    order.date_paid = ipn_obj.payment_date
    order.is_paid = True
    order.save()

    # IF THERE WAS A SINGLE USE DISCOUNT, UPDATE IT
    if order.discount:
        if order.discount.single_use == True:
            order.discount.is_active = False
            order.discount.save()

    # SEND THE EMAILS
    if ipn_obj.flag == True:
        from emailer.views import _payment_flagged
        _payment_flagged(order)
    else:
        from emailer.views import _payment_success
        _payment_success(order)

    # NOW CREATE A CUSTOMER PACKAGE
    from logistics.views import _create_customer_package
    _create_customer_package(order)


payment_was_successful.connect(show_me_the_money)
payment_was_flagged.connect(show_me_the_money)
예제 #22
0
    if not valid:
        subject, from_email = 'DA admin - Paypal subscription error', 'Directo al Artista <*****@*****.**>'
        message = render_to_string('email/paypal_subs_error.html', {
            'trans': trans,
            'object': ipn_obj.item_name,
        })

        html_content = render_to_string(
            'email/global/template.html', {
                'email_title': 'DA admin - Paypal subscription error',
                'email_content': message,
            })

        html_content = transform(html_content)
        text_content = strip_tags(html_content)

        msg = EmailMultiAlternatives(subject, text_content, from_email,
                                     ['*****@*****.**'])
        msg.attach_alternative(html_content, "text/html")
        msg.send(fail_silently=True)

    return valid


payment_was_successful.connect(payment_success)
payment_was_flagged.connect(payment_success_flagged)
payment_was_refunded.connect(paypal_refund_payment)

subscription_cancel.connect(paypal_subscription_canceled)
subscription_signup.connect(paypal_validate_plan_signup)
subscription_eot.connect(paypal_subscription_eot)
예제 #23
0
from registration.models import RegistrationProfile
from registration.views import ActivationView

def payment_signal(sender, **kwargs):
	ipn_object = sender
	#if ipn_object.payment_status == ST_PP_COMPLETED:
	if payment_status == 'Completed':
		print "payment_status == ST_PP_COMPLETED"

		"""
		Here use django-registration to authenticate
		the User
		"""

		activate_user(activation_key)

		activation_key = ACTIVATED

		#ActivationView.activate()

	else:
		print str(ipn_object.payment_status)
		print "error"

valid_ipn_received.connect(payment_signal)	
payment_was_flagged.connect(payment_signal)

print "SIGNALS MODULE IMPORTED"

예제 #24
0
    # write the actual message
    message = "ID: " + str(ipn_obj.id) + "\n"
    if err_on_success:
        message += "Error from process_err_ipn_signal: " + err_on_success + "\n"
    if ipn_obj.flag:
        message += "Flag info: " + ipn_obj.flag_info + "\n"
    message += "\n"
    message += "Response: " + ipn_obj.response + "\n"
    message += "Transaction Subject: " + ipn_obj.transaction_subject + "\n"
    message += "Custom: " + ipn_obj.custom + "\n"
    message += "Quantity: " + str(ipn_obj.quantity) + "\n"
    message += "Option Name1: " + unicode(ipn_obj.option_name1) + "\n"  
    message += "Payer Status: " + unicode(ipn_obj.payer_status) + "\n" 
    message += "Payment Date: " + unicode(ipn_obj.payment_date) + "\n" 
    message += "Payment Gross: " + unicode(ipn_obj.payment_gross) + "\n" 
    message += "Payment Status: " + unicode(ipn_obj.payment_status) + "\n" 
    message += "Payment Type: " + unicode(ipn_obj.payment_type) + "\n" 
    message += "Name: " + unicode(ipn_obj.first_name) + " " + unicode(ipn_obj.last_name) + "\n" 
    message += "Payer Email: " + unicode(ipn_obj.payer_email) + "\n" 
    message += "Payer ID: " + unicode(ipn_obj.payer_id) + "\n" 
    message += "MC Currency: " + unicode(ipn_obj.mc_currency) + "\n" 
    message += "MC Fee: " + unicode(ipn_obj.mc_fee) + "\n" 
    message += "MC Gross: " + unicode(ipn_obj.mc_gross) + "\n" 
    message += "\n\n\n\n" 
    message += "query: " + unicode(ipn_obj.query) + "\n"

    send_mail(subject, message, news_settings.NEWS_PAY_ERR_MAIL_FROM, 
            [news_settings.NEWS_PAY_ERR_MAIL_TO])

payment_was_flagged.connect(process_err_ipn_signal)
예제 #25
0
        return POSTBACK_ENDPOINT

    def get_urls(self):
        urlpatterns = patterns('',
           (r'^', include('paypal.standard.ipn.urls')),
            )
        return urlpatterns

    def form_class(self):
        if self.encrypted:
            return PayPalEncryptedPaymentsForm
        return PayPalPaymentsForm

    def generate_form(self):
        return self.form_class()(initial=self.fields)


def unsuccessful_txn_handler(sender, **kwargs):
    transaction_was_unsuccessful.send(sender=sender.__class__,
                                      type="purchase",
                                      response=sender)


def successful_txn_handler(sender, **kwargs):
    transaction_was_successful.send(sender=sender.__class__,
                                    type="purchase",
                                    response=sender)

payment_was_flagged.connect(unsuccessful_txn_handler)
payment_was_successful.connect(successful_txn_handler)
예제 #26
0
            if self.engine == "paypal":
                return self.project.paymentgatewayselector.paypal_gateway.notification_email
            elif self.engine == "ideal":
                return self.project.paymentgatewayselector.mollie_gateway.notification_email

    @property
    def donation_fee(self):
        return (self.amount - self.amount_received)

    def __unicode__(self):
        return u'Invoice %(invoice_id)s (Project: %(project_name)s)' % {
            'invoice_id': self.id, 'project_name': self.project
        }

    class Meta:
        app_label = 'rsr'
        verbose_name = u'invoice'
        ordering = ['-id', ]


# PayPal IPN listener
def process_paypal_ipn(sender, **kwargs):
    ipn = sender
    if ipn.payment_status == 'Completed':
        invoice = Invoice.objects.get(pk=int(ipn.invoice))
        invoice.amount_received = invoice.amount - ipn.mc_fee
        invoice.ipn = ipn.txn_id
        invoice.status = 3
        invoice.save()
payment_was_flagged.connect(process_paypal_ipn)
예제 #27
0
    
def payment_flagged(sender, **kwargs):
    ipn_obj = sender
    order = get_object_or_404(Order, invoice_id=ipn_obj.invoice)
    order.status = Order.STATUS_PAYMENT_FLAGGED
    order.save()

     # create and send an email to me
    invoice_id = order.invoice_id
    email = order.owner.email
    recipient = '*****@*****.**'
    body = render_to_string('shop/emails/order_confirm_admin.txt', {'email': email, 'invoice_id': invoice_id, 'order_items': order.items.all()})
    subject_line = "FLAGGED ORDER - %s" % invoice_id 
    email_sender = '*****@*****.**'
      
    send_mail(
                  subject_line, 
                  body, 
                  email_sender,
                  [recipient], 
                  fail_silently=False
     )   
payment_was_flagged.connect(payment_flagged)






예제 #28
0
파일: models.py 프로젝트: hgezim/GizmoBooks
    mail_managers(
        "Book sold", "Book copy with id: %d has sold.\n IPN id: %d" %
        (book_copy.id, ipn_obj.id))


payment_was_successful.connect(book_copy_just_sold)


def book_copy_sale_flagged(sender, **kwargs):
    ipn_obj = sender
    mail_managers(
        "Book payment flagged.",
        "A book payment has been flagged.\n IPN id: %d." % ipn_obj.id)


payment_was_flagged.connect(book_copy_sale_flagged)


class Author(models.Model):
    name = models.CharField(max_length=100)

    def __unicode__(self):
        return self.name


class Subject(MPTTModel):
    name = models.CharField(max_length=50)
    bnid = models.CharField(max_length=50, blank=True)
    hidden = models.BooleanField(default=False)
    parent = models.ForeignKey('self',
                               null=True,