当前位置: 首页>>代码示例>>Python>>正文


Python stripe.api_key方法代码示例

本文整理汇总了Python中stripe.api_key方法的典型用法代码示例。如果您正苦于以下问题:Python stripe.api_key方法的具体用法?Python stripe.api_key怎么用?Python stripe.api_key使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在stripe的用法示例。


在下文中一共展示了stripe.api_key方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create_for_customer

# 需要导入模块: import stripe [as 别名]
# 或者: from stripe import api_key [as 别名]
def create_for_customer(self, customer, book, trial_period_days=0, quantity=1, paid_until=None):
        if not paid_until and trial_period_days > 0:
            paid_until = timezone.now() + timedelta(days=trial_period_days)
        if paid_until and trial_period_days < 1 and paid_until > timezone.now():
            trial_period_days = (paid_until - timezone.now()).days
        stripe.api_key = settings.STRIPE_SECRET_KEY
        return stripe.Subscription.create(
            trial_period_days=trial_period_days,
            plan='monthly_2017_03',
            customer=customer.stripe_id,
            # quantity=quantity,
        )
        return self.create(
            customer=customer,
            is_active=True,
            paid_until=paid_until,
            book=book,
        ) 
开发者ID:phildini,项目名称:logtacts,代码行数:20,代码来源:models.py

示例2: _update_membership

# 需要导入模块: import stripe [as 别名]
# 或者: from stripe import api_key [as 别名]
def _update_membership(self, membership_change):
        stripe.api_key = os.environ['STRIPE_PRIVATE_KEY']
        active_membership = self._get_active_membership()
        if membership_change['membership_type'] is None:
            self._cancel_membership(active_membership)
        elif membership_change['new_membership']:
            if active_membership is None:
                self._add_membership(membership_change, active_membership)
            else:
                raise ValidationError(
                    'new membership requested for account with active '
                    'membership'
                )
        else:
            if active_membership is None:
                raise ValidationError(
                    'membership change requested for account with no '
                    'active membership'
                )
            else:
                self._cancel_membership(active_membership)
                self._add_membership(membership_change, active_membership) 
开发者ID:MycroftAI,项目名称:selene-backend,代码行数:24,代码来源:account.py

示例3: setUp

# 需要导入模块: import stripe [as 别名]
# 或者: from stripe import api_key [as 别名]
def setUp(self):
    super(StripeTest, self).setUp()
    stripe_lib.api_key = "sk_test_sm4iLzUFCeEE4l8uKe4KNDU7"
    self.pledge = dict(
      email='pika@pokedex.biz',
      phone='212-234-5432',
      name=u'Pik\u00E1 Chu',
      occupation=u'Pok\u00E9mon',
      employer='Nintendo',
      target='Republicans Only',
      subscribe=True,
      amountCents=4200,
      pledgeType='CONDITIONAL',
      team='rocket',
      thank_you_sent_at=None,
      payment=dict(
        STRIPE=dict(
        )
      )) 
开发者ID:MayOneUS,项目名称:pledgeservice,代码行数:21,代码来源:test_e2e.py

示例4: CreateCustomerWithPlan

# 需要导入模块: import stripe [as 别名]
# 或者: from stripe import api_key [as 别名]
def CreateCustomerWithPlan(self, email, card_token, amount_dollars,
    recurrence_period):
    stripe.api_key = self.stripe_private_key
    if recurrence_period == "monthly":
      plan = "one_dollar_monthly"
    elif recurrence_period == "weekly":
      plan = "one_dollar_weekly"
    else:
      plan = "one_dollar_monthly"
      
    customer = stripe.Customer.create(
      card=card_token,
      email=email,
      plan=plan,
      quantity=amount_dollars
    )

    return customer 
开发者ID:MayOneUS,项目名称:pledgeservice,代码行数:20,代码来源:env.py

示例5: init_app

# 需要导入模块: import stripe [as 别名]
# 或者: from stripe import api_key [as 别名]
def init_app(self, app):
        billing_type = app.config.get("BILLING_TYPE", "FakeStripe")

        if billing_type == "Stripe":
            billing = stripe
            stripe.api_key = app.config.get("STRIPE_SECRET_KEY", None)

        elif billing_type == "FakeStripe":
            billing = FakeStripe

        else:
            raise RuntimeError("Unknown billing type: %s" % billing_type)

        # register extension with app
        app.extensions = getattr(app, "extensions", {})
        app.extensions["billing"] = billing
        return billing 
开发者ID:quay,项目名称:quay,代码行数:19,代码来源:billing.py

示例6: main

# 需要导入模块: import stripe [as 别名]
# 或者: from stripe import api_key [as 别名]
def main(opts, args):
    if len(args) == 0:
        sys.exit("Need to specify a relative path to the script you want to run.")

    script_path = args[0]
    if not script_path.endswith('.py'):
        sys.exit("You can only reference python scripts that end with a .py extension.")

    mltshpoptions.parse_dictionary(getattr(settings, opts.settings))

    # if a server argument was specified and doesn't match with the
    # server_id configured for settings, then exit silently
    # without running
    if opts.server_id and opts.server_id != options.server_id:
        exit(0)

    lib.flyingcow.register_connection(host=options.database_host,
        name=options.database_name, user=options.database_user,
        password=options.database_password)    

    if options.stripe_secret_key:
        stripe.api_key = options.stripe_secret_key

    run(script_path) 
开发者ID:MLTSHP,项目名称:mltshp,代码行数:26,代码来源:runner.py

示例7: main

# 需要导入模块: import stripe [as 别名]
# 或者: from stripe import api_key [as 别名]
def main():
    stripe.api_key = get_env_variable("STRIPE_TEST_KEY")
    plans = stripe.Plan.list()
    stripe.api_key = get_env_variable("STRIPE_LIVE_KEY")
    for plan in plans['data']:
        try:
            plan = stripe.Plan.retrieve(plan['id'])
            print("Plan {} already exists on LIVE".format(plan['id']))
        except stripe.error.InvalidRequestError:
            stripe.Plan.create(
                id=plan['id'],
                amount=plan['amount'],
                currency=plan['currency'],
                interval=plan['interval'],
                name=plan['name'],
            )
            print("Plan {} created on LIVE".format(plan['id']))
    print("Job done") 
开发者ID:phildini,项目名称:logtacts,代码行数:20,代码来源:sync_stripe_plans.py

示例8: donation_endpoint

# 需要导入模块: import stripe [as 别名]
# 或者: from stripe import api_key [as 别名]
def donation_endpoint():
    stripe.api_key = os.getenv("STRIPE_API_KEY")
    metadata = {
        "full_name": request.json["fullName"],
        "orcid_id": request.json["orcidId"],
        "email": request.json["email"]
    }
    try:
        stripe.Charge.create(
            amount=request.json["cents"],
            currency="usd",
            source=request.json["tokenId"],
            description="Impactstory donation",
            metadata=metadata
        )
    except stripe.error.CardError, e:
        # The card has been declined
        abort_json(499, "Sorry, your credit card was declined.") 
开发者ID:ourresearch,项目名称:impactstory-tng,代码行数:20,代码来源:views.py

示例9: reset_api_key

# 需要导入模块: import stripe [as 别名]
# 或者: from stripe import api_key [as 别名]
def reset_api_key():
    """Resets the API key for an account"""

    from library.mailer import email_api_key_change
    from datetime import datetime

    account_id = Account.authorize(request.values.get('api_key'))
    if not account_id:
        return jsonify(api_error('API_UNAUTHORIZED')), 401

    account = Account.query.get(account_id)
    if account.password != password_hash(request.values.get('password')):
        return jsonify(api_error('ACCOUNTS_LOGIN_ERROR')), 401

    account.api_key = random_hash("%s%s" % (account.email, account.password))
    account.mod_date = datetime.now()
    db.session.commit()

    email_api_key_change(account)

    return jsonify({
        'api_key': account.api_key
    }) 
开发者ID:lyonbros,项目名称:faxrobot,代码行数:25,代码来源:accounts.py

示例10: transactions

# 需要导入模块: import stripe [as 别名]
# 或者: from stripe import api_key [as 别名]
def transactions():
    """List transactions"""

    v = request.values.get

    page = int(v('page', 1))

    account_id = Account.authorize(v('api_key'))
    if not account_id:
        return jsonify(api_error('API_UNAUTHORIZED')), 401

    account = Account.query.get(account_id)

    res = Transaction.query.filter_by(account_id= account_id)
    res = res.order_by(Transaction.create_date.desc()).paginate(page, 15, False)

    return jsonify({
        'page':         res.page,
        'pages':        res.pages,
        'per_page':     res.per_page,
        'total':        res.total,
        'has_next':     res.has_next,
        'has_prev':     res.has_prev,
        'transactions': [trans.public_data() for trans in res.items]
    }) 
开发者ID:lyonbros,项目名称:faxrobot,代码行数:27,代码来源:accounts.py

示例11: deprovision

# 需要导入模块: import stripe [as 别名]
# 或者: from stripe import api_key [as 别名]
def deprovision():
    """Derovision a Phaxio fax number"""

    from library.mailer import email_registration

    ip = fix_ip(request.headers.get('x-forwarded-for', request.remote_addr))

    account_id = Account.authorize(request.values.get('api_key'))
    if account_id == None:
        return jsonify(api_error('API_UNAUTHORIZED')), 401

    account = Account.query.get(account_id)

    if len(account.incoming_numbers) == 0:
        return jsonify(api_error('INCOMING_CANNOT_REMOVE')), 400

    if not delete_number_from_phaxio(account.incoming_numbers[0].fax_number):
        return jsonify(api_error('INCOMING_FAILED_TO_DEPROVISION')), 500

    db.session.delete(account.incoming_numbers[0])
    db.session.commit()

    return jsonify({"success": True}) 
开发者ID:lyonbros,项目名称:faxrobot,代码行数:25,代码来源:incoming.py

示例12: delete_number_from_phaxio

# 需要导入模块: import stripe [as 别名]
# 或者: from stripe import api_key [as 别名]
def delete_number_from_phaxio(fax_number):
    payload = {
        "number": fax_number,
        "api_key": os.environ.get('PHAXIO_API_KEY'),
        "api_secret": os.environ.get('PHAXIO_API_SECRET')
    }

    try:
        url = "https://api.phaxio.com/v1/releaseNumber"
        r = requests.post(url, data=payload)
        response = json.loads(r.text)

        if response["success"] == False:
            return False
    except:
        return False

    return True 
开发者ID:lyonbros,项目名称:faxrobot,代码行数:20,代码来源:incoming.py

示例13: __init__

# 需要导入模块: import stripe [as 别名]
# 或者: from stripe import api_key [as 别名]
def __init__(self):
        stripe.api_key = STRIPE_SECRET 
开发者ID:JamesRamm,项目名称:longclaw,代码行数:4,代码来源:stripe.py

示例14: create_stripe_account

# 需要导入模块: import stripe [as 别名]
# 或者: from stripe import api_key [as 别名]
def create_stripe_account(token: str, email: str):
    stripe.api_key = os.environ['STRIPE_PRIVATE_KEY']
    customer = stripe.Customer.create(source=token, email=email)
    return customer.id 
开发者ID:MycroftAI,项目名称:selene-backend,代码行数:6,代码来源:stripe.py

示例15: create_stripe_subscription

# 需要导入模块: import stripe [as 别名]
# 或者: from stripe import api_key [as 别名]
def create_stripe_subscription(customer_id, plan):
    stripe.api_key = os.environ['STRIPE_PRIVATE_KEY']
    request = stripe.Subscription.create(
        customer=customer_id,
        items=[{'plan': plan}]
    )

    return request.id 
开发者ID:MycroftAI,项目名称:selene-backend,代码行数:10,代码来源:stripe.py


注:本文中的stripe.api_key方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。