Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions app/api/helpers/payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,13 @@ def get_credentials(event=None):
"""
if not event:
settings = get_settings()
if settings['stripe_secret_key'] and settings["stripe_publishable_key"] and settings[
'stripe_secret_key'] != "" and \
settings["stripe_publishable_key"] != "":
if settings['app_environment'] == 'development' and settings['stripe_test_secret_key'] and \
settings['stripe_test_publishable_key']:
return {
'SECRET_KEY': settings['stripe_test_secret_key'],
'PUBLISHABLE_KEY': settings["stripe_test_publishable_key"]
}
elif settings['stripe_secret_key'] and settings["stripe_publishable_key"]:
return {
'SECRET_KEY': settings['stripe_secret_key'],
'PUBLISHABLE_KEY': settings["stripe_publishable_key"]
Expand Down
2 changes: 2 additions & 0 deletions app/api/schema/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ class Meta:
# Stripe Keys
stripe_client_id = fields.Str(allow_none=True)
stripe_publishable_key = fields.Str(allow_none=True)
stripe_test_secret_key = fields.Str(allow_none=True)
stripe_test_publishable_key = fields.Str(allow_none=True)

#
# Generators
Expand Down
2 changes: 2 additions & 0 deletions app/factories/setting.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ class Meta:
stripe_client_id = common.string_
stripe_secret_key = common.string_
stripe_publishable_key = common.string_
stripe_test_secret_key = common.string_
stripe_test_publishable_key = common.string_
# PayPal Credentials
paypal_mode = 'development'
paypal_client = common.string_
Expand Down
5 changes: 5 additions & 0 deletions app/models/setting.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ class Setting(db.Model):
stripe_client_id = db.Column(db.String)
stripe_secret_key = db.Column(db.String)
stripe_publishable_key = db.Column(db.String)
stripe_test_secret_key = db.Column(db.String)
stripe_test_publishable_key = db.Column(db.String)

# AliPay Keys - Stripe Sources
alipay_secret_key = db.Column(db.String)
Expand Down Expand Up @@ -183,6 +185,7 @@ def __init__(self,
fb_client_id=None, fb_client_secret=None, tw_consumer_key=None,
stripe_client_id=None,
stripe_secret_key=None, stripe_publishable_key=None,
stripe_test_secret_key=None, stripe_test_publishable_key=None,
in_client_id=None, in_client_secret=None,
tw_consumer_secret=None, sendgrid_key=None,
secret=None, storage_place=None,
Expand Down Expand Up @@ -271,6 +274,8 @@ def __init__(self,
self.stripe_client_id = stripe_client_id
self.stripe_publishable_key = stripe_publishable_key
self.stripe_secret_key = stripe_secret_key
self.stripe_test_publishable_key = stripe_test_publishable_key
self.stripe_test_secret_key = stripe_test_secret_key
self.web_app_url = web_app_url
self.android_app_url = android_app_url
self.email_service = email_service
Expand Down
30 changes: 30 additions & 0 deletions migrations/versions/rev-2019-08-07-01:11:29-f5c3a4fd23fb_.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""add stripe test keys

Revision ID: f5c3a4fd23fb
Revises: 4925dd5fd720
Create Date: 2019-08-07 01:11:29.736517

"""

from alembic import op
import sqlalchemy as sa
import sqlalchemy_utils


# revision identifiers, used by Alembic.
revision = 'f5c3a4fd23fb'
down_revision = '4925dd5fd720'


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('settings', sa.Column('stripe_test_publishable_key', sa.String(), nullable=True))
op.add_column('settings', sa.Column('stripe_test_secret_key', sa.String(), nullable=True))
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('settings', 'stripe_test_secret_key')
op.drop_column('settings', 'stripe_test_publishable_key')
# ### end Alembic commands ###