11[ ![ Build Status] ( https://travis-ci.org/wallee-payment/php-sdk.svg?branch=master )] ( https://travis-ci.org/wallee-payment/php-sdk )
22
3- # wallee SDK for PHP
3+ # wallee PHP Library
44
5- This repository contains the open source PHP SDK that allows you to access wallee from your PHP app .
5+ The wallee PHP library wraps around the wallee API. This library facilitates your interaction with various services such as transactions, accounts, and subscriptions .
66
7- ## Requirements
8-
9- * [ PHP 5.6.0 and later] ( http://www.php.net/ )
107
118## Documentation
129
13- https://app-wallee.com/doc/api/web-service
10+ [ wallee Web Service API] ( https://app-wallee.com/doc/api/web-service )
11+
12+ ## Requirements
13+
14+ - PHP 5.6.0 and above
1415
1516## Installation
1617
@@ -39,24 +40,44 @@ require_once '/path/to/php-sdk/autoload.php';
3940```
4041
4142## Usage
43+ The library needs to be configured with your account's space id, user id, and secret key which are available in your [ wallee
44+ account dashboard] ( https://app-wallee.com/account/select ) . Set ` space_id ` , ` user_id ` , and ` api_secret ` to their values.
4245
43- ### Basic Example
46+ ### Configuring a Service
4447
4548``` php
46- <?php
49+ require_once(__DIR__ . '/autoload.php');
50+
51+ // Configuration
52+ $spaceId = 405;
53+ $userId = 512;
54+ $secret = 'FKrO76r5VwJtBrqZawBspljbBNOxp5veKQQkOnZxucQ=';
55+
56+ // Setup API client
57+ $client = new \Wallee\Sdk\ApiClient($userId, $secret);
58+
59+ // Create API service instance
60+ $transactionService = new \Wallee\Sdk\Service\TransactionService($client);
61+ $transactionPaymentPageService = new \Wallee\Sdk\Service\TransactionPaymentPageService($client);
62+
63+ ```
64+
65+ To get started with sending transactions, please review the example below:
4766
67+ ``` php
4868require_once(__DIR__ . '/autoload.php');
4969
5070// Configuration
5171$spaceId = 405;
5272$userId = 512;
53- $secret = " FKrO76r5VwJtBrqZawBspljbBNOxp5veKQQkOnZxucQ=" ;
73+ $secret = ' FKrO76r5VwJtBrqZawBspljbBNOxp5veKQQkOnZxucQ=' ;
5474
5575// Setup API client
5676$client = new \Wallee\Sdk\ApiClient($userId, $secret);
5777
5878// Create API service instance
5979$transactionService = new \Wallee\Sdk\Service\TransactionService($client);
80+ $transactionPaymentPageService = new \Wallee\Sdk\Service\TransactionPaymentPageService($client);
6081
6182// Create transaction
6283$lineItem = new \Wallee\Sdk\Model\LineItemCreate();
@@ -69,19 +90,44 @@ $lineItem->setType(\Wallee\Sdk\Model\LineItemType::PRODUCT);
6990
7091
7192$transaction = new \Wallee\Sdk\Model\TransactionCreate();
72- $transaction->setCurrency(" EUR" );
93+ $transaction->setCurrency(' EUR' );
7394$transaction->setLineItems(array($lineItem));
7495$transaction->setAutoConfirmationEnabled(true);
7596
7697$createdTransaction = $transactionService->create($spaceId, $transaction);
7798
7899// Create Payment Page URL:
79- $redirectionUrl = $transactionService->buildPaymentPageUrl ($spaceId, $createdTransaction->getId());
100+ $redirectionUrl = $transactionPaymentPageService->paymentPageUrl ($spaceId, $createdTransaction->getId());
80101
81102header('Location: ' . $redirectionUrl);
82103
104+ ```
105+ ### HTTP Client
106+ You can either use ` php curl ` or ` php socket ` extentions. It is recommend you install the necessary extentions and enable them on your system.
107+
108+ You have to ways two specify which HTTP client you prefer.
109+
110+ ``` php
111+ $userId = 512;
112+ $secret = 'FKrO76r5VwJtBrqZawBspljbBNOxp5veKQQkOnZxucQ=';
113+
114+ // Setup API client
115+ $client = new \Wallee\Sdk\Sdk\ApiClient($userId, $secret);
116+
117+ $httpClientType = \Wallee\Sdk\Sdk\Http\HttpClientFactory::TYPE_CURL; // or \Wallee\Sdk\Sdk\Http\HttpClientFactory::TYPE_SOCKET
118+
119+ $client->setHttpClientType($httpClientType);
120+ ```
121+
122+ You can also specify the HTTP client via the ` WLE_HTTP_CLIENT ` environment variable. The possible string values are ` curl ` or ` socket ` .
123+
124+
125+ ``` php
126+ <?php
127+ putenv('WLE_HTTP_CLIENT=curl');
128+ ?>
83129```
84130
85131## License
86132
87- Please see the [ license file] ( LICENSE ) for more information.
133+ Please see the [ license file] ( https://github.com/wallee-payment/php-sdk/blob/master/ LICENSE) for more information.
0 commit comments