Skip to content

Commit

Permalink
Release 7.0.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
WorldlineConnect committed Mar 19, 2024
1 parent c2f7030 commit ece801d
Show file tree
Hide file tree
Showing 508 changed files with 41,651 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
@@ -0,0 +1,12 @@
root = true

[*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
4 changes: 4 additions & 0 deletions .gitattributes
@@ -0,0 +1,4 @@
.gitattributes export-ignore
.gitignore export-ignore

* text eol=lf
56 changes: 56 additions & 0 deletions .github/workflows/api-docs.yml
@@ -0,0 +1,56 @@
name: API docs

on:
push:
tags: ['[0-9]+.[0-9]+*']

permissions:
contents: write

jobs:
api-docs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
path: code
persist-credentials: false
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '5.6'
- name: Install apigen
run: composer global require apigen/apigen
- name: Build API docs
run: apigen generate -s lib,src -d docs --deprecated --no-source-code --title 'Worldline Connect PHP SDK'
working-directory: code
- name: Checkout pages
uses: actions/checkout@v3
with:
ref: gh-pages
path: pages
- name: Deploy pages
run: |
SDK_VERSION_FOLDER=`echo "$SDK_VERSION" | awk --field-separator '.' '{print $1".x";}'`
# Create .nojekyll if it doesn't exist yet
touch .nojekyll
mkdir -p "apidoc/$SDK_VERSION_FOLDER"
rsync --quiet --archive --checksum --delete --exclude .git ../code/docs/ "apidoc/$SDK_VERSION_FOLDER/"
if [ -e apidoc/latest ]; then rm -r apidoc/latest; fi
pushd apidoc && ln -s "$SDK_VERSION_FOLDER" latest && popd
git config user.email "$USER_EMAIL"
git config user.name "$USER_NAME"
git add --all .
# Only commit when there are changes
git diff --quiet && git diff --staged --quiet || git commit --message "Generated API docs for version ${SDK_VERSION}"
git push
shell: bash
working-directory: pages
env:
SDK_VERSION: ${{ github.ref_name }}
USER_EMAIL: ${{ github.event.pusher.email }}
USER_NAME: ${{ github.event.pusher.name }}
10 changes: 10 additions & 0 deletions .gitignore
@@ -0,0 +1,10 @@
.idea
.buildpath
.project
.settings
*.pyc
doc
/composer.lock
/phpunit.xml
/tests/config.json
/vendor/
58 changes: 58 additions & 0 deletions README.md
@@ -0,0 +1,58 @@
# Worldline Connect PHP SDK

## Introduction

The Worldline Connect PHP SDK helps you to communicate with the [Worldline Connect](https://docs.connect.worldline-solutions.com/) Server API. Its primary features are:

* convenient PHP wrapper around the API calls and responses:
* marshalls PHP request objects to HTTP requests
* unmarshalls HTTP responses to PHP response objects or PHP exceptions
* handling of all the details concerning authentication
* handling of required metadata

Its use is demonstrated by an example for most calls. The examples execute a call using the provided API keys.

See the [Worldline Connect Developer Hub](https://docs.connect.worldline-solutions.com/documentation/sdk/server/php/) for more information on how to use the SDK.

## Structure of this repository

This repository consists out of the following components:

1. The source code of the SDK itself: `/src` and `/lib`
2. The source code of the unit and integration tests (including the examples): `/tests`

## Requirements

PHP 5.4 or above is required. In addition, to support streaming uploads, package [robtimus/multipart](https://packagist.org/packages/robtimus/multipart) is required.

## Installation via Composer

1. Initialize [Composer](https://getcomposer.org/download/) in your project, if this is not already done, by executing the following command:

```
composer init
```

2. Add a requirement to the SDK to your `composer.json` file by executing the following command:

```
composer require worldline-global-collect/connect-sdk-php
```
3. Add `vendor/autoload.php` to your project, if this is not already done, by adding the following line of code:

```
require __DIR__ . '/vendor/autoload.php';
```

## Manual installation

1. Download the latest version of the PHP SDK from GitHub. Choose the `connect-sdk-php-x.y.z.tar.gz` file from the [releases](https://github.com/Worldline-Global-Collect/connect-sdk-php/releases) page, where `x.y.z` is the version number.
2. Add the contents of the `tar.gz` file to your project. The content of the `/src` and `/lib` folders may be combined, if this is required by the project.
3. Add all classes from the `/src` and `/lib` folders to your autoloader; all classes inside these folders are compliant with [PSR-4](http://www.php-fig.org/psr/psr-4/).

## Development and testing

1. Install [Composer](https://getcomposer.org/download/)
2. From the root of the sdk-php project, run `composer install`
3. Copy `tests/config.json.dist` to `tests/config.json` and replace the template values by actual values
4. From the root of the sdk-php project, `vendor/phpunit/phpunit/phpunit` (or just `phpunit` when it is already installed on your local machine)
34 changes: 34 additions & 0 deletions composer.json
@@ -0,0 +1,34 @@
{
"name": "worldline-global-collect/connect-sdk-php",
"type": "library",
"description": "PHP SDK to communicate with the Worldline Global Collect platform server-to-server API",
"homepage": "https://worldline.com/",
"keywords": ["SDK"],
"license": "MIT",
"authors": [
{
"name": "Worldline Global Collect",
"homepage": "https://worldline.com/"
}
],
"require": {
"php": ">=5.4",
"ext-curl": "*",
"ext-json": "*",
"ext-mbstring": "*",
"robtimus/multipart": "~1.0"
},
"require-dev": {
"phpunit/phpunit": "~4"
},
"autoload": {
"psr-4": {
"Worldline\\Connect\\Sdk\\": ["src/Worldline/Connect/Sdk", "lib/Worldline/Connect/Sdk"]
}
},
"autoload-dev": {
"psr-4": {
"Worldline\\Connect\\Sdk\\": ["tests/Worldline/Connect/Sdk"]
}
}
}
197 changes: 197 additions & 0 deletions documentation/Migration Guide v6 to v7.md
@@ -0,0 +1,197 @@
# Migrating from version 6.x.x to 7.0.0

## Dependency

The Composer project name has changed to `worldline-global-collect/connect-sdk-php`. You need to update the dependencies in your `composer.json` file:

```json
"require": {
"worldline-global-collect/connect-sdk-php": "~7.0.0"
}
```

## Use statements

All namespaces have been renamed, and some classes and interfaces have moved to different namespaces. Each API version now has its own namespace structure that contains all classes specific for that version, including classes like `APIError`, exceptions and webhooks classes.

You need to change your use statements as follows:

| Previous namespace | Class / interface | New namespace | Notes |
|--------------------------------------|------------------------------|--------------------------------------|-------|
| Ingenico\Connect\Sdk | ApiException | Worldline\Connect\Sdk\V1 |
| Ingenico\Connect\Sdk | AuthorizationException | Worldline\Connect\Sdk\V1 |
| Ingenico\Connect\Sdk | BodyObfuscator | Worldline\Connect\Sdk\Logging |
| Ingenico\Connect\Sdk | CommunicatorLogger | Worldline\Connect\Sdk\Logging |
| Ingenico\Connect\Sdk | CommunicatorLoggerHelper | Worldline\Connect\Sdk\Communication |
| Ingenico\Connect\Sdk | Connection | Worldline\Connect\Sdk\Communication |
| Ingenico\Connect\Sdk | ConnectionResponse | Worldline\Connect\Sdk\Communication |
| Ingenico\Connect\Sdk | DataObject | Worldline\Connect\Sdk\Domain |
| Ingenico\Connect\Sdk | DeclinedPaymentException | Worldline\Connect\Sdk\V1 |
| Ingenico\Connect\Sdk | DeclinedPayoutException | Worldline\Connect\Sdk\V1 |
| Ingenico\Connect\Sdk | DeclinedRefundException | Worldline\Connect\Sdk\V1 |
| Ingenico\Connect\Sdk | DefaultConnection | Worldline\Connect\Sdk\Communication |
| Ingenico\Connect\Sdk | GlobalCollectException | Worldline\Connect\Sdk\V1 |
| Ingenico\Connect\Sdk | HeaderObfuscator | Worldline\Connect\Sdk\Logging |
| Ingenico\Connect\Sdk | HttpHeaderHelper | Worldline\Connect\Sdk\Communication |
| Ingenico\Connect\Sdk | HttpObfuscator | Worldline\Connect\Sdk\Communication |
| Ingenico\Connect\Sdk | IdempotenceException | Worldline\Connect\Sdk\V1 |
| Ingenico\Connect\Sdk | InvalidResponseException | Worldline\Connect\Sdk\Communication |
| Ingenico\Connect\Sdk | MultipartDataObject | Worldline\Connect\Sdk\Communication |
| Ingenico\Connect\Sdk | MultipartFormDataObject | Worldline\Connect\Sdk\Communication |
| Ingenico\Connect\Sdk | ReferenceException | Worldline\Connect\Sdk\V1 |
| Ingenico\Connect\Sdk | RequestObject | Worldline\Connect\Sdk\Communication |
| Ingenico\Connect\Sdk | ResourceLogger | Worldline\Connect\Sdk\Logging |
| Ingenico\Connect\Sdk | ResponseBuilder | Worldline\Connect\Sdk\Communication |
| Ingenico\Connect\Sdk | ResponseClassMap | Worldline\Connect\Sdk\Communication |
| Ingenico\Connect\Sdk | ResponseException | Worldline\Connect\Sdk\V1 |
| Ingenico\Connect\Sdk | ResponseExceptionFactory | Worldline\Connect\Sdk\V1 |
| Ingenico\Connect\Sdk | ResponseFactory | Worldline\Connect\Sdk\Communication |
| Ingenico\Connect\Sdk | ResponseHeaderBuilder | Worldline\Connect\Sdk\Communication |
| Ingenico\Connect\Sdk | SplFileObjectLogger | Worldline\Connect\Sdk\Logging |
| Ingenico\Connect\Sdk | UploadableFile | Worldline\Connect\Sdk\Domain |
| Ingenico\Connect\Sdk | UuidGenerator | Worldline\Connect\Sdk\Communication |
| Ingenico\Connect\Sdk | ValidationException | Worldline\Connect\Sdk\V1 |
| Ingenico\Connect\Sdk | ValueObfuscator | Worldline\Connect\Sdk\Logging |
| Ingenico\Connect\Sdk | All other classes | Worldline\Connect\Sdk |
| Ingenico\Connect\Sdk\Domain\MetaData | ShoppingCartExtension | Worldline\Connect\Sdk\Domain |
| Ingenico\Connect\Sdk\Domain\* | All other domain classes | Worldline\Connect\Sdk\V1\Domain | All domain classes for version 1 of the API are now in the same namespace |
| Ingenico\Connect\Sdk\Merchant\* | All classes | Worldline\Connect\Sdk\V1\Merchant\* | The same namespace structure is used |
| Ingenico\Connect\Sdk\Webhooks | WebhooksHelper | Worldline\Connect\Sdk\V1\Webhooks |
| Ingenico\Connect\Sdk\Webhooks | All other classes | Worldline\Connect\Sdk\Webhooks |

## API calls

Method `merchant` of class `Client` has moved to new class `V1Client`. Instances of this class are available through method `v1` of class `Client`. You need to replace all occurrences of `->merchant` with `->v1()->merchant` in your code. For instance:

```php
$response = $client->v1()->merchant($merchantId)->services()->testconnection();
```

## API version

Constant `API_VERSION` of class `Client` has been removed. You need to replace all occurrences in your code with string literal `'v1'`.

## Communicator

The constructor of class `Communicator` now takes a required `CommunicatorConfiguration` and an optional `Authenticator` and `Connection`. If the `Authenticator` or `Connection` is not provided a new instance will be created using the given `CommunicatorConfiguration`. That means you only need to provide an `Authenticator` or `Connection` if the defaults aren't sufficient. You need to change all calls to the constructor in your code with one of the following:

* To use a `DefaultConnection` instance, provide only the `CommunicatorConfiguration`:
```php
$communicator = new Communicator($communicatorConfiguration);
```

* To use a custom `Connection` implementation, provide the `CommunicatorConfiguration`, `null` for the `Authenticator`, and the `Connection`:
```php
$communicator = new Communicator($connection, null, $communicatorConfiguration);
```

### Accessing fields

The `getConnection`, `setConnection`, `getCommunicatorConfiguration` and `setCommunicatorConfiguration` methods have been removed. You need to capture the constructor arguments in your code instead of calling the `getConnection` and `getCommunicatorConfiguration` methods, and you need to create a new `Communicator` instance in your code instead of calling the `setConnection` and `setCommunicatorConfiguration` methods.

### HTTP methods

The HTTP methods of class `Communicator` no longer use a `ResponseExceptionFactory` but instead throw instances of new class `ErrorResponseException`. Mapping these to other exceptions is now the response of the calling class. The SDK's own client classes will take care of this for you, but if you use these methods directly you need to change all occurrences in your code. For instance:

```php
try {
return $communicator->get($responseClassMap, $uri, $clientMetaInfo, null, $callContext);
} catch (ErrorResponseException $e) {
throw $responseExceptionFactory->createException($e->getHttpStatusCode(), $e->getErrorResponse(), $callContext);
}
```

The `getResponseExceptionFactory` method has been removed, as it is no longer necessary.

### HTTP methods with binary responses

The `BodyHandler` parameter of methods `getWithBinaryResponse`, `deleteWithBinaryResponse`, `postWithBinaryResponse` and `putWithBinaryResponse` is required and is therefore now the first parameter. You need to move the argument from the end to the start of the argument list in all occurrences in your code.

## CommunicatorConfiguration

The integrator is now required. You need to make sure a non-empty integrator is set on any `CommunicatorConfiguration` instance you create.

## DeclinedPaymentException

Method `getPaymentResult` of class `DeclinedPaymentException` has been renamed to `getCreatePaymentResult` to match the return type. You need to change all occurrences in your code with the new name.

## GlobalCollectException

Class `GlobalCollectException` has been renamed to `PlatformException`. You need to replace all occurrences in your code with the new name.

## Resource

Class `Resource` has been renamed to `ApiResource`, to avoid IDEs confusing it with the built-in `resource` type. You need to replace all occurrences in your code with the new name.

## Client classes

All client classes have been renamed to end with `Client`. For instance, class `Merchant` is renamed to `MerchantClient`, and class `Payments` is renamed to `PaymentsClient`. You need to replace all occurrences in your code with the new names.

## Communication

### Connection

The `ProxyConfiguration` parameter has been removed from methods of interface `Connection`. This should instead be provided when creating instances of implementing classes. You need to change all custom implementations to remove the parameter from the implemented methods and store an optional `ProxyConfiguration` in a field instead.

### ConnectionResponse and DefaultConnectionResponse

Interface `ConnectionResponse` and class `DefaultConnectionResponse` have been combined into class `ConnectionResponse`. You need to replace all occurrences of class `DefaultConnectionResponse` in your code with `ConnectionResponse`. You need also need to change all custom implementations of interface `ConnectionResponse` to extend the combined class instead of implement it.

### DefaultConnection

The constructor of class `DefaultConnection` now takes an optional `CommunicatorConfiguration` instead of optional connect and read timeouts. You need to replace all occurrences in your code that set a connect or read timeout to use the `CommunicatorConfiguration` instead. For instance:

```php
$communicatorConfiguration->setConnectTimeout($connectTimeout);
$communicatorConfiguration->setReadTimeout($readTimeout);
$connection = new DefaultConnection($communicatorConfiguration);
```

Alternatively, you can omit the `DefaultConnection` and let the `Communicator` create it:

```php
$communicatorConfiguration->setConnectTimeout($connectTimeout);
$communicatorConfiguration->setReadTimeout($readTimeout);
$communicator = new Communicator($communicatorConfiguration);
```

### HttpHeaderHelper

Class `HttpHeaderHelper` has been turned into a utility class. Its methods are now static and it can no longer be instantiated. You need to replace all occurrences in your code with static method calls, and remove any instance.

### InvalidResponseException

Field `response` of class `InvalidResponseException` has been made private. You need to replace all occurrences in your code with calls to the `getResponse` method.

### RequestHeaderGenerator

Class `RequestHeaderGenerator` has been replaced with new interface `Authenticator`, new classes `V1HMACAuthenticator` and `MetadataProvider`, and new methods in class `Communicator`.

* To get values for the `X-GCS-ServerMetaInfo` header you need to change your code to use instances of class `MetaDataProvider` and its `getServerMetaInfoValue` method.
* To get values for the `X-GCS-Idempotence-Key` header you need to change your code to use the result of calling `getIdempotenceKey` on the `CallContext` instance.
* To get values for the `Authorization` header you need to change your code to use instances of class `V1HMACAuthenticator` and its `getAuthorization` method.
* To get values for the `Date` header you need to change your code to use `gmdate('D, d M Y H:i:s T')`.

### ResponseClassMap

Field `responseClassNamesByHttpStatusCode` of class `ResponseClassMap` has been made private. You need to replace all occurrences in your code with the `addResponseClassName` and `getResponseClassName` methods.

### ResponseExceptionFactory

Class `ResponseExceptionFactory` has been renamed to `ExceptionFactory`. You need to replace all occurrences in your code with the new name.

### ResponseFactory

Since class `ErrorResponse` is specific for version 1 of the API, class `ResponseFactory` no longer defaults to it. The `ResponseClassMap` argument must have a value for its `defaultErrorResponseClassName` field instead.

## JSON marshalling

### DataObject

Method `getLastJsonDecodeErrorString` of class `DataObject` has moved to new class `JSONUtil`. You need to change all occurrences in custom `DataObject` sub classes to call the method on `JSONUtil` instead.

## Webhooks

### WebhooksHelper

Method `validate` of class `WebhooksHelper` has been removed. You need to replace all occurrences in your code with a `SignatureValidator`.

0 comments on commit ece801d

Please sign in to comment.