Repository: fossasia/open-event-server

Issue:
Implement instructions for offline payments
Currently there are options in wizard step 1 for offline payments, but the are instructions are missing.
- [x] Please implement instructions that expand on activation of option as shown below.

![screenshot from 2016-08-20 15 51 31](https://cloud.githubusercontent.com/assets/1583873/17831627/50f0f248-66ee-11e6-83a6-09104a4c4393.png)
- [x] Offer example for cheque payment as shown below.

![screenshot from 2016-08-20 15 52 27](https://cloud.githubusercontent.com/assets/1583873/17831631/664190bc-66ee-11e6-90b1-b72d26030cef.png)
- [x] Offer to example for bank transfer as shown below.

![screenshot from 2016-08-20 15 51 59](https://cloud.githubusercontent.com/assets/1583873/17831637/8355ac92-66ee-11e6-85ec-9401e60cb9e1.png)
- [ ] On the registration page show offline payment instructions when chosen as in example below.

![screenshot-www eventnook com 2016-08-20 15-57-16](https://cloud.githubusercontent.com/assets/1583873/17831658/12ea980e-66ef-11e6-9c8a-050b5772959a.png)



Discussion:
@niranjan94 Can I help u with this if u dont mind :) ?

@aditya1702 sure :) .. Which part of this would you like to do ?

@niranjan94 I will start working on the first 3 points


Resolving patch:
diff --git a/app/helpers/ticketing.py b/app/helpers/ticketing.py
--- a/app/helpers/ticketing.py
+++ b/app/helpers/ticketing.py
@@ -25,6 +25,7 @@
 from app.models.event import Event
 from app.models.user_detail import UserDetail
 from app.models.discount_code import DiscountCode
+from sqlalchemy import or_
 
 from app.helpers.helpers import send_email_after_account_create_with_password
 
@@ -46,7 +47,7 @@ def get_orders_of_user(user_id=None, upcoming_events=True):
             user_id = login.current_user.id
         query = Order.query.join(Order.event) \
             .filter(Order.user_id == user_id) \
-            .filter(Order.status == 'completed')
+            .filter(or_(Order.status == 'completed', Order.status == 'placed'))
         if upcoming_events:
             return query.filter(Event.start_time >= datetime.now())
         else:
@@ -161,7 +162,7 @@ def get_discount_code(event_id, discount_code):
 
     @staticmethod
     def get_or_create_user_by_email(email, data=None):
-        user = DataGetter.get_user_by_email(email, False)
+        user = DataGetter.get_user_by_email(email, True)
         if not user:
             password = binascii.b2a_hex(os.urandom(4))
             user_data = [email, password]
@@ -191,7 +192,7 @@ def get_and_set_expiry(identifier, override=False):
 
         if order and not order.paid_via:
             if override \
-                or (order.status != 'completed' and
+                or (order.status != 'completed' and order.status != 'placed' and
                     (order.created_at + timedelta(
                                 minutes=TicketingManager.get_order_expiry())) < datetime.utcnow()):
                 order.status = 'expired'
@@ -238,7 +239,7 @@ def create_order(form, from_organizer=False):
         return order
 
     @staticmethod
-    def initiate_order_payment(form):
+    def initiate_order_payment(form, paid_via=None):
         identifier = form['identifier']
         email = form['email']
 
@@ -255,6 +256,9 @@ def initiate_order_payment(form):
                          and (order.paid_via == 'stripe'
                               or order.paid_via == 'paypal'))):
 
+                if paid_via:
+                    order.paid_via = paid_via
+
                 country = form['country']
                 address = form['address']
                 city = form['city']
@@ -265,7 +269,12 @@ def initiate_order_payment(form):
                 order.state = state
                 order.country = country
                 order.zipcode = zipcode
-                order.status = 'initialized'
+
+                if paid_via == 'transfer' or paid_via == 'onsite' or paid_via == 'cheque':
+                    order.status = 'placed'
+                else:
+                    order.status = 'initialized'
+
             else:
                 order.status = 'completed'
                 order.completed_at = datetime.utcnow()
diff --git a/app/views/public/ticketing.py b/app/views/public/ticketing.py
--- a/app/views/public/ticketing.py
+++ b/app/views/public/ticketing.py
@@ -33,7 +33,7 @@ def create_order(self):
     @expose('/<order_identifier>/', methods=('GET',))
     def view_order(self, order_identifier):
         order = TicketingManager.get_and_set_expiry(order_identifier)
-        if not order or order.status == 'expired':
+        if not order or order.status == 'expired' or order.status == 'placed':
             abort(404)
         if order.status == 'completed':
             return redirect(url_for('ticketing.view_order_after_payment', order_identifier=order_identifier))
@@ -50,7 +50,7 @@ def view_order(self, order_identifier):
     @expose('/<order_identifier>/view/', methods=('GET',))
     def view_order_after_payment(self, order_identifier):
         order = TicketingManager.get_and_set_expiry(order_identifier)
-        if not order or order.status != 'completed':
+        if not order or (order.status != 'completed' and order.status != 'placed'):
             abort(404)
         return self.render('/gentelella/guest/ticketing/order_post_payment.html', order=order, event=order.event)
 
@@ -81,13 +81,16 @@ def view_order_tickets_after_payment_pdf(self, order_identifier):
 
     @expose('/initiate/payment/', methods=('POST',))
     def initiate_order_payment(self):
-        result = TicketingManager.initiate_order_payment(request.form)
+        paid_via = request.form.get('pay_via_service', 'stripe')
+        result = TicketingManager.initiate_order_payment(request.form, paid_via)
         if result:
-            if request.form.get('pay_via_service', 'stripe') == 'stripe':
+            if request.form.get('pay_via_service', 'stripe') != 'paypal':
                 return jsonify({
                     "status": "ok",
                     "email": result.user.email,
-                    "action": "start_stripe" if result.status == 'initialized' else "show_completed"
+                    "action": "start_stripe"
+                    if result.status == 'initialized' and paid_via == 'stripe'
+                    else "show_completed"
                 })
             else:
                 return jsonify({


Test patch: