Download the PHP package c975l/purchasecredits-bundle without Composer
On this page you can find all versions of the php package c975l/purchasecredits-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package purchasecredits-bundle
PurchaseCreditsBundle
PurchaseCreditsBundle does the following:
- Allows to purchase and use credits within your website,
- Interfaces with Stripe via c975LPaymentBundle for its payment,
- Integrates with c975LToolbarBundle,
- Emails the user about purchased credits and joins your Terms of sales as PDF to the email,
This Bundle relies on the use of c975LPaymentBundle, Stripe and its PHP Library. So you MUST have a Stripe account.
It is also recomended to use this with a SSL certificat to reassure the user.
As the Terms of sales MUST be sent to the user with the Gift-Voucher, you MUST provide a Route or url for this PDF file. If you don't have such, you may consider using c975LSiteBundle for its pre-defined models and c975LPageEditBundle for its ability to create a PDF.
PurchaseCreditsBundle dedicated web page.
PurchaseCreditsBundle API documentation.
Bundle installation
Step 1: Download the Bundle
v3.x works with Symfony 4.x. Use v2.x for Symfony 3.x Use Composer to install the library
Step 2: Configure the Bundle
Check dependencies for their configuration:
c975LPurchaseCreditsBundle uses c975L/ConfigBundle to manage configuration parameters. Use the Route "/purchase-credits/config" with the proper user role to modify them.
Step 3: Enable the Routes
Then, enable the routes by adding them to the /config/routes.yaml
file of your project:
Step 4: User entity
Your User entity MUST have a property credits
with proper and getter and setter, plus a addCredits()
one, notice the +=
, this method is used to add and subtract credits:
Step 5: Create MySql tables
You can use php bin/console make:migration
to create the migration file as documented in Symfony's Doctrine docs OR use Use /Resources/sql/purchase-credits.sql
to create the table user_transactions
. The DROP TABLE
is commented to avoid dropping by mistake.
Step 6: Override templates
It is strongly recommended to use the Override Templates from Third-Party Bundles feature to integrate fully with your site.
For this, simply, create the following structure /templates/bundles/c975LPurchaseCreditsBundle/
in your app and then duplicate the file layout.html.twig
in it, to override the existing Bundle file.
In layout.html.twig
, it will mainly consist to extend your layout and define specific variables, i.e. :
How to use
All the process for purchase and payment is managed via the bundle. All you have to implement on your side is the use of credits. You can do so with the following code:
Routes
The different Routes (naming self-explanatory) available are:
- purchasecredits_dashboard
- purchasecredits_purchase
- purchasecredits_transactions
Twig access
You can access user's credits in Twig via
Credits information
If you want to display information about credits to user, you can add, in your Twig template, the following code. It will display, on one line, the number of credits, a link to transactions, a link to purchase and a warning when credits are <= 0.
Transaction display
The display of the list of transactions is done via the bundle, but in case you want to link to a specific transaction, you can do so with the following:
Credits Div data for javascript use
If you want to insert a div containing the user's credits, to be used by javascript, you can do it via the Twig extension:
Then you can access it via
Have a look at it to see the properties covered.
If this project help you to reduce time to develop, you can sponsor me via the "Sponsor" button at the top :)
All versions of purchasecredits-bundle with dependencies
c975l/config-bundle Version ^2
c975l/email-bundle Version ^4
c975l/includelibrary-bundle Version ^1
c975l/payment-bundle Version ^4
c975l/services-bundle Version ^1
c975l/toolbar-bundle Version ^1
doctrine/doctrine-bundle Version *
doctrine/orm Version *
knplabs/knp-paginator-bundle Version *
symfony/form Version *
symfony/security Version *
symfony/translation Version *
twig/intl-extra Version *