Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Well, you're asking two questions.</p> <blockquote> <p>how do you incrementally charge a user each month?</p> </blockquote> <p>What you are looking for is recurring payment, most payment gateway provides such options (Paypal does). Basically, it stores credit card information in a secure database, and run a cron every day to check for recurring profile and ask for authorization. However, I actually <strong>don't advise</strong> you to do it yourself, it's difficult, and somehow illegal in most country. (You can't store CC numbers yourself).</p> <p>Some website will charge you once for <em>n</em> months, but in a user perspective point of view it can afraid them.</p> <blockquote> <p>How would I implement this in code?</p> </blockquote> <p>Zend Framework ships a component (<a href="http://framework.zend.com/manual/en/zend.acl.html" rel="nofollow"><code>Zend_Acl</code></a>) which will help you to build an <a href="http://en.wikipedia.org/wiki/Access_control_list" rel="nofollow">Access Control List</a>.</p> <p>What you can do is created one "role" per subscription type, each with different privileges on different resources.</p> <p>If you know the <a href="http://en.wikipedia.org/wiki/MoSCoW_Method" rel="nofollow">MoSCOW method</a>, it is somehow similar:</p> <ul> <li>(Role)Free plan can (Privilege)register (Resource)website.</li> <li>(Role)Basic plan can (Privilege)create 5 (Resource)workspace.<br> etc.</li> </ul> <p>Note, that most of the time, there is a kind of <a href="http://en.wikipedia.org/wiki/Privilege_escalation" rel="nofollow">Privilege Escalation</a>, because on how you can inherit roles.</p> <p>You need to isolate, and find what your resource, resources can be anything you want, and even be dynamic and created on the fly.</p> <p>Using assertions, you should be able to limit the number of workspace per role.</p> <pre><code>Class WorkspaceCountAssertion { const MAX_WORKSPACE = 5; public function assert(Zend_Acl $acl, Zend_Acl_Role_Interface $role = null, Zend_Acl_Resource_Interface $resource = null, $privilege = null) { //retrieve the current workspace count if ($workspaceCount &gt; self::MAX_WORKSPACE) { return false; } return true; } } $acl-&gt;allow('basic', 'workspace', 'create', new WorkspaceCountAssertion()); </code></pre> <p>It gives you the idea.</p> <p>Note, that I never used the term user, controller, etc., you actually need to think in terms of Role, Resource, Privilege.</p> <hr> <p>You need to store the role, with its associated account in a simple many-to-one relationship.<br> Each account can have one role. How to update this when the payment stop? Depends, but in most case you'll need to run a cron which will check for ending subscription and check for recurring payment, depending on the payment gateway, it'll either postback the resulting transaction, or return it directly with the webservice. If the payment failed or is refused, then you can change back the role to a free account.</p> <p>There are several way to do that, it depends on your application and requirements.</p> <p>You may want to store each monthly subscription, or update a linked account/subscription row.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload