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.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package purchasecredits-bundle

PurchaseCreditsBundle

Symfony bundle for prepaid credits on the c975L core — credit packs sold through the basket, a per-user ledger and a spending API the site's own services call. Checkout is delegated to c975L/PaymentBundle.

GitHub Packagist Version PHP Version Codacy Grade

Bundle page · Tutorials · Block kinds · Live demo · Demo back-office

BUNDLE UNDER DEVELOPMENT — USE AT YOUR OWN RISK


Why PurchaseCreditsBundle

Add PurchaseCreditsBundle on top of the shared CoreBundle foundation to sell credits and let the site spend them. The purchase flows through PaymentBundle's Basket/checkout engine (BasketItemProviderInterface) instead of duplicating one; what a credit buys is the site's own business, decided by its own services.


TL;DR — Credit packs sold through PaymentBundle's basket, a ledger per user whose sum is the balance, and CreditServiceInterface::spend() for the site's services. One route (the member's credit history), one config key (its test mode), no email of its own; the balance, with a link to the packs, also shows on the member's account page.

Contents

Features


Requirements


Installation

Download

Run migrations

Two tables: credit_pack and credit_transaction, whose lines go with the account they belong to (ON DELETE CASCADE).

Nothing to register by hand

No route to import, the stylesheet published by php bin/console assets:install - and one config key, loaded with the others by php bin/console c975l:config:load-all: the menu entries, the block kind, the basket provider, the stylesheet and the Twig functions are picked up by autoconfiguration. The block's "Buy" button is PaymentBundle's own basket Stimulus controller, registered by that bundle.


Selling credits

  1. In the back office, Credits > Credit packs: create the packs (credits, price in the shop's currency, VAT).
  2. Place the Credit packs block on a page. Every visitor sees a "Buy" button per pack, a signed-in one their balance too; credits landing on an account, a visitor is asked to sign in at the checkout.
  3. Once the basket is paid, CreditBasketItemProvider::onBasketPaid() writes one ledger line per pack, with the number of credits frozen in the basket when it was filled — what the customer agreed to is what is credited, whatever the pack becomes before the payment.

A pack withdrawn from sale is refused at the checkout too, a basket living several days in the session. A basket filled before signing in is bound to the account signed in at the checkout.


Spending credits

From the console, php bin/console c975l:purchasecredits:grant <email> <credits> --description="Goodwill gesture" writes the same line.

spend() locks the user's row while it reads the balance and writes the line, so two spendings at once cannot both pass on the same credits. Never read getBalance() and then write a line yourself. InsufficientCreditsException is thrown once the transaction is over, so the EntityManager stays open and the caller carries on.

The ledger is the only truth: never store a balance beside it. A line is never edited nor deleted — Credits > Credit movements only adds lines, a mistake being corrected by the reversing line.


Twig

Function Returns
purchasecredits_packs() the published packs, in the back office order
purchasecredits_balance() the signed-in user's balance, null for a visitor

The block is never cached: the balance shown next to the packs belongs to whoever reads the page. Override templates/bundles/c975LPurchaseCreditsBundle/blocks/Packs.html.twig in the app to change its markup — or extend it and fill its empty packs_intro, pack_class, pack_top and pack_extra blocks to say what a pack buys on the site (each pack is UiBundle's pricing card: card--featured in pack_class and a card-ribbon badge in pack_top put a pack forward).


Translations

The bundle ships translations/purchasecredits.{en,fr,es}.xlf and resolves every label in its own purchasecredits domain — the spoken narrations of its guided projects in purchasecredits_narration — including the anchor and background fields UiBundle's traits add to the block's form. The one word it borrows — the "added!" confirmation of the basket — is PaymentBundle's.

A pack carries no free text to translate: its title, "%count% credits", comes from the catalogue, in the reader's language. A ledger line's description is written in the language of the basket it answers to.


What this bundle deliberately does not contribute

ConfigBundle and UiBundle expose a long list of contribution points, and not branching one is a valid answer — it is only worth writing down:

Point Why not
Emails the purchase is confirmed by PaymentBundle's own order email, like any basket
Sign-up bonus registration is the application's own code (scaffolded), which calls grant()
Content translation a pack has no free text: its title is "%count% credits", from the translation catalogue
"What's new", procedures to be written once the bundle runs on a site
Scripts the block's button is PaymentBundle's basket controller
Sitemap, linkable routes no public page of its own: the packs are a block placed on the site's pages
Health check, status extra nothing here calls for an action a maintainer takes
Import / export a ledger is not a catalogue

AI agent skills

The package ships a skill of its own, skills/c975l-purchasecredits/SKILL.md, written for the coding agent of the site installing this bundle rather than for someone modifying it. Point your agent at it:

It holds what an agent gets wrong when left to its own habits — a credits column added on the user, a balance read and then written in two steps, a ledger line edited — alongside the services, entities and Twig functions, each named as it actually is in the sources.

Nothing is installed, nothing is copied into your project: the file sits in vendor/ like any other part of the package and follows it at each composer update. A user of Claude Code wanting it to load by itself symlinks it into their own skills directory:

Tests\SkillsTest keeps the file honest: every path, class member, Twig function and block kind it quotes is checked against the sources, so renaming any of them fails the build rather than leaving an agent confidently wrong.


Upgrading from v4

v5 is a rewrite on the c975L core; nothing of v4's API survives. v4 (Symfony 4, legacy architecture) lives on the 4.x branch, and UPGRADE.md gives the mapping and the SQL that takes over a v4 ledger.


License

MIT — see LICENSE.


All versions of purchasecredits-bundle with dependencies

PHP Build Version
Package Version
Requires php Version >=8.4
c975l/core-bundle Version ^1.90
c975l/payment-bundle Version ^6.26
doctrine/dbal Version ^4.4
doctrine/orm Version ^3.7
easycorp/easyadmin-bundle Version ^5.7
symfony/form Version ^8.0
symfony/framework-bundle Version ^8.0
symfony/routing Version ^8.0
symfony/security-bundle Version ^8.0
symfony/translation Version ^8.0
symfony/twig-bridge Version ^8.0
symfony/validator Version ^8.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package c975l/purchasecredits-bundle contains the following files

Loading the files please wait ...