advancingu/stripe-subscription-bundle

此包已被弃用且不再维护。未建议替代包。

通过Stripe API处理订阅

dev-master 2013-09-23 20:03 UTC

This package is not auto-updated.

Last update: 2020-01-19 16:19:58 UTC


README

AdvancinguStripeSubscriptionBundle提供了一种简单的Symfony服务,用于通过Stripe支付服务订阅付费订阅。该包还包括一个HTML表格和JS代码,用于显示可用的订阅计划,并允许用户使用Stripe的支付弹出窗口订阅计划。

使用此包需要有一个Stripe账户。

安装

该包需要Symfony 2.2或更高版本,Stripe PHP API以及JMSSecurityExtraBundle。

通过Composer安装包,请在您的composer.json依赖中添加以下行

"advancingu/stripe-subscription-bundle": "dev-master"

一旦该包进一步稳定,将引入语义版本控制。

配置

通过config.yml提供的示例配置

parameters:
    advancingu_stripe_subscription.keys.public: %stripe_public_key%
    advancingu_stripe_subscription.keys.secret: %stripe_secret_key%

advancingu_stripe_subscription:
    stripe_public_key: %advancingu_stripe_subscription.keys.public%
    stripe_secret_key: %advancingu_stripe_subscription.keys.secret%
    payee_name: "ACME Industries Inc."
    plans:
        my_default_plan:                 # The plan's ID as defined with Stripe.
            i18nKey: plan.default.name   # Key inside translation domain for a plan.
            messageDomain: messages      # Translation domain to use for plan name.
            price: 2000                  # In cents.
            currency: CAD                # Three character ISO currency code. Must be supported by your Stripe account.
            role: ROLE_PLAN_DEFAULT           # The lowest user role required for permission to execute actions protected by the plan.
    subscription_check:
        subscribe_route: MyWebsiteBundle_default_subscribe            # Route to redirect to if a user tries to access a resource without or with an insufficient plan. 
        subscription_required_i18nKey: subscription.please_subscribe  # Key of the flash message to display.
        subscription_required_message_domain: messages                # Translation domain of flash message.
    trial_role: ROLE_PLAN_TRIAL               # Role name to identify a trial plan subscriber.
    trial_duration: +14 days                  # PHP DateTime modifier string, indicating the duration of a trial
    object_manager: doctrine_mongodb.odm.default_document_manager     # Service ID of the object manager responsible for persisting user instances.

要使用包含的HTML模板,请将您的Stripe公钥添加到Twig的全局变量中

twig:
    globals:
        stripe_public_key: "%advancingu_stripe_subscription.keys.public%"

要使用安全异常监听器,请将监听器添加到您的security.yml防火墙中

security:
    firewalls:
        my_firewall:
            access_denied_handler: advancingu_stripe_subscription.access_denied_listener

使用

注意:计划角色名称必须以ROLE_开头,否则将不会被Symfony默认的安全投票者识别。

提示:使用角色层次结构来定义增量计划。

许可

此包受MIT许可协议保护。请参阅包中的完整许可协议。

LICENSE