예제 #1
0
            event.save()
            logger.info(
                'Paypal Success: deposit payment recieved, status updated')
    else:
        logger.error('Paypal Failure: IPN object status is not complete')


valid_ipn_received.connect(show_me_the_money)


def show_me_the_error(sender, **kwargs):
    logger.error('Paypal Error: invalid IPN received')
    logger.error(sender)


invalid_ipn_received.connect(show_me_the_error)


def view_that_asks_for_money(request, pk, custom):
    custom = custom
    event = get_object_or_404(Event, pk=pk)
    item_name = 'Deposit for {0} on {1}'.format(event.event_type,
                                                event.event_date)
    cancel_return = '{0}/payment_cancel/{1}'.format(base_url, event.pk)
    return_url = '{0}/payment_success/{1}'.format(base_url, event.pk)
    paypal_dict = {
        "business": paypal_reciever_email,
        "image_url": paypal_logo_url,
        "amount": event.deposit,
        "item_name": item_name,
        "invoice": event.pk,
예제 #2
0
파일: models.py 프로젝트: judy2k/pipsevents
                    obj_type.title(),
                    'payment to paypal email {}'.format(
                        additional_data['test_paypal_email']
                    ) if obj_type == 'paypal_test' else
                    'id {}'.format(obj.id),
                    ipn_obj.invoice,
                    ipn_obj.txn_id, e
                    )
            )
            send_mail(
                '{} There was some problem processing payment_not_received for '
                '{} {}'.format(
                    settings.ACCOUNT_EMAIL_SUBJECT_PREFIX, obj_type,
                    'payment to paypal email {}'.format(
                        additional_data['test_paypal_email']
                    ) if obj_type == 'paypal_test' else
                    'id {}'.format(obj.id)
                ),
                'Please check your booking and paypal records for '
                'invoice # {}, paypal transaction id {}.\n\nThe exception '
                'raised was "{}".\n\nNOTE: this error occurred during '
                'processing of the payment_not_received signal'.format(
                    ipn_obj.invoice, ipn_obj.txn_id, e
                ),
                settings.DEFAULT_FROM_EMAIL,
                [settings.SUPPORT_EMAIL],
                fail_silently=False)

valid_ipn_received.connect(payment_received)
invalid_ipn_received.connect(payment_not_received)
예제 #3
0
    )
    evaluacion = models.ForeignKey(
        Evaluacion, null=True, blank=False, related_name='evaluacion_pago_set', on_delete=models.PROTECT
    )

    def __str__(self):
        return 'Comprobante con metodo de pago: {0}'.format(self.get_tipo_pago_display())


class Codigo(models.Model):
    codigo = models.CharField(max_length=200, null=True, blank=False)
    activo = models.BooleanField(null=False, blank=False, default=True)

    def __str__(self):
        return 'Codigo: {0}'.format(self.codigo)


def guardar_pago_evaluacion(sender, **kwargs):
    print(sender)
    ipn_obj = sender

    if ipn_obj.payment_status == ST_PP_COMPLETED:
        if ipn_obj.receiver_email != settings.PAYPAL_BUSINESS:
            return
    else:
        return


valid_ipn_received.connect(guardar_pago_evaluacion)
invalid_ipn_received.connect(guardar_pago_evaluacion)
예제 #4
0
        order = None
        if ipn_obj.payment_status == ST_PP_COMPLETED:
            logger.info("PayPal: payment flaged")
            order = mark_payment(ipn_obj, PAYMENT_FLAGGED)
        else:
            logger.info("PayPal: payment failed")
            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:
            logger.warning("PayPal: unsuccessful ipn payment, no order found for uuid %s" % ipn_obj.custom)
    else:
        logger.warning("PayPal: unsuccessful ipn payment signal with no ipn object")


def successful_pdt(sender, **kwargs):
    logger.info("PayPal: successful pdt payment")
    pdt_obj = sender
    mark_payment(pdt_obj, True)


def unsuccesful_pdt(sender, **kwargs):
    logger.info("PayPal: unsuccessful pdt payment")
    pdt_obj = sender
    mark_payment(pdt_obj, False)

valid_ipn_received.connect(successful_payment, dispatch_uid="Order.ipn_successful")
invalid_ipn_received.connect(unsuccessful_payment, dispatch_uid="Order.ipn_unsuccessful")
예제 #5
0
        # payment was successful
        order = get_object_or_404(Order, id=ipn_object.invoice)

        # mark the order as paid
        order.paid = True
        order.save()
        # create invoice e - mail
        subject = 'My Shop - Invoice no. {}'.format(order.id)
        message = 'Please, find attached the invoice for your recent purchase.'
        email = EmailMessage(subject,
                             message,
                             '*****@*****.**',
                             [order.email])

        # generate PDF
        html = render_to_string('orders/order/pdf.html', {'order': order})
        out = BytesIO()
        stylesheets = [weasyprint.CSS(settings.STATIC_ROOT + 'css/pdf.css')]
        weasyprint.HTML(string=html).write_pdf(out,
                                               stylesheets=stylesheets)
        # attach PDF file
        email.attach('order_{}.pdf'.format(order.id),
                     out.getvalue(),
                     'application/pdf')
        # send e-mail
        email.send()


invalid_ipn_received.connect(payment_notification)

예제 #6
0
파일: models.py 프로젝트: sanekzh/discord
                billing = Billing.objects.get(
                    paypal_email=ipn_obj.receiver_email)
                new_member = Member(user=billing.user,
                                    email=ipn_obj.payer_email)
                new_member.save()
            except Exception as e:
                print("Error add new Member...", e.args)
    return HttpResponse(status=200)


def invalid_payment(sender, **kwargs):
    print("I am here in invalid payment")
    print(sender)


invalid_ipn_received.connect(invalid_payment)
valid_ipn_received.connect(payment_received_succes)


def payment_stripe_received_succes(sender, user_id):
    """ This is callback handler for valid_ipn_received signal.

    We are here checking whether payer_email is already
    in database or not. We are creating members here after
    transaction was successfully.
    """

    ipn_obj = sender

    billing = Billing.objects.get(user_id=user_id)
    member = Member.objects.filter(user=billing.user,
예제 #7
0
        p.ipn = ipn_obj
        p.save()

        # if payment is completed, so valid
        if ipn_obj.payment_status == ST_PP_COMPLETED:
            # check correct price , currency and mail
            if int(ipn_obj.mc_gross) == int(p.price.price) and \
                    ipn_obj.mc_currency == 'EUR' and \
                    ipn_obj.business == settings.PAYPAL_RECEIVER_EMAIL:
                # all is OK, update state
                p.state = True
                p.save()
                sendmail_payment_success(p)
        else:
            # TODO: send alert / mail
            return
    except Payment.DoesNotExist:
        # TODO: send alert / mail
        pass
    except:
        # TODO: send alert / mail
        pass


# See django-paypal API.
# When Paypal sends us a POST request, a signal is sent to all objects
# that are connected
# We want to be informed of any PayPal actions
valid_ipn_received.connect(update_paypal)
invalid_ipn_received.connect(update_paypal)
예제 #8
0
            "amount": self.total_price,
            "currency": "EUR",
            "item_name":
            "%s-%s Transcript" % (self.category, self.text_format),
            "invoice": "%s-%s" % (self.pk, uuid.uuid4()),
            "notify_url": settings.PAYPAL_NOTIFY_URL,
            "return_url": "%s/paypal-return" % settings.SITE_URL,
            "cancel_return": "%s/paypal-cancel" % settings.SITE_URL,
            "custom": "%s-%s" % (self.pk, self.tat)
        }
        return PayPalPaymentsForm(initial=paypal_dict)

    @property
    def is_past_due(self):
        return timezone.now() > self.deadline


class Review(models.Model):
    transcript_detail = models.ForeignKey(TranscriptDetails,
                                          related_name='reviews')
    user = models.ForeignKey(settings.AUTH_USER_MODEL, related_name='reviews')
    comment = HTMLField(blank=True)
    created_at = models.DateTimeField(default=timezone.now)


from .signals import payment_accepted, invalid_handler

valid_ipn_received.connect(payment_accepted)

invalid_ipn_received.connect(invalid_handler)
예제 #9
0
        # if ipn_obj.receiver_email != "*****@*****.**":
            # Not a valid payment
            # return

        # ALSO: for the same reason, you need to check the amount
        # received, `custom` etc. are all what you expect or what
        # is allowed.

        # Undertake some action depending upon `ipn_obj`.
        # if ipn_obj.custom == "premium_plan":
            # price = ...
        # else:
            # price = ...

        # if ipn_obj.mc_gross == price and ipn_obj.mc_currency == 'USD':

        # ...
        print("Completed!")
    else:
        # ...
        print("Not Completed")


def error_in_payment(sender, **kwargs):
    print(sender)
    print('Error')


valid_ipn_received.connect(show_me_the_money)
invalid_ipn_received.connect(error_in_payment)
예제 #10
0
        elif ipn_obj.payment_status == ST_PP_REFUNDED:
            # DO NOTHING, JUST SEND EMAILS SO WE CAN CHECK MANUALLY
            logger.info(
                "IPN signal received for refunded invoice %s; transaction id %s",
                ipn_obj.invoice, ipn_obj.txn_id)
            send_processed_refund_emails(invoice)
        else:
            # DO NOTHING, JUST SEND EMAILS SO WE CAN CHECK MANUALLY
            logger.info(
                "IPN signal received with unexpecting status %s; invoice %s; transaction id %s",
                ipn_obj.payment_status, ipn_obj.invoice, ipn_obj.txn_id)
            send_failed_payment_emails(
                ipn_obj, error="IPN signal received with unexpecting status")
    except Exception as error:
        logger.error(error)
        # If anything else went wrong
        send_failed_payment_emails(ipn_obj, error=error)


def process_invalid_ipn(sender, **kwargs):
    ipn_obj = sender
    logger.info("Invalid IPN %s; invoice %s, flag_info %s", ipn_obj.id,
                ipn_obj.invoice, ipn_obj.flag_info)
    raise PayPalProcessingError(
        f"Invalid IPN: {ipn_obj.id}; invoice {ipn_obj.invoice}; flag {ipn_obj.flag_info}"
    )


valid_ipn_received.connect(process_ipn)
invalid_ipn_received.connect(process_invalid_ipn)
예제 #11
0
        }
        return 'square-commerce-v1://payment/create?data=' + urlencode(json.dumps(initial, cls=DjangoJSONEncoder))

    def paypal_forms(self):
        Forms = namedtuple('Forms', 'one_click,sub_click,zero_click,square_click')
        one_click_initial, sub_click_initial = self.paypal_form_initial()

        if (
            self.should_invoice
            and self.invoice.total == 0
        ):
            zero_click_initial = {
                'ticket_id': self.id,
            }
        else:
            zero_click_initial = None

        from lindy.ticket.forms import FinalizeZeroDollarCheckout

        return Forms(
            one_click=PayPalPaymentsForm(initial=one_click_initial) if one_click_initial else None,
            sub_click=PayPalPaymentsForm(initial=sub_click_initial) if sub_click_initial else None,
            zero_click=FinalizeZeroDollarCheckout(initial=zero_click_initial) if zero_click_initial else None,
            square_click=self.square_form_initial(),
        )

valid_ipn_received.connect(Ticket.show_me_the_money)
invalid_ipn_received.connect(Ticket.ipn_error)

del PayPalIPN  # do not export this model so it is not autodiscovered in the wrong place
예제 #12
0
from django.shortcuts import get_object_or_404
from paypal.standard.models import ST_PP_COMPLETED
from paypal.standard.ipn.signals import valid_ipn_received, invalid_ipn_received
from .models import Order


def payment_notification(sender, **kwargs):
    ipn_obj = sender
    if ipn_obj.payment_status == ST_PP_COMPLETED:

        order = get_object_or_404(Order, id=ipn_obj.invoice)
        # mark the order as paid
        order.paid = True
        order.save()


valid_ipn_received.connect(payment_notification)


def payment_reversed(sender, **kwargs):
    ipn_obj = sender
    if ipn_obj.payment_status != "Completed":
        order = get_object_or_404(Order, id=ipn_obj.invoice).delete()


invalid_ipn_received.connect(payment_reversed)
예제 #13
0
파일: views.py 프로젝트: DSIW/sdf
    if request.method == 'POST' and request.is_ajax():
        return JsonResponse({'result': success})
    else:
        if success:
            messages.add_message(request, messages.SUCCESS, 'Die Bezahlung wurde abgebrochen.')
        return HttpResponseRedirect(reverse('app_book:book-detail', kwargs={'id': payment.book_id}))


def paypal_ipn(sender, **kwargs):
    ipn_obj = sender
    payment = Payment.objects.filter(invoice=ipn_obj.invoice).first()
    if payment is not None:
        update_payment_from_paypal_ipn(payment, ipn_obj)

valid_ipn_received.connect(paypal_ipn)
invalid_ipn_received.connect(paypal_ipn)


@login_required
def rate_seller(request, id):
    backpath = request.META.get('HTTP_REFERER')
    if backpath is None :
        backpath = reverse("app:startPage")
    rating = SellerRating.objects.filter(payment_id=id).first()
    if rating is not None:
        messages.add_message(request,messages.ERROR,"Sie können ein Verkäufer pro Einkauf nur einmal bewerten.")
        return HttpResponseRedirect(backpath)
    payment = get_object_or_404(Payment, id=id)
    if payment is None:
        messages.add_message(request,messages.ERROR,"Sie können diesen Nutzer nicht bewerten.")
        return HttpResponseRedirect(backpath)
예제 #14
0
파일: models.py 프로젝트: judy2k/pipsevents
                settings.DEFAULT_FROM_EMAIL, [settings.SUPPORT_EMAIL],
                fail_silently=False)

    except Exception as e:
        # if anything else goes wrong, send a warning email
        logger.warning(
            'Problem processing payment_not_received for {} {}; invoice_'
            'id {}, transaction id: {}. Exception: {}'.format(
                obj_type.title(), 'payment to paypal email {}'.format(
                    additional_data['test_paypal_email'])
                if obj_type == 'paypal_test' else 'id {}'.format(obj.id),
                ipn_obj.invoice, ipn_obj.txn_id, e))
        send_mail(
            '{} There was some problem processing payment_not_received for '
            '{} {}'.format(
                settings.ACCOUNT_EMAIL_SUBJECT_PREFIX, obj_type,
                'payment to paypal email {}'.format(
                    additional_data['test_paypal_email'])
                if obj_type == 'paypal_test' else 'id {}'.format(obj.id)),
            'Please check your booking and paypal records for '
            'invoice # {}, paypal transaction id {}.\n\nThe exception '
            'raised was "{}".\n\nNOTE: this error occurred during '
            'processing of the payment_not_received signal'.format(
                ipn_obj.invoice, ipn_obj.txn_id, e),
            settings.DEFAULT_FROM_EMAIL, [settings.SUPPORT_EMAIL],
            fail_silently=False)


valid_ipn_received.connect(payment_received)
invalid_ipn_received.connect(payment_not_received)
예제 #15
0
파일: signals.py 프로젝트: Croolis/e-store
from paypal.standard.ipn.signals import valid_ipn_received, invalid_ipn_received
from django.core.mail import send_mail

def show_me_the_money(sender, **kwargs):
    ipn_obj = sender
    print('!!!!!!!!!!!!!!!!!!!!!!!!!!!')
    if ipn_obj.payment_status == ST_PP_COMPLETED:
        code = ipn_obj.invoice
        try:
            items = Cart.objects.filter(code=code)[0].items.all()
            for item in items:
                item.amount = max(0, item.amount - 1)
        except:
            pass
        if ipn_obj.receiver_email != "*****@*****.**":
            return


        #send_mail(
        #    '1',
        #    '2',
        #    '*****@*****.**',
        #    ['*****@*****.**'],
        #    fail_silently=False,
        #)
    else:
        pass

valid_ipn_received.connect(show_me_the_money)
invalid_ipn_received.connect(show_me_the_money)
예제 #16
0
def handle_invalid_donation(sender, **kwargs):
    logger.info('An invalid IPN request was made')


class DonationAdmin(ModelAdmin):
    permission_helper_class = ProtectModelPermissionHelper
    model = PayPalIPN
    menu_label = 'Donations'
    menu_icon = 'form'
    menu_order = 230
    list_display = ('payment_date', 'first_name', 'last_name', 'payer_email',
                    'payment_type', 'mc_gross', 'payment_status')
    list_filter = ('recurring', 'payment_status')
    search_fields = ('first_name', 'last_name')
    inspect_view_enabled = True

    def recurring_donation(self, obj):
        return True if obj.recurring else False


modeladmin_register(ConcertAdmin)
modeladmin_register(PersonAdmin)
modeladmin_register(CompositionAdmin)
modeladmin_register(BlogPostAdmin)
modeladmin_register(InstrumentAdmin)
modeladmin_register(DonationAdmin)
modeladmin_register(NewMemberRequestAdmin)
valid_ipn_received.connect(handle_donation)
invalid_ipn_received.connect(handle_invalid_donation)
예제 #17
0
from paypal.standard.models import ST_PP_COMPLETED
from paypal.standard.ipn.signals import valid_ipn_received,invalid_ipn_received
from django.views.decorators.csrf import csrf_exempt

def show_me_the_money(sender, **kwargs):
    print('test')
    print("TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT")
    ipn_obj = sender
    if ipn_obj.payment_status == ST_PP_COMPLETED:
     
        if ipn_obj.receiver_email != "*****@*****.**":
            # Not a valid payment
            return

        if ipn_obj.mc_gross == ipn_obj.amount and ipn_obj.mc_currency == 'USD':
            pk = ipn_obj.invoice
            dsr = DatasetRequest.objects.get(pk=pk)
            dsr.is_paid = True
            dsr.save()
    else:
        pass

print("FC barcelona")
valid_ipn_received.connect(show_me_the_money)
invalid_ipn_received.connect(show_me_the_money)

예제 #18
0
def process_payment(sender, **kwargs):
    print "Processing payment"
    ipn_obj = sender

    if ipn_obj.payment_status == ST_PP_COMPLETED:
        # Undertake some action depending upon `ipn_obj`.
        custom_code = b64decode(ipn_obj.custom)
        print "Custom Code: " + ipn_obj.custom + " decoded: " + custom_code
        m = re.search("reservation=(.*),(\d*)", custom_code)
        print "txn_id = " + ipn_obj.txn_id
        try:
            reservation_id = int(m.group(2))
            print "id=" + unicode(reservation_id)
            reservation = Reservation.objects.get(id=reservation_id)
            print unicode(reservation)
            charge = {"txn_id": ipn_obj.txn_id, "invoice": ipn_obj.invoice}
            reservation.pay(confirmation=json.dumps(charge), choice="P")
            print "paid"
        except Reservation.DoesNotExist:
            print "not exist"
        except:
            print "otro error" + sys.exc_info()[0]

    else:
        print "fallo"


valid_ipn_received.connect(process_payment)
invalid_ipn_received.connect(process_payment)