Exemplo n.º 1
0
 def send_failure_email(self, transaction_id):
     print('Payment failure data received ' + transaction_id)
     order_payment = OrderPayment.objects.select_related('order').filter(
         transaction_id=transaction_id).first()
     customer = Customer.objects.get(
         customer_id=order_payment.order.customer_id)
     email = Email()
     email.subject = "Order failure for Grocery 60"
     email.phone = customer.phone_number
     email.email = customer.email
     email.order_id = order_payment.order_id
     email.template = 'order_payment_failure.html'
     email_send.send_email_topic(email)
Exemplo n.º 2
0
 def get(self, request):
     print('verifying')
     username = request.GET.get('username')
     user = User.objects.get(username=username)
     email = Email()
     email.subject = "Welcome to Grocery 60 !!!"
     email.email = user.email
     email.first_name = user.first_name
     email.username = user.username
     email.template = 'registration.html'
     # email_send.send_email(email, 'registration.html')
     email_send.send_email_topic(email)
     print('return')
     data = {'message': 'success'}
     return JsonResponse(data=data, status=status.HTTP_200_OK, safe=False)
Exemplo n.º 3
0
 def send_store_email(self, transaction_id):
     print('Store success data received ' + transaction_id)
     order_payment = OrderPayment.objects.select_related('order').filter(
         correlation_id=transaction_id).first()
     print('order_payment ', order_payment)
     store = Store.objects.get(store_id=order_payment.store.store_id)
     print('store ', store)
     email = Email()
     email.currency = '₹' if store.currency == 'inr' else '$'
     email.subject = "Store Order Confirmation for Grocery 60"
     email.email = store.email
     email.order_id = order_payment.order_id
     email.set_order(email.order_id)
     email.template = 'store_order_confirmation.html'
     email_send.send_email_topic(email)
Exemplo n.º 4
0
 def post(self, request, *args, **kwargs):
     data = JSONParser().parse(request)
     email = data.get('email')
     user = User.objects.filter(email=email).first()
     if user:
         email = Email()
         email.subject = "Forgot username for Grocery 60 !!!"
         email.email = user.email
         email.username = user.username
         email.first_name = user.first_name
         email.template = 'forgot_username.html'
         email_send.send_email_topic(email)
         return JsonResponse(data={"msg": "Username is sent to your email"},
                             status=status.HTTP_200_OK,
                             safe=False)
     else:
         raise ValidationError('User does not exist in the system')
Exemplo n.º 5
0
 def post(self, request, *args, **kwargs):
     data = JSONParser().parse(request)
     username = data.get('username')
     print('password reset for user', username)
     user = User.objects.filter(username=username).first()
     if user:
         text_password = util.generate_password(8)
         user.password = hashers.make_password(text_password)
         user.save()
         email = Email()
         email.subject = "Password reset for Grocery 60 !!!"
         email.email = user.email
         email.username = user.username
         email.first_name = user.first_name
         email.password = text_password
         # email_send.send_email(email, 'password_reset.html')
         email.template = 'password_reset.html'
         email_send.send_email_topic(email)
         return JsonResponse(data={}, status=status.HTTP_200_OK, safe=False)
     else:
         raise ValidationError('User does not exist in system')
Exemplo n.º 6
0
    def delete(self, request, order_id):
        print('order id cancellation', order_id)
        order_payment = OrderPayment.objects.get(order_id=order_id)
        print(order_payment.transaction_id)
        # Perform for stripe orders
        if order_payment.transaction_id.startswith('pi_'):
            try:
                # To cancel a PaymentIntent
                intent = stripe.PaymentIntent.cancel(
                    order_payment.transaction_id)
            except stripe.error.StripeError as e:
                # Display a very generic error to the user, and maybe send
                # yourself an email
                raise ValidationError(
                    'Order Cancellation failed for Order  #{:d}. Please email to [email protected] '
                    'and we will reply you in 24 hours. '.format(order_id))

        if not order_payment.transaction_id.startswith('pi_') or intent.get(
                'status') == 'canceled':
            order_payment.status = 'CANCELED'
            order_payment.save()
            order = Order.objects.get(order_id=order_id)
            order.status = 'CANCELED'
            order.save()
            # Send email for order cancellation
            email = Email()
            email.subject = "Order cancellation for Grocery 60"
            user = User.objects.get(id=order_payment.order.customer_id)
            email.email = user.email
            email.order_id = order_payment.order_id
            email.template = 'order_cancellation.html'
            # email_send.send_email(email, 'order_cancellation.html')
            email_send.send_email_topic(email)
            response_dict = {'status': 'success'}
            return JsonResponse(data=response_dict,
                                status=status.HTTP_200_OK,
                                safe=False)
        else:
            raise ValidationError('Order Cancellation failed for Order = ',
                                  order_id)
Exemplo n.º 7
0
 def send_success_email(self, email):
     print('data received ', email.order_id)
     print('data received ', email.order_items_list)
     email.template = 'order_confirmation.html'
     email_send.send_email_topic(email)
Exemplo n.º 8
0
 def send_pickup_email(self, email):
     print('data received ', email.order_id)
     print('data received ', email.order_items_list)
     # email_send.send_email(email, 'order_pickup.html')
     email.template = 'order_pickup.html'
     email_send.send_email_topic(email)