Download the PHP package esanj/discount-client without Composer

On this page you can find all versions of the php package esanj/discount-client. 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 discount-client

Esanj Discount Client

A Laravel client package for the Esanj Discount Microservice (coupons & gift cards). It authenticates with client credentials through the esanj/auth-bridge package, then lets you create and apply discount codes (coupons) and gift cards — with typed DTOs, typed responses and structured error handling.

Installation

The service provider and the Discount, Coupon and GiftCard facades are auto-discovered.

Configuration

Publish the config (optional — it is merged automatically):

Set the environment variables:

The access token is issued by the OAuth server configured for esanj/auth-bridge (ACCOUNTING_BRIDGE_BASE_URL) using this service's DISCOUNT_CLIENT_ID / DISCOUNT_CLIENT_SECRET, then sent as a short-lived Bearer token to the Discount service. Tokens are cached and refreshed automatically by auth-bridge.

Usage

Dependency injection (recommended)

You can also inject CouponClientInterface / GiftCardClientInterface directly.

Facades

Applying a coupon (validate → redeem → confirm / cancel)

Applying a gift card (validate → redeem)

Creating coupons and gift cards

Error Handling

Every failure throws a subclass of Esanj\DiscountClient\Exceptions\DiscountException:

Exception When
DiscountAuthenticationException Client credentials missing/invalid; the OAuth server rejected the token request.
DiscountApiException The Discount service returned an error response. Carries statusCode, responseBody, getErrorCode(), getErrors().

Server (5xx), connection and rejected-token (401/403) failures are retried automatically according to the retry config; a rejected token is invalidated and re-fetched before the retry.

API surface

Method HTTP Endpoint
coupons()->create(CouponData) POST /api/v1/service/coupons
coupons()->show(string $code) GET /api/v1/service/coupons/{code}
coupons()->validate(string $code, CouponValidationData) POST /api/v1/service/coupons/{code}/validate
coupons()->redeem(string $code, string $usageId, CouponValidationData) POST /api/v1/service/coupons/{code}/redeem
coupons()->confirm(string $code, string $usageId) POST /api/v1/service/coupons/{code}/confirm
coupons()->cancel(string $code, string $usageId) POST /api/v1/service/coupons/{code}/cancel
giftCards()->create(GiftCardData) POST /api/v1/service/gift-cards
giftCards()->show(string $code) GET /api/v1/service/gift-cards/{code}
giftCards()->validate(string $code, int $userId) POST /api/v1/service/gift-cards/{code}/validate
giftCards()->redeem(string $code, string $usageId, int $userId) POST /api/v1/service/gift-cards/{code}/redeem

See docs/GUIDE.md for a full walkthrough.

License

MIT


All versions of discount-client with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2|^8.3|^8.4
ext-json Version *
esanj/auth-bridge Version >=0.2.0 <0.3.0
illuminate/support Version ^12.0|^13.0
illuminate/log Version ^12.0|^13.0
guzzlehttp/guzzle Version ^7.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 esanj/discount-client contains the following files

Loading the files please wait ...