wallee/sdk

wallee SDK for PHP

2.0.5 2019-11-13 12:45 UTC

README

Build Status

wallee PHP Library

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

Documentation

wallee Web Service API

Requirements

  • PHP 5.6.0 and above

Installation

You can use Composer or install manually

Composer

The preferred method is via composer. Follow the installation instructions 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 wallee/sdk

Manual Installation

Alternatively you can download the package in its entirety. The 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

The library needs to be configured with your account's space id, user id, and secret key which are available in your wallee account dashboard. Set space_id, user_id, and api_secret to their values.

Configuring a Service

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

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

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

// Create API service instance
$transactionService = new \Wallee\Sdk\Service\TransactionService($client);
$transactionPaymentPageService = new \Wallee\Sdk\Service\TransactionPaymentPageService($client);

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 \Wallee\Sdk\ApiClient($userId, $secret);

// Create API service instance
$transactionService = new \Wallee\Sdk\Service\TransactionService($client);
$transactionPaymentPageService = new \Wallee\Sdk\Service\TransactionPaymentPageService($client);

// Create transaction
$lineItem = new \Wallee\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(\Wallee\Sdk\Model\LineItemType::PRODUCT);


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

$createdTransaction = $transactionService->create($spaceId, $transaction);

// Create Payment Page URL:
$redirectionUrl = $transactionPaymentPageService->paymentPageUrl($spaceId, $createdTransaction->getId());

header('Location: ' . $redirectionUrl);

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 \Wallee\Sdk\Sdk\ApiClient($userId, $secret);

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

$client->setHttpClientType($httpClientType);

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

<?php
putenv('WLE_HTTP_CLIENT=curl');
?>

License

Please see the license file for more information.