Repository: fossasia/open-event-server

Issue:
Addition of API keys for PayTM
**Feature Description**
Parent issue #6247 
Sub issue:
PayTM API keys require fields in the settings model.  Corresponding front-end fields will be added after this.



Discussion:
Issue-Label Bot is automatically applying the label `feature` to this issue, with a confidence of 0.97. Please mark this comment with :thumbsup: or :thumbsdown: to give our bot feedback! 

 Links: [app homepage](https://github.com/marketplace/issue-label-bot), [dashboard](https://mlbot.net/data/fossasia/open-event-server) and [code](https://github.com/hamelsmu/MLapp) for this bot.

Resolving patch:
diff --git a/app/api/schema/settings.py b/app/api/schema/settings.py
--- a/app/api/schema/settings.py
+++ b/app/api/schema/settings.py
@@ -58,6 +58,7 @@ class Meta:
     #
     # Online Payment Flags
     #
+    is_paytm_activated = fields.Bool(dump_only=True, allow_none=False, default=False)
     is_paypal_activated = fields.Bool(dump_only=True)
     is_stripe_activated = fields.Bool(dump_only=True)
     is_omise_activated = fields.Bool(dump_only=True)
@@ -185,6 +186,12 @@ class Meta:
     alipay_publishable_key = fields.Str(allow_none=True)
     alipay_secret_key = fields.Str(allow_none=True)
 
+    # payTM credentials
+    paytm_mode = fields.Str(allow_none=True)
+    paytm_live_merchant = fields.Str(allow_none=True)
+    paytm_live_secret = fields.Str(allow_none=True)
+    paytm_sandbox_merchant = fields.Str(allow_none=True)
+    paytm_sandbox_secret = fields.Str(allow_none=True)
     #
     # EMAIL
     #
diff --git a/app/models/setting.py b/app/models/setting.py
--- a/app/models/setting.py
+++ b/app/models/setting.py
@@ -104,6 +104,14 @@ class Setting(db.Model):
     omise_test_public = db.Column(db.String)
     omise_test_secret = db.Column(db.String)
 
+    # payTM credentials
+    is_paytm_activated = db.Column(db.Boolean, default=False, nullable=False)
+    paytm_mode = db.Column(db.String)
+    paytm_live_merchant = db.Column(db.String)
+    paytm_live_secret = db.Column(db.String)
+    paytm_sandbox_merchant = db.Column(db.String)
+    paytm_sandbox_secret = db.Column(db.String)
+
     #
     # EMAIL
     #
@@ -222,6 +230,12 @@ def __init__(self,
                  omise_live_secret=None,
                  alipay_publishable_key=None,
                  alipay_secret_key=None,
+                 is_paytm_activated=False,
+                 paytm_mode=None,
+                 paytm_live_merchant=None,
+                 paytm_live_secret=None,
+                 paytm_sandbox_merchant=None,
+                 paytm_sandbox_secret=None,
                  invoice_sending_day=None,
                  invoice_sending_timezone=None,
                  admin_billing_contact_name=None,
@@ -297,6 +311,7 @@ def __init__(self,
         self.paypal_sandbox_client = paypal_sandbox_client
         self.paypal_sandbox_secret = paypal_sandbox_secret
 
+
         # Omise Credentials
         self.omise_mode = omise_mode
         self.omise_test_public = omise_test_public
@@ -308,6 +323,14 @@ def __init__(self,
         self.alipay_publishable_key = alipay_publishable_key
         self.alipay_secret_key = alipay_secret_key
 
+        # payTM Credentials
+        self.is_paytm_activated = is_paytm_activated
+        self.paytm_mode = paytm_mode
+        self.paytm_live_merchant = paytm_live_merchant
+        self.paytm_live_secret = paytm_live_secret
+        self.paytm_sandbox_merchant = paytm_sandbox_merchant
+        self.paytm_sandbox_secret = paytm_sandbox_secret
+
         # Event Invoice settings
         self.invoice_sending_timezone = invoice_sending_timezone
         self.invoice_sending_day = invoice_sending_day
diff --git a/migrations/versions/rev-2019-08-09-19:41:03-246b5b6123af_.py b/migrations/versions/rev-2019-08-09-19:41:03-246b5b6123af_.py
new file mode 100644
--- /dev/null
+++ b/migrations/versions/rev-2019-08-09-19:41:03-246b5b6123af_.py
@@ -0,0 +1,37 @@
+"""empty message
+
+Revision ID: 246b5b6123af
+Revises: 9d5753192ac9
+Create Date: 2019-08-09 19:41:03.995657
+
+"""
+
+from alembic import op
+import sqlalchemy as sa
+import sqlalchemy_utils
+
+
+# revision identifiers, used by Alembic.
+revision = '246b5b6123af'
+down_revision = '9d5753192ac9'
+
+
+def upgrade():
+    # ### commands auto generated by Alembic - please adjust! ###
+    op.add_column('settings', sa.Column('paytm_live_merchant', sa.String(), nullable=True))
+    op.add_column('settings', sa.Column('paytm_live_secret', sa.String(), nullable=True))
+    op.add_column('settings', sa.Column('paytm_mode', sa.String(), nullable=True))
+    op.add_column('settings', sa.Column('paytm_sandbox_merchant', sa.String(), nullable=True))
+    op.add_column('settings', sa.Column('paytm_sandbox_secret', sa.String(), nullable=True))
+    op.add_column('settings', sa.Column('is_paytm_activated', sa.Boolean(), server_default='False', nullable=False))
+    # ### end Alembic commands ###
+
+
+def downgrade():
+    op.drop_column('settings', 'paytm_sandbox_secret')
+    op.drop_column('settings', 'paytm_sandbox_merchant')
+    op.drop_column('settings', 'paytm_mode')
+    op.drop_column('settings', 'paytm_live_secret')
+    op.drop_column('settings', 'paytm_live_merchant')
+    op.drop_column('settings', 'is_paytm_activated')
+    # ### end Alembic commands ###


Test patch: