PHPackages                             meeteeor/sdk - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. meeteeor/sdk

ActiveLibrary[API Development](/categories/api)

meeteeor/sdk
============

Meeteeor SDK for PHP

3.2.0(3y ago)08Apache-2.0PHPPHP &gt;=5.6

Since Jun 16Pushed 3y agoCompare

[ Source](https://github.com/Meeteeor/php-sdk)[ Packagist](https://packagist.org/packages/meeteeor/sdk)[ Docs](http://github.com/Meeteeor/php-sdk)[ RSS](/packages/meeteeor-sdk/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

[![Build Status](https://camo.githubusercontent.com/6775d5476b56e46dfdeebcfe19680d9e1e6545bac5e8a62b4ddf657a9c1e430b/68747470733a2f2f7472617669732d63692e6f72672f4d65657465656f722f7068702d73646b2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/Meeteeor/php-sdk)

Meeteeor PHP Library
====================

[](#meeteeor-php-library)

The Meeteeor PHP library wraps around the Meeteeor API. This library facilitates your interaction with various services such as transactions, accounts, and subscriptions.

Documentation
-------------

[](#documentation)

[Meeteeor Web Service API](https://paymentshub.weareplanet.com/doc/api/web-service)

Requirements
------------

[](#requirements)

- PHP 5.6.0 and above

Installation
------------

[](#installation)

You can use **Composer** or **install manually**

### Composer

[](#composer)

The preferred method is via [composer](https://getcomposer.org). Follow the [installation instructions](https://getcomposer.org/doc/00-intro.md) if you do not already have composer installed.

Once composer is installed, execute the following command in your project root to install this library:

```
composer require meeteeor/sdk
```

### Manual Installation

[](#manual-installation)

Alternatively you can download the package in its entirety. The [Releases](../../releases) page lists all stable versions.

Uncompress the zip file you download, and include the autoloader in your project:

```
require_once '/path/to/php-sdk/autoload.php';
```

Usage
-----

[](#usage)

The library needs to be configured with your account's space id, user id, and secret key which are available in your [Meeteeor account dashboard](https://paymentshub.weareplanet.com/account/select). Set `space_id`, `user_id`, and `api_secret` to their values.

### Configuring a Service

[](#configuring-a-service)

```
require_once(__DIR__ . '/autoload.php');

// Configuration
$spaceId = 405;
$userId = 512;
$secret = 'FKrO76r5VwJtBrqZawBspljbBNOxp5veKQQkOnZxucQ=';

// Setup API client
$client = new \Meeteeor\Sdk\ApiClient($userId, $secret);

// Get API service instance
$client->getTransactionService();
$client->getTransactionPaymentPageService();
```

To get started with sending transactions, please review the example below:

```
require_once(__DIR__ . '/autoload.php');

// Configuration
$spaceId = 405;
$userId = 512;
$secret = 'FKrO76r5VwJtBrqZawBspljbBNOxp5veKQQkOnZxucQ=';

// Setup API client
$client = new \Meeteeor\Sdk\ApiClient($userId, $secret);

// Create transaction
$lineItem = new \Meeteeor\Sdk\Model\LineItemCreate();
$lineItem->setName('Red T-Shirt');
$lineItem->setUniqueId('5412');
$lineItem->setSku('red-t-shirt-123');
$lineItem->setQuantity(1);
$lineItem->setAmountIncludingTax(29.95);
$lineItem->setType(\Meeteeor\Sdk\Model\LineItemType::PRODUCT);

$transactionPayload = new \Meeteeor\Sdk\Model\TransactionCreate();
$transactionPayload->setCurrency('EUR');
$transactionPayload->setLineItems(array($lineItem));
$transactionPayload->setAutoConfirmationEnabled(true);

$transaction = $client->getTransactionService()->create($spaceId, $transactionPayload);

// Create Payment Page URL:
$redirectionUrl = $client->getTransactionPaymentPageService()->paymentPageUrl($spaceId, $transaction->getId());

header('Location: ' . $redirectionUrl);
```

### HTTP Client

[](#http-client)

You can either use `php curl` or `php socket` extentions. It is recommend you install the necessary extentions and enable them on your system.

You have to ways two specify which HTTP client you prefer.

```
$userId = 512;
$secret = 'FKrO76r5VwJtBrqZawBspljbBNOxp5veKQQkOnZxucQ=';

// Setup API client
$client = new \Meeteeor\Sdk\ApiClient($userId, $secret);

$httpClientType = \Meeteeor\Sdk\Http\HttpClientFactory::TYPE_CURL; // or \Meeteeor\Sdk\Http\HttpClientFactory::TYPE_SOCKET

$client->setHttpClientType($httpClientType);

//Setup a custom connection timeout if needed. (Default value is: 25 seconds)
$client->setConnectionTimeout(20);
```

You can also specify the HTTP client via the `PLN_HTTP_CLIENT` environment variable. The possible string values are `curl` or `socket`.

```
