Download the PHP package darkghosthunter/laraflow without Composer

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

Laraflow

Latest Stable Version License Build Status Coverage Status Maintainability Test Coverage

Laraflow

This package lets you use the unofficial Flow SDK with Laravel.

This package is compatible with Laravel Cashier, so you can use both.

Requirements

Check older releases for older Laravel versions.

Installation

Just fire up Composer and require it into your project.

Database Preparation

If you want to use the Billable trait to charge customers, along with the Subscribable or Multisubscribable traits for Flow Subscriptions, you will need to run these database migrations:

These migrations are available in database/migrations. These are deactivated by default, but you can activate them if you publish the config file:

The point of these migrations is to sync the Customer ID, Subscription ID and the local data.

It's not necessary to run them if you are not planning to use these traits, so you can let this config on false, which is the default.

Configuration

To start using Flow with this package, just set three keys in your .env file: the environment, your API Key and Secret.

Additionally, you can publish the config file flow.php if you want to set defaults or some other advanced settings.

Deactivating CSRF

Since Flow issues POST Requests to your site using the user's browser, CSRF must be deactivated in these routes:

These POST Requests have a token comprised of 40 random characters identifying the transaction. Consider using ThrottleRequests Middleware to avoid brute force attacks.

What's inside?

A lot of goodies:

Facades

You get Facades for all Flow Services:

Service Facade
Coupon FlowCoupon
Customer FlowCustomer
Invoice FlowInvoice
Payment FlowPayment
Plan FlowPlan
Refund FlowRefund
Settlement FlowSettlement
Subscription FlowSubscription

All the services receive main Flow instance from the Service Container. So you can easily make something like this:

Refer to the Flow SDK Wiki to see how to use each Service. Just replace $flow->{service}() by the Facade of your choosing.

Billable

You can hook up charges to a user's Credit Card, or Email if he doesn't have one registered, through the Billable trait.

After you made the update_users_table migrations, you will be able to:

By default, Billable won't register your User when is created, allowing you to not clutter up your Flow account with users that won't use billing or subscriptions. You can sync the model creation with the Customer creation in Flow by setting syncOnCreate to true:

Method Description
hasCustomer() If the Model has a Flow Customer
hasCard() If the Model Credit Card Registered in Flow
getCustomer() Returns if the Flow Customer
createCustomer() Creates a Customer in Flow
updateCustomer() Updates a Customer in Flow using the local data
deleteCustomer() Deletes a Customer in Flow
registerCard() Creates a petition to register a Credit Card in Flow
syncCard() Sync the local card data from Flow
removeCard() Removes a Credit Card from Flow
charge() Charge a Customer
chargeToCard() Charge a Customer only if it has a Credit Card registered

You can always checkout the source code for more handy methods.

Subscribable

To gracefully allow your Users to have subscriptions managed by Flow, add the Subscribable trait. This will link a one-to-one subscription to the Customer and User.

After you run the create_flow_subscriptions migration, along with this trait, you will be able to:

Method Description
flowSubscription() Local Flow Subscription relationship
hasSubscription() If the Model has a local Subscription
subscription() Returns the Flow Subscription
subscribe() Subscribes the Customer to a Plan
subscribeWithCard() Subscribes the Customer only if he has a Credit Card registered
updateSubscription() Updates the subscription trial days (if possible)
unsubscribe() Unsubscribes the Customer at the end of his cycle
unsubscribeNow() Immediately unsubscribes a Customer
attachCoupon() Attaches a Coupon to the Flow Subscription
attachOrReplaceCoupon() Attaches or Replaces a Coupon in the Flow Subscription
detachCoupon() Detaches any Coupon from the Flow Subscription

You can always checkout the source code for more handy methods.

Multisubscribable

The main difference between this and the Subscribable trait is this allows a User to have multiple subscriptions - even on the same plan.

Since this trait uses the same method names, do not use both Subscribable and Multisubscribable traits in the same Model.

Because a User can have multiple subscriptions under this trait, for most operations you will have to include the subscriptionId where you want to operate.

Method table

Method Description
flowSubscriptions() Local Flow Subscriptions relationship
hasSubscriptions() If the User has at least one matching subscription
isSubscribedTo() If the User is subscribed to a Plan
subscription() Returns the Flow Subscription
subscriptions() Returns all User's Flow Subscriptions
subscriptionsForPlanId() Return the Flow Subscriptions for a Plan Id
subscribe() Subscribes the Customer to a Plan
subscribeWithCard() Subscribes the Customer only if he has a Credit Card registered
updateSubscription() Updates the subscription trial days (if possible)
unsubscribe() Unsubscribes the Customer at the end of his cycle
unsubscribeNow() Immediately unsubscribes a Customer
attachCoupon() Attaches a Coupon to the Flow Subscription
attachOrReplaceCoupon() Attaches or Replaces a Coupon in the Flow Subscription
detachCoupon() Detaches any Coupon from the Flow Subscription

You can always checkout the source code for more handy methods.

Notifications Events

This package comes with Webhook routes and Events that will fire up when Flow hit these routes with Payments, Refunds and Plans paid:

An Event will fire containing the Payment or a Refund, depending on what Flow has sent.

While this was made to save you time, you can deactivate these routes and use your own with your own logic, with or without firing events, inside the published flow.php.

You can also override the the default for each, if webhooks-defaults are set to true:

The default Webhook Routes are protected by the VerifyWebhookMiddleware, which will validate the secret if there is set.

Webhook Protection

Since disabling CSRF will unprotect the endpoints, it's recommended to add a static Webhook Secret String so only Flow can reach your application. This string is never visible to the end user.

You can conveniently generate a random string and save it as the Webhook Secret to protect your exposed endpoints:

This will append the secret to your .env file automatically, or replaced if it already exists.

After that, add the VerifyWebhookMiddleware to the Webhook endpoints. This Middleware ensures the POST Request has a token of 40 characters and the same secret as configured. When not, it will abort the Request with a 404 Not Found:

If you loaded the middleware but didn't set a Webhook Secret, don't worry. The middleware won't do nothing as it checks first if the Webhook Secret exists before anything.

Logging

No hassle! This package hooks Flow gracefully into Laravel's default logging system, so no need to change anything.

Custom Adapter

While Flow SDK uses Guzzle as a default HTTP Client, you can make your own Adapter, implementing the AdapterInterface and registered inside the Service Container.

Then, put the name of your registered Adapter in the adapter section of your published flow.php config file. The Adapter will be resolved when Flow SDK is instantiated.

This will allow in your test to make a fake Adapter and catch all Requests.

Service Providers

This package adds Flow SDK into your application as a Service Provider. You can access the Flow object just pulling it out from the Service Container like you would normally do, like using Dependency Injection or just using the resolve() helper, etc.

On the backstage, this package registers two Services Providers:

This ensures the configuration will be always loaded, and the Flow SDK only when is called in your code.

License

This package is licenced by the MIT License.

This package is not related in any way, directly or indirectly, to any of the services, companies, products and/or services referenced in this package.


All versions of laraflow with dependencies

PHP Build Version
Package Version
Requires php Version ^7.1.3
illuminate/database Version 5.8.*
illuminate/routing Version 5.8.*
illuminate/support Version 5.8.*
illuminate/console Version 5.8.*
illuminate/events Version 5.8.*
illuminate/log Version 5.8.*
darkghosthunter/flow-sdk Version ^1.0.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 darkghosthunter/laraflow contains the following files

Loading the files please wait ....