Skip to content
This repository was archived by the owner on Jul 14, 2026. It is now read-only.

Commit 847ae00

Browse files
Stable Release (#4)
* Minor improvements in the documentation and trk * Improve documentation about the Response * Improve refund transaction funcitonality * Version bump for stable release * Code optimization
1 parent 44ecfab commit 847ae00

7 files changed

Lines changed: 40 additions & 19 deletions

File tree

README.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Overview
44

5-
This repository contains the open source PHP SDK that allows you to integrate quickly with the SumUp's ecommerce [API](https://developer.sumup.com/rest-api) endpoints. As a transport layer it support cURL or [GuzzleHttp](https://packagist.org/packages/guzzlehttp/guzzle) but they are not required if you provide your own.
5+
This repository contains the open source PHP SDK that allows you to integrate quickly with the SumUp's [API](https://developer.sumup.com/rest-api) endpoints.
66

77
## Installation
88

@@ -12,20 +12,19 @@ The SumUp eCom PHP SDK can be installed with [Composer](https://getcomposer.org/
1212
composer require sumup/sumup-ecom-php-sdk
1313
```
1414

15-
> **Note:** This version of the SumUp SDK for PHP requires PHP 5.6 or greater.
16-
1715
## Basic usage
1816

1917
```php
2018
try {
2119
$sumup = new \SumUp\SumUp([
22-
'app_id' => 'YOUR-CLIENT-ID',
20+
'app_id' => 'YOUR-CLIENT-ID',
2321
'app_secret' => 'YOUR-CLIENT-SECRET',
24-
'code' => 'YOUR-AUTHORIZATION-CODE'
22+
'code' => 'YOUR-AUTHORIZATION-CODE'
2523
]);
2624
$checkoutService = $sumup->getCheckoutService();
27-
$checkoutResponse = $checkoutService->create($config);
28-
// use the variable $checkoutResponse
25+
$checkoutResponse = $checkoutService->create($amount, $currency, $checkoutRef, $payToEmail);
26+
$checkoutId = $checkoutResponse->getBody()->id;
27+
// pass the $chekoutId to the front-end to be processed
2928
} catch (\SumUp\Exceptions\SumUpAuthenticationException $e) {
3029
echo 'Authentication error: ' . $e->getMessage();
3130
} catch (\SumUp\Exceptions\SumUpResponseException $e) {

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"description": "SumUp eCom SDK for PHP",
44
"type": "library",
55
"license": "proprietary",
6-
"version": "1.0.0-rc.2",
6+
"version": "1.0.0",
77
"keywords": ["sumup", "sdk", "payment processing", "ecommerce", "payment", "checkout"],
88
"homepage": "https://developer.sumup.com",
99
"authors": [

docs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Here is the API reference for the SumUp Ecommerce SDK for PHP.
99
| [\SumUp\SumUp](https://github.com/sumup/sumup-ecom-php-sdk/blob/master/docs/reference/SumUp.md) | The main object that helps tie all the SDK components together. |
1010
| [\SumUp\Application\ApplicationConfiguration](https://github.com/sumup/sumup-ecom-php-sdk/blob/master/docs/reference/ApplicationConfiguration.md) | An entity that represents all the application's configurations. |
1111
| [\SumUp\Authentication\AccessToken](https://github.com/sumup/sumup-ecom-php-sdk/blob/master/docs/reference/AccessToken.md) | An entity that represents an access token. |
12+
| [\SumUp\HttpClients\Response](https://github.com/sumup/sumup-ecom-php-sdk/blob/master/docs/reference/Response.md) | The response object that every service returns. |
1213

1314
## Services
1415

@@ -25,7 +26,6 @@ Here is the API reference for the SumUp Ecommerce SDK for PHP.
2526
2627
| Class name | Description |
2728
|--- |--- |
28-
| [\SumUp\HttpClients\Response]() | The response object that every service returns. |
2929
| [\SumUp\HttpClients\SumUpCUrlClient]() | The HTTP client for managing cURL requests. |
3030
| [\SumUp\HttpClients\SumUpGuzzleHttpClient]() | The HTTP client for managing [Guzzle HTTP](https://packagist.org/packages/guzzlehttp/guzzle) requests. |
3131
| [\SumUp\HttpClients\HttpClientsFactory]() | The factory class that creates HTTP clients. | -->

docs/reference/Response.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Response for the SumUp Ecommerce SDK for PHP
2+
3+
## \SumUp\HttpClients\Response
4+
5+
The `\SumUp\HttpClients\Response` object is the main object that is returned from every successful service call.
6+
7+
## Instance Methods
8+
9+
### getHttpResponseCode()
10+
11+
```php
12+
public function getHttpResponseCode(): int
13+
```
14+
15+
Returns the HTTP response code.
16+
17+
### getBody()
18+
19+
```php
20+
public function getBody(): mixed
21+
```
22+
23+
Returns different object according to the service's response.

docs/reference/Transactions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ Returns a `\SumUp\HttpClients\Response` or throws an exception.
7777
Refunds a transaction partially or fully depending on the `amount`.
7878

7979
```php
80-
public function refund(string $transactionId, float $amount): \SumUp\HttpClients\Response
80+
public function refund(string $transactionId, float $amount = null): \SumUp\HttpClients\Response
8181
```
8282

8383
Returns a `\SumUp\HttpClients\Response` or throws an exception.

src/SumUp/Services/Transactions.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ public function getTransactionHistory($filters = [])
154154
* Refund a transaction partially or fully.
155155
*
156156
* @param $transactionId
157-
* @param $amount
157+
* @param null $amount
158158
*
159159
* @return \SumUp\HttpClients\Response
160160
*
@@ -164,17 +164,17 @@ public function getTransactionHistory($filters = [])
164164
* @throws \SumUp\Exceptions\SumUpAuthenticationException
165165
* @throws \SumUp\Exceptions\SumUpSDKException
166166
*/
167-
public function refund($transactionId, $amount)
167+
public function refund($transactionId, $amount = null)
168168
{
169169
if (empty($transactionId)) {
170170
throw new SumUpArgumentException(ExceptionMessages::getMissingParamMsg('transaction id'));
171171
}
172-
if (empty($amount)) {
173-
throw new SumUpArgumentException(ExceptionMessages::getMissingParamMsg('amount'));
172+
$payload = [];
173+
if (!empty($amount)) {
174+
$payload = [
175+
'amount' => $amount
176+
];
174177
}
175-
$payload = [
176-
'amount' => $amount
177-
];
178178
$path = '/v0.1/me/refund/' . $transactionId;
179179
$headers = array_merge(Headers::getStandardHeaders(), Headers::getAuth($this->accessToken));
180180
return $this->client->send('POST', $path, $payload, $headers);

src/SumUp/Utils/Headers.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@ public static function getAuth(AccessToken $accessToken)
5656
*/
5757
public static function getTrk()
5858
{
59-
$version = self::getProjectVersion();
60-
return ['X-SDK' => 'PHP/v' . $version];
59+
return ['X-SDK' => 'PHP-SDK/v' . self::getProjectVersion() . ' PHP/v' . phpversion()];
6160
}
6261

6362
/**

0 commit comments

Comments
 (0)