Download the PHP package moltin/php-sdk without Composer

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

moltin PHP SDK

This official PHP SDK for interacting with moltin.

NOTE: master is designed to access V2 of the API. If you want legacy access to V1 of the API, please use the most recent 1.x.x tag

Installation

You can install the package manually or by adding it to your composer.json:

Instantiating the SDK Client:

Pass in the configuration to the client:

Or configure after construct:

Note: if you are unsure what your client_id or client_secret are, please select the store in your account and copy them.

Enterprise Customers

If you are an enterprise customer and have your own infrastructure with your own domain, you can configure the client to use your domain:

Or by adding the api_endpoint field to the $config array you pass to the constructor.

Using the client

Multiple Resources

To return a list of your resources (limited to 100 depending your store configuration):

Single Resource by ID

Fetch a Resource by ID:

Fetching the category/brand/collection tree

Categories, brands and collections can be nested to create a tree structure (see the CategoryRelationships example).

You can retrieve a full tree of the items rather than having to build them by using tree method:

Limiting and Offsetting Results

Sorting Results

Filtering Results

To filter your results when calling resources which support it (e.g. /v2/products).

A simple filter to get all products which are in stock may look like this:

A more advanced filter to find products which are digital, drafted and have a stock greater than 20 would look like this:

The array passed to the filter method should contain all of the conditions required to be met by the filter on the API and allow you to use several filters of the same type (as demostrated above).

For more information on the filter operations please read the API reference.

Including data

To include other data in your request (such as products when getting a category) call the with() method on the resource:

Create Relationships

Requesting a Specific Currency

For calls that support the X-MOLTIN-CURRENCY header, you can specifiy it on the client:

Working with files

A POST request to the v2/files endpoint allows you to upload a file and store it remotely.

To create a file using the SDK, you need to have the file on disk:

Integrations

Getting Logs

Gateways

Your payment gateways can be managed using the SDK.

Carts, Orders and Payments

To simplify the way you process carts, orders and payments, we provide some utility functions.

Carts

Adding items to a cart:

When no cart reference is supplied, we will get it from the $_COOKIE. You can change the name used in the $_COOKIE by passing it in the config when instantiating the client.

This is therefore a valid call (although the cart will be a new one if you follow on from the example above):

Get the cart items:

Update the quantity of an item in the cart:

Remove an item from the cart:

Orders

To convert a cart to an order (which can then be paid):

Payments

When you have a Moltin\Entities\Order object from the checkout method you can take a payment for it:

You can now check the response ($payment) to see what happened with your payment.

You can also setup test details for most payment gateways, please refer to them for their details and check out the example for more informatiom on cart -> order -> pay.

Handling Exceptions

Aside from errors that may occur due to the call, there may be other Exceptions thrown. To handle them, simply wrap your call in a try catch block:

Internally, there are several custom Exceptions which may be raised - see the Exceptions directory for more information.

Examples

In the examples directory there are command line implementations using the SDK. To use the examples you will need to:

By default, for successful calls, we will display the data in a table on the command line. You can, however, use a flag to view the response:

Test

Generate a coverage report:


All versions of php-sdk with dependencies

PHP Build Version
Package Version
Requires php Version >=5.5.0
guzzlehttp/guzzle Version ~6.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 moltin/php-sdk contains the following files

Loading the files please wait ....