def __init__(self, *args, **kwargs):
     self.environment = kwargs.pop('environment')
     self.merchant_id = kwargs.pop('merchant_id')
     self.private_key = kwargs.pop('private_key')
     self.public_key = kwargs.pop('public_key')
     self.apple_pay_display_name = kwargs.pop('apple_pay_display_name', '')
     self.google_pay_merchant_id = kwargs.pop('google_pay_merchant_id', '')
     self.submit_for_settlement = kwargs.pop('submit_for_settlement', True)
     self.paypal_flow = kwargs.pop('paypal_flow', '')
     self.gateway = BraintreeGateway(
         Configuration(
             (Environment.Sandbox
              if self.environment == 'sandbox' else Environment.Production),
             merchant_id=self.merchant_id,
             public_key=self.public_key,
             private_key=self.private_key,
         ))
     super(BraintreeDropinProvider, self).__init__(*args, **kwargs)
Example #2
0
 def capture_payment(self, testing=False, order=None, amount=None):
     """Process payments without an authorization step."""
     braintree_settings = config_get_group('PAYMENT_SATCHMO_BRAINTREE')
     
     # Configure Braintree
     Configuration.configure(
         Environment.Production if django_settings.IS_PROD else Environment.Sandbox,
         braintree_settings.MERCHANT_ID.value,
         braintree_settings.PUBLIC_KEY.value,
         braintree_settings.PRIVATE_KEY.value
     )
     
     if order:
         self.prepare_data(order)
     else:
         order = self.order
     
     if order.paid_in_full:
         self.log_extra('%s is paid in full, no capture attempted.', order)
         results = ProcessorResult(self.key, True, _("No charge needed, paid in full."))
         self.record_payment()
     else:
         self.log_extra('Capturing payment for %s', order)
         amount = order.balance
         
         result = Transaction.sale({
             "amount": amount,
             # "order_id": "123",
             "credit_card": {
                 "number": order.credit_card.decryptedCC,
                 "expiration_date": order.credit_card.expirationDate,    # 05/2012 ?
                 "cvv": order.credit_card.ccv
             },
             "customer": {
                 "first_name": order.contact.first_name,
                 "last_name": order.contact.last_name,
                 "email": order.contact.email,
             },
             "billing": {
                 "first_name": order.contact.first_name,
                 "last_name": order.contact.last_name,
                 "street_address": order.full_bill_street,
                 "locality": order.bill_city,
                 "region": order.bill_state,
                 "postal_code": order.bill_postal_code,
             },
             "options": {
                 "submit_for_settlement": True
             }
         })
         
         if result.is_success:
             payment = self.record_authorization(order=order, amount=amount, transaction_id=result.transaction.id)
             response_text = 'Success'
         else:
             response_text = ''
             for error in result.errors.deep_errors:
                 if response_text != '':
                     response_text += ', %s' % error.message
                 else:
                     response_text = error.message
             payment = self.record_failure(amount=amount)
         
         return ProcessorResult(self.key, result.is_success, response_text, payment=payment)
         # standard = self.get_standard_charge_data(amount=amount)
         # results = self.send_post(standard, testing)
     
     return results
Example #3
0
STATIC_ROOT = (os.path.join(BASE_DIR, 'static'), )

MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media/')

AUTH_USER_MODEL = 'accounts.User'  # Переопредєляєм стандартного юзера

# Ключ, по которому храним данные корзины в сессии
CART_SESSION_ID = 'cart'

EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'

# Настройки Braintree (сервис оплаты).
BRAINTREE_MERCHANT_ID = 'XXX'  # ID продавца.
BRAINTREE_PUBLIC_KEY = 'XXX'  # Публичный ключ.
BRAINTREE_PRIVATE_KEY = 'XXX'  # Секретный ключ.

from braintree import Configuration, Environment

Configuration.configure(
    Environment.Sandbox,  # Для разработки. Перед продакшеном удалить.
    # Environment.Production,  # Для продакшена расскоментировать.
    BRAINTREE_MERCHANT_ID,
    BRAINTREE_PUBLIC_KEY,
    BRAINTREE_PRIVATE_KEY)

#  Настройки redis(для рекомендации товаров).
REDIS_HOST = 'localhost'
REDIS_PORT = 6379
REDIS_DB = 1
Example #4
0
USE_TZ = True

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.2/howto/static-files/

STATIC_URL = '/static/'

STATIC_ROOT = os.path.join(BASE_DIR, "shop/static/")

MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media/')

EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'

# BRAINTREE PAYMENT GATEWAY CONFIGURATION.
BRAINTREE_MERCHANT_ID = secrets.BRAINTREE_MERCHANT_ID
BRAINTREE_PUBLIC_KEY = secrets.BRAINTREE_PUBLIC_KEY
BRAINTREE_PRIVATE_KEY = secrets.BRAINTREE_PRIVATE_KEY

Configuration.configure(
    Environment.
    Sandbox,  # when you go live change this to Environment.Production
    BRAINTREE_MERCHANT_ID,
    BRAINTREE_PUBLIC_KEY,
    BRAINTREE_PRIVATE_KEY)

# REDIS CONFIGURATION.
REDIS_HOST = 'localhost'
REDIS_PORT = 6379
REDIS_DB = 1
Example #5
0
        'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',
        'LOCATION': '/var/tmp/django_cache',
        'TIMEOUT': 60 * 60,
        'OPTIONS': {
            'MAX_ENTRIES': 10000
        }
    }
}

BRAINTREE_MERCHANT_ID = 'YOUR_BT_MERCH_ID'
BRAINTREE_PUBLIC_KEY = 'YOUR_BT_PUBLIC_KEY'
BRAINTREE_PRIVATE_KEY = 'YOUR_BT_PRIVATE_KEY'
from braintree import Configuration, Environment

Configuration.configure(
    Environment.Production if IS_PROD else Environment.Sandbox,
    BRAINTREE_MERCHANT_ID, BRAINTREE_PUBLIC_KEY, BRAINTREE_PRIVATE_KEY)

# If your django's version is 1.2, you must config the cache like below,
# and make sure the directory exists and is readable and writable by the user apache.
CACHE_BACKEND = 'file:///var/tmp/django_cache'

AWS_ACCESS_KEY_ID = None
AWS_SECRET_ACCESS_KEY = None
S3_BUCKET_NAME = None

# Forced language setting, if you configure this value, the system will display messages/page by using this language.
#   Default: en-us
# If you configure this value, you must provide files:
#   1.JS language package file "l10n_[FORCED_LANGUAGE_CODE].js" in the directory MHLogin/media/js/localization
FORCED_LANGUAGE_CODE = 'en-us'
Example #6
0
from customers.models import Profile
from django.contrib.auth.models import User
from utilities.format import json_response


# Sandbox API Keys
API_KEYS = {
	'merchant_id':	'qymc7fr9ct6xbd9x',
	'public_key': '8d9g5rg8jsm4r2qm',
	'private_key': '7d88960a48e944ee76f511ae4f25e1ff',
	'cse_key': 'MIIBCgKCAQEAttvzhxtNmLlSJ0nPLwrwOrdtvU8sYVnVG3LYQrgMOI1WOY3J7Crsr1/LHrAVMrIr/IakrU9ChHPVHx33Wyg5czkx3QGEvMO2mme7Kcn2isQbTtowoc05c9qabuRTQR05BMnmUDb1bjZjdUaWXhqgSJgrycBGh1fdc5K1e048J8kaAZPPstntwGdg0CwJy45gNHGotjK02hTnEDDS4qdc5IWcSvPziusP8WG69PIYxqBgFyL9A3DOI25etr6S9l6wIRC63F12dmkqG89PsLIOKelzAHBiEp4B8nlcOsMA+BRG0QZ1ZKNLqkxf883QpE929wwZIeDY8QaiAAcCrbUosQIDAQAB',
}

Configuration.configure(
	Environment.Sandbox,
	API_KEYS['merchant_id'],
	API_KEYS['public_key'],
	API_KEYS['private_key']
)


def create_customer(user=None):
	"""
	创建一个braintree.Customer对象
	@user: Braintree支持使用自己的 ID 作为客户 ID, 所以这里使用User的 id 作为customer_id来创建用户,不使用email的原因是braintree不支持使用@符号
	@return: 返回customer_id
	"""
	pass


def get_client_token(user=None):
	"""
Example #7
0
STATIC_ROOT = os.path.join(BASE_DIR, 'static/')
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media/')

CART_SESSION_ID = 'cart'

#EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'

# Braintree settings
BRAINTREE_MERCHANT_ID = 'mnxfy2xrfcpmb7r5'  # Merchant ID
BRAINTREE_PUBLIC_KEY = 'dzx5k3ctrcc4x3j8'  # Public Key
BRAINTREE_PRIVATE_KEY = 'a8089285c0cc993746706fcd950295a9'  # Private key

from braintree import Configuration, Environment

Configuration.configure(
    # configurar a Production cuando se publique
    Environment.Sandbox,
    BRAINTREE_MERCHANT_ID,
    BRAINTREE_PUBLIC_KEY,
    BRAINTREE_PRIVATE_KEY)

# messages directory
LOCALE_PATHS = (os.path.join(BASE_DIR, 'locale/'), )

# SMTP
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = '******'
EMAIL_HOST_PASSWORD = '******'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
Example #8
0
    'south',
    'django_common',
    "django_braintree",
    
    
)

BRAINTREE_MERCHANT = 'zyr39d95p83gcf6z'
BRAINTREE_PUBLIC_KEY = '5tzg943xmcc24jgd'
BRAINTREE_PRIVATE_KEY = 'fb2ca740b92bcc832abeecaf9de63922'

from braintree import Configuration, Environment

Configuration.configure(
    Environment.Sandbox,
    BRAINTREE_MERCHANT,
    BRAINTREE_PUBLIC_KEY,
    BRAINTREE_PRIVATE_KEY
)
    # Uncomment the next line to enable the admin:
    # 'django.contrib.admin',
    # Uncomment the next line to enable admin documentation:
    # 'django.contrib.admindocs',

# A sample logging configuration. The only tangible logging
# performed by this configuration is to send an email to
# the site admins on every HTTP 500 error when DEBUG=False.
# See http://docs.djangoproject.com/en/dev/topics/logging for
# more details on how to customize your logging configuration.
LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
Example #9
0
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static/')

MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media/')

CART_SESSION_ID = 'cart'

# CELERY_ALWAYS_EAGER позволит вам выполнять асинхронные задачи локально в
# синхронном режиме вместо отправки их в очередь. Это бывает полезно для
# запуска юнит-тестов или запуска приложения локально без установки Celery.

EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'

BRAINTREE_MERCHANT_ID = 'vfs246n6j2c42z69'
BRAINTREE_PUBLIC_KEY = '9d24xf2p42qgtw22'
BRAINTREE_PRIVATE_KEY = 'd6db579303b1a8dd236fc62311da3538'

from braintree import Configuration, Environment

Configuration.configure(
    Environment.Sandbox,  # for production, use Environment.Production
    BRAINTREE_MERCHANT_ID,
    BRAINTREE_PUBLIC_KEY,
    BRAINTREE_PRIVATE_KEY)

REDIS_HOST = 'localhost'
REDIS_PORT = 6379
REDIS_DB = 1
Example #10
0
    def capture_payment(self, testing=False, order=None, amount=None):
        """Process payments without an authorization step."""
        if braintree_wrapper_server:
            transaction_sale = braintree_wrapper_server._sale_transaction
        else:
            braintree_settings = config_get_group('PAYMENT_SATCHMO_BRAINTREE')

            # Configure Braintree
            Configuration.configure(
                Environment.Production
                if getattr(django_settings, 'IS_PROD', False) else
                Environment.Sandbox, braintree_settings.MERCHANT_ID.value,
                braintree_settings.PUBLIC_KEY.value,
                braintree_settings.PRIVATE_KEY.value)

            transaction_sale = Transaction.sale

        if order:
            self.prepare_data(order)
        else:
            order = self.order

        if order.paid_in_full:
            self.log_extra('%s is paid in full, no capture attempted.', order)
            results = ProcessorResult(self.key, True,
                                      _("No charge needed, paid in full."))
            self.record_payment()
        else:
            self.log_extra('Capturing payment for %s', order)
            amount = order.balance
            if braintree_wrapper_server:
                data = {}
            else:
                data = {
                    "amount": amount,
                    # "order_id": "123",
                    "credit_card": {
                        "number": order.credit_card.decryptedCC,
                        "expiration_date":
                        order.credit_card.expirationDate,  # 05/2012 ?
                        "cvv": order.credit_card.ccv
                    },
                    "customer": {
                        "first_name": order.contact.first_name,
                        "last_name": order.contact.last_name,
                    },
                    "billing": {
                        "first_name": order.contact.first_name,
                        "last_name": order.contact.last_name,
                        "street_address": order.full_bill_street,
                        "locality": order.bill_city,
                        "region": order.bill_state,
                        "postal_code": order.bill_postal_code,
                    },
                    "options": {
                        "submit_for_settlement": True
                    }
                }
            signals.satcho_braintree_order_validate.send(sender=self,
                                                         data=data,
                                                         order=order)

            result = transaction_sale(data)

            if result.is_success:
                payment = self.record_authorization(
                    order=order,
                    amount=amount,
                    transaction_id=result.transaction.id)
                response_text = 'Success'
            else:
                response_text = ''
                for error in result.errors.deep_errors:
                    response_text += '%s ' % error.message
                payment = self.record_failure(amount=amount)

            return ProcessorResult(self.key,
                                   result.is_success,
                                   response_text,
                                   payment=payment)
            # standard = self.get_standard_charge_data(amount=amount)
            # results = self.send_post(standard, testing)

        return results
Example #11
0
USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.0/howto/static-files/

STATIC_URL = '/static/'
STATIC_ROOT= os.path.join(BASE_DIR, 'static/')
MEDIA_URL='/media/'
MEDIA_ROOT=os.path.join(BASE_DIR, 'media/')
CART_SESSION_ID='cart'

CELERY_BROKER_URL= "redis://localhost:6379/0"

BRAINTREE_MERCHANT_ID = 'phvg3b2rz4k7jwqy'
BRAINTREE_PUBLIC_KEY = 'kf84mmg2cf4x3fk5'
BRAINTREE_PRIVATE_KEY = '5efd1f609a3fa90e212632f0838680e8'


GATEWAY = BraintreeGateway(
Configuration(
    braintree.Environment.Sandbox,
    BRAINTREE_MERCHANT_ID,
    BRAINTREE_PUBLIC_KEY,
    BRAINTREE_PRIVATE_KEY
))
Example #12
0
# EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'

# There're more options here (not only these five)
EMAIL_HOST = EMAIL_HOST
EMAIL_HOST_USER = EMAIL_HOST_USER
EMAIL_HOST_PASSWORD = EMAIL_HOST_PASSWORD
EMAIL_PORT = 587
EMAIL_USE_TLS = True

# Recommendation engine related
REDIS_HOST = 'localhost'
REDIS_PORT = 6379
REDIS_DB = 1

# Braintree settings
#   here: https://www.braintreegateway.com

BRAINTREE_MERCHANT_ID = BRT_MERCHANT_ID
BRAINTREE_PUBLIC_KEY = BRT_PUBLIC_KEY
BRAINTREE_PRIVATE_KEY = BRT_PRIVATE_KEY

Configuration.configure(
    # There's another option 'Production'
    #   Also, it's OKAY that we don't get a auto-completion here :P
    Environment.Sandbox,
    BRAINTREE_MERCHANT_ID,
    BRAINTREE_PUBLIC_KEY,
    BRAINTREE_PRIVATE_KEY,
)
Example #13
0
USE_I18N = True

USE_L10N = True

USE_TZ = True

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.1/howto/static-files/

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static/')

MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media/')

CART_SESSION_ID = 'cart'

EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'

# Настройки Braintree
BRAINTREE_MERCHANT_ID = '********'  # ID продавца
BRAINTREE_PUBLIC_KEY = '********'  # Публичный ключ
BRAINTREE_PRIVATE_KEY = '********'  # Секретный ключ

Configuration.configure(
    Environment.Sandbox,  # при публикации приложения, необходимо заменить на Environment.Production
    BRAINTREE_MERCHANT_ID,
    BRAINTREE_PUBLIC_KEY,
    BRAINTREE_PRIVATE_KEY
)
Example #14
0
    def capture_payment(self, testing=False, order=None, amount=None):
        """Process payments without an authorization step."""
        if braintree_wrapper_server:
            transaction_sale = braintree_wrapper_server._sale_transaction
        else:
            braintree_settings = config_get_group("PAYMENT_SATCHMO_BRAINTREE")

            # Configure Braintree
            Configuration.configure(
                Environment.Production if getattr(django_settings, "IS_PROD", False) else Environment.Sandbox,
                braintree_settings.MERCHANT_ID.value,
                braintree_settings.PUBLIC_KEY.value,
                braintree_settings.PRIVATE_KEY.value,
            )

            transaction_sale = Transaction.sale

        if order:
            self.prepare_data(order)
        else:
            order = self.order

        if order.paid_in_full:
            self.log_extra("%s is paid in full, no capture attempted.", order)
            results = ProcessorResult(self.key, True, _("No charge needed, paid in full."))
            self.record_payment()
        else:
            self.log_extra("Capturing payment for %s", order)
            amount = order.balance
            if braintree_wrapper_server:
                data = {}
            else:
                data = {
                    "amount": amount,
                    # "order_id": "123",
                    "credit_card": {
                        "number": order.credit_card.decryptedCC,
                        "expiration_date": order.credit_card.expirationDate,  # 05/2012 ?
                        "cvv": order.credit_card.ccv,
                    },
                    "customer": {"first_name": order.contact.first_name, "last_name": order.contact.last_name},
                    "billing": {
                        "first_name": order.contact.first_name,
                        "last_name": order.contact.last_name,
                        "street_address": order.full_bill_street,
                        "locality": order.bill_city,
                        "region": order.bill_state,
                        "postal_code": order.bill_postal_code,
                    },
                    "options": {"submit_for_settlement": True},
                }
            signals.satcho_braintree_order_validate.send(sender=self, data=data, order=order)

            result = transaction_sale(data)

            if result.is_success:
                payment = self.record_authorization(order=order, amount=amount, transaction_id=result.transaction.id)
                response_text = "Success"
            else:
                response_text = ""
                for error in result.errors.deep_errors:
                    response_text += "%s " % error.message
                payment = self.record_failure(amount=amount)

            return ProcessorResult(self.key, result.is_success, response_text, payment=payment)
            # standard = self.get_standard_charge_data(amount=amount)
            # results = self.send_post(standard, testing)

        return results
Example #15
0
USE_I18N = True

USE_L10N = True

USE_TZ = True

CART_SESSION_ID = 'cart'

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.0/howto/static-files/

STATIC_URL = '/static/'

MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media/')

# email configs

EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_HOST_USER = os.getenv('EMAIL_HOST_USER')
EMAIL_HOST_PASSWORD = os.getenv('EMAIL_HOST_PASSWORD')
EMAIL_USE_TLS = True

# Braintree settings
Configuration.configure(Environment.Sandbox,
                        os.getenv('BRAINTREE_MERCHANT_ID'),
                        os.getenv('BRAINTREE_PUBLIC_KEY'),
                        os.getenv('BRAINTREE_PRIVATE_KEY'))
Example #16
0
from braintree import BraintreeGateway, Configuration, Environment
import os
from flask import Flask, render_template, request, redirect

gateway = BraintreeGateway(
    Configuration(Environment.Sandbox,
                  merchant_id=os.getenv("ID"),
                  public_key=os.getenv("KEY"),
                  private_key=os.getenv("SECRET")))

app = Flask(__name__)


@app.route("/")
def home():
    return render_template("index.html", token=gateway.client_token.generate())


@app.route("/pay", methods=["POST"])
def pay():
    gateway.transaction.sale({
        "amount": "100.00",
        "payment_method_nonce": request.form['nonce'],
        "options": {
            "submit_for_settlement": True
        }
    })
    return redirect(url_for('home'))


if __name__ == "__main__":
Example #17
0
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/dev/howto/static-files/

STATIC_URL = '/static/'

MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media/')


CART_SESSION_ID = 'cart'

EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'


# Braintree settings
BRAINTREE_MERCHANT_ID = ''
BRAINTREE_PUBLIC_KEY = ''
BRAINTREE_PRIVATE_KEY = ''

from braintree import Configuration, Environment

Configuration.configure(
    Environment.Sandbox,
    # Environment.Production,
    BRAINTREE_MERCHANT_ID,
    BRAINTREE_PUBLIC_KEY,
    BRAINTREE_PRIVATE_KEY
)

STATIC_ROOT = os.path.join(BASE_DIR, 'static/')
Example #18
0
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')

MEDIA_URL = '/media/'  # this is our local path where our media located
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')

CART_SESSION_ID = 'cart'
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'

BRAINTREE_MERCHANT_ID = os.environ.get('Merchant ID')
BRAINTREE_PUBLIC_KEY = os.environ.get('Public Key')
BRAINTREE_PRIVATE_KEY = os.environ.get('Private Key')

Configuration.configure(Environment.Sandbox,
                        merchant_id=BRAINTREE_MERCHANT_ID,
                        private_key=BRAINTREE_PRIVATE_KEY,
                        public_key=BRAINTREE_PUBLIC_KEY)

# mimetypes.add_type("text/css", ".css", True)

LOCALE_PATHS = [
    os.path.join(BASE_DIR, 'locale'),
]

INTERNAL_IPS = [
    # ...
    '127.0.0.1',
    # ...
]
Example #19
0
TIME_ZONE = "UTC"

USE_I18N = True

USE_L10N = True

USE_TZ = True

EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.0/howto/static-files/

STATIC_URL = "/static/"
STATIC_ROOT = os.path.join(BASE_DIR, "static/")

MEDIA_URL = "/media/"
MEDIA_ROOT = os.path.join(BASE_DIR, "media/")

CART_SESSION_ID = "cart"

from braintree import Configuration, Environment

Configuration.configure(
    Environment.Sandbox,
    "2ds4s376x79cgszr",
    "zsfg6yhgcw6rjrsp",
    "5eba8a1a893fe96291a36bd1ff1dac1d",
)
Example #20
0
CART_SESSION_ID = 'cart'

LOGIN_REDIRECT_URL = 'shop:product_list'
LOGOUT_REDIRECT_URL = 'shop:product_list'
LOGIN_URL = 'shop:login'
LOGOUT_URL = 'shop:logout'

EMAIL_HOST = 'smtp.163.com'
EMAIL_HOST_USER = '******'  # 填写你的邮件地址
EMAIL_HOST_PASSWORD = '******'  # 邮箱的smtp授权码
EMAIL_PORT = 25
EMAIL_USE_TLS = True
DEFAULT_FROM_EMAIL = EMAIL_HOST_USER

# Braintree settings
BRAINTREE_MERCHANT_ID = '7v2bydr3s3v67wtp'
BRAINTREE_PUBLIC_KEY = 'dtdb8tbrg8z9th6x'
BRAINTREE_PRIVATE_KEY = 'ac32671a82d394d1d314aa6a3ff54223'

Configuration.configure(
    Environment.parse_environment("sandbox"),
    # Environment.parse_environment("product"),
    BRAINTREE_MERCHANT_ID,
    BRAINTREE_PUBLIC_KEY,
    BRAINTREE_PRIVATE_KEY)

REDIS_HOST = '222.25.2.37'
REDIS_PORT = 6379
REDIS_DB = 1
Example #21
0
PROJECT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
BASE_DIR = os.path.dirname(PROJECT_DIR)

AUTH_USER_MODEL = "accounts.User"

CART_SESSION_ID = "cart"

# Braintree settings
BRAINTREE_MERCHANT_ID = os.getenv("BRAINTREE_MERCHANT_ID")
BRAINTREE_PUBLIC_KEY = os.getenv("BRAINTREE_PUBLIC_KEY")
BRAINTREE_PRIVATE_KEY = os.getenv("BRAINTREE_PRIVATE_KEY")

BraintreeConfiguration.configure(
    BraintreeEnvironment.Sandbox,
    BRAINTREE_MERCHANT_ID,
    BRAINTREE_PUBLIC_KEY,
    BRAINTREE_PRIVATE_KEY,
)

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/

# Application definition

INSTALLED_APPS = [
    "accounts",
    "cart",
    "community",
    "contact",
    "events",
    "facets",
import os
from braintree import BraintreeGateway, Configuration, Environment
from flask import Blueprint, render_template, redirect, request, url_for, flash, Flask
from models.image import Image
from models.user import User
from models.donate import Donate
from flask_login import login_required, current_user

donations_blueprint = Blueprint('donations',
                                __name__,
                                template_folder='templates')

gateway = BraintreeGateway(
    Configuration(Environment.Sandbox,
                  merchant_id=os.getenv("BT_MERCHANT_ID"),
                  public_key=os.getenv("BT_PUBLIC_KEY"),
                  private_key=os.getenv("BT_PRIVATE_KEY")))


@donations_blueprint.route("/<id>/new")
@login_required
def new(id):
    token = gateway.client_token.generate()
    return render_template("donations/new.html", token=token, image_id=id)


@donations_blueprint.route("/<id>/pay", methods=["POST"])
@login_required
def pay(id):
    donation = Donate.create(user_id=current_user.id,
                             image_id=id,
Example #23
0
USE_I18N = True

USE_L10N = True

USE_TZ = True

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/dev/howto/static-files/

STATIC_URL = '/static/'

MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media/')

CART_SESSION_ID = 'cart'

# Braintree settings - replace with your credentials after signing up for braintree account
BRAINTREE_MERCHANT_ID = 'Merchant ID'  # Merchant ID
BRAINTREE_PUBLIC_KEY = 'Public Key'  # Public Key
BRAINTREE_PRIVATE_KEY = 'Private key'  # Private key

Configuration.configure(Environment.Sandbox, BRAINTREE_MERCHANT_ID,
                        BRAINTREE_PUBLIC_KEY, BRAINTREE_PRIVATE_KEY)

STATIC_ROOT = os.path.join(BASE_DIR, 'static/')

AUTH_USER_MODEL = 'users.CustomUser'

LOGIN_REDIRECT_URL = 'home'
LOGOUT_REDIRECT_URL = 'home'
Example #24
0
USE_L10N = True

USE_TZ = True

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.1/howto/static-files/

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static/')

MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media/')

CART_SESSION_ID = 'cart'

# EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'

EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = config('EMAIL_USER')
EMAIL_HOST_PASSWORD = config('EMAIL_PASSWORD')
EMAIL_PORT = 587
EMAIL_USE_TLS = True

BROKER_URL = 'amqp://localhost'

Configuration.configure(
    Environment.Sandbox,  # При продакшене заменить на Environment.Production
    config('BRAINTREE_MERCHANT_ID'),
    config('BRAINTREE_PUBLIC_KEY'),
    config('BRAINTREE_PRIVATE_KEY'))