Skip to content

Commit

Permalink
Release 1.0.8
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewrowanwallee committed Jul 24, 2024
1 parent 4eefab8 commit 11d1fca
Show file tree
Hide file tree
Showing 92 changed files with 556 additions and 605 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# PrestaShop 8 wallee Integration
This repository contains the PrestaShop wallee payment module that enables the shop to process payments with [wallee](https://www.wallee.com).

## To install module manually by dragging up zip file, please download [.zip archive](https://plugin-documentation.wallee.com/wallee-payment/prestashop-8/1.0.7/wallee.zip) of module with correct structure required by Prestashop installation
## To install module manually by dragging up zip file, please download [.zip archive](https://plugin-documentation.wallee.com/wallee-payment/prestashop-8/1.0.8/wallee.zip) of module with correct structure required by Prestashop installation

##### To use this extension, a [wallee](https://app-wallee.com/user/signup) account is required.

Expand All @@ -12,15 +12,15 @@ This repository contains the PrestaShop wallee payment module that enables the s

## Documentation

* [English](https://plugin-documentation.wallee.com/wallee-payment/prestashop-8/1.0.7/docs/en/documentation.html)
* [English](https://plugin-documentation.wallee.com/wallee-payment/prestashop-8/1.0.8/docs/en/documentation.html)

## Support

Support queries can be issued on the [wallee support site](https://app-wallee.com/space/select?target=/support).

## License

Please see the [license file](https://github.com/wallee-payment/prestashop-8/blob/1.0.7/LICENSE) for more information.
Please see the [license file](https://github.com/wallee-payment/prestashop-8/blob/1.0.8/LICENSE) for more information.

## Other PrestaShop Versions

Expand Down
4 changes: 2 additions & 2 deletions docs/en/documentation.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ <h2>Documentation</h2> </div>
</a>
</li>
<li>
<a href="https://github.com/wallee-payment/prestashop-8/releases/tag/1.0.7/">
<a href="https://github.com/wallee-payment/prestashop-8/releases/tag/1.0.8/">
Source
</a>
</li>
Expand All @@ -50,7 +50,7 @@ <h1>
<div class="olist arabic">
<ol class="arabic">
<li>
<p><a href="https://github.com/wallee-payment/prestashop-8/releases/tag/1.0.7/">Download</a> the module.</p>
<p><a href="https://github.com/wallee-payment/prestashop-8/releases/tag/1.0.8/">Download</a> the module.</p>
</li>
<li>
<p>Login to the backend of your PrestsShop store.</p>
Expand Down
2 changes: 1 addition & 1 deletion views/templates/admin/admin_help_buttons.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
<div class="alert alert-info">
<img src="../modules/wallee/logo.png" style="float:left; margin-right:15px;" height="50">
<p><strong>{l s='This module requires an %s account.' sprintf='wallee' mod='wallee'}</strong></p>
<p><a class="btn btn-default" href="https://app-wallee.com/user/signup" target="_blank">{l s='Sign Up' mod='wallee'}</a> <a class="btn btn-default" href="https://plugin-documentation.wallee.com/wallee-payment/prestashop-8/1.0.7/docs/en/documentation.html" target="_blank">{l s='Documentation' mod='wallee'}</a></p>
<p><a class="btn btn-default" href="https://app-wallee.com/user/signup" target="_blank">{l s='Sign Up' mod='wallee'}</a> <a class="btn btn-default" href="https://plugin-documentation.wallee.com/wallee-payment/prestashop-8/1.0.8/docs/en/documentation.html" target="_blank">{l s='Documentation' mod='wallee'}</a></p>
</div>
2 changes: 1 addition & 1 deletion wallee-sdk/composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wallee/sdk",
"version": "4.2.0",
"version": "4.4.0",
"description": "wallee SDK for PHP",
"keywords": [
"wallee",
Expand Down
4 changes: 2 additions & 2 deletions wallee-sdk/lib/ApiClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ final class ApiClient {
* @var array
*/
private $defaultHeaders = [
'x-meta-sdk-version' => "4.2.0",
'x-meta-sdk-version' => "4.4.0",
'x-meta-sdk-language' => 'php',
'x-meta-sdk-provider' => "wallee",
];
Expand All @@ -58,7 +58,7 @@ final class ApiClient {
*
* @var string
*/
private $userAgent = 'PHP-Client/4.2.0/php';
private $userAgent = 'PHP-Client/4.4.0/php';

/**
* The path to the certificate authority file.
Expand Down
6 changes: 3 additions & 3 deletions wallee-sdk/lib/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class Configuration
*
* @var string
*/
protected $userAgent = 'Wallee\Sdk/4.2.0/php';
protected $userAgent = 'Wallee\Sdk/4.4.0/php';

/**
* Debug switch (default set to false)
Expand Down Expand Up @@ -388,8 +388,8 @@ public static function toDebugReport()
$report = 'PHP SDK (Wallee\Sdk) Debug Report:' . PHP_EOL;
$report .= ' OS: ' . php_uname() . PHP_EOL;
$report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL;
$report .= ' OpenAPI Spec Version: 4.2.0' . PHP_EOL;
$report .= ' SDK Package Version: 4.2.0' . PHP_EOL;
$report .= ' OpenAPI Spec Version: 4.4.0' . PHP_EOL;
$report .= ' SDK Package Version: 4.4.0' . PHP_EOL;
$report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL;

return $report;
Expand Down
106 changes: 79 additions & 27 deletions wallee-sdk/lib/Http/CurlHttpClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
*/


declare(strict_types=1);

namespace Wallee\Sdk\Http;

use Wallee\Sdk\Http\ConnectionException;
Expand All @@ -33,14 +35,35 @@
*/
final class CurlHttpClient implements IHttpClient {

public function isSupported() {
/**
* Checks if curl is installed in the system.
*
* @return bool
*/
public function isSupported(): bool {
return function_exists('curl_version');
}

public function send(ApiClient $apiClient, HttpRequest $request) {
/**
* Sends the request using curl.
*
* The function will try to use the CA certificates provided by the system, first.
* If an error is detected, a second attempt will be done but this time using the
* CA certificates provided by this SDK.
* If this second attempt is valid, the SDK's CA certificates wil be stored in a
* temporal file ensuring upcoming request will use them. But if the second attempt
* also fails, then it means that the SDK's CA certificates do not help either, and
* will not be used anymore.
*
* @param ApiClient $apiClient
* @param HttpRequest $request
* @return HttpResponse
* @throws ConnectionException
*/
public function send(ApiClient $apiClient, HttpRequest $request): HttpResponse {
$curl = curl_init();

$tempCAFile = sys_get_temp_dir() . DIRECTORY_SEPARATOR . "wallee-ca-bundle.crt";
$tempCAFile = sys_get_temp_dir() . DIRECTORY_SEPARATOR . "tmp-ca-bundle.crt";

// set timeout, if needed
if ($request->getTimeOut() !== 0) {
Expand All @@ -62,7 +85,7 @@ public function send(ApiClient $apiClient, HttpRequest $request) {
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2);
if (file_exists($tempCAFile)) {
// use the temporal CA Bundle if it was set, which indicates a previous error.
// Use the temporal CA Bundle if it was set, which indicates a previous error.
$apiClient->setCertificateAuthority($tempCAFile);
curl_setopt($curl, CURLOPT_CAINFO, $apiClient->getCertificateAuthority());
}
Expand Down Expand Up @@ -96,7 +119,7 @@ public function send(ApiClient $apiClient, HttpRequest $request) {
// debugging for curl
$debugFilePointer = fopen($apiClient->getDebugFile(), 'a');
if ($apiClient->isDebuggingEnabled()) {
error_log("[DEBUG] HTTP Request body ~BEGIN~".PHP_EOL.print_r($request->getBody(), true).PHP_EOL."~END~".PHP_EOL, 3, $apiClient->getDebugFile());
error_log("[DEBUG] HTTP Request body ~BEGIN~" . PHP_EOL . print_r($request->getBody(), true) . PHP_EOL . "~END~" . PHP_EOL, 3, $apiClient->getDebugFile());

curl_setopt($curl, CURLOPT_VERBOSE, 1);
curl_setopt($curl, CURLOPT_STDERR, $debugFilePointer);
Expand All @@ -108,48 +131,78 @@ public function send(ApiClient $apiClient, HttpRequest $request) {
curl_setopt($curl, CURLOPT_HEADER, 1);

// Make the request
$response = curl_exec($curl);
if ($response) {
$response = $this->handleResponse($apiClient, $request, $curl, $response, $request->getUrl());
} else {
// if there was an error, try again with the CA bundle provided by this SDK.
if (!file_exists($tempCAFile)) {
$caContent = file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . "ca-bundle.crt");
$curlResponse = curl_exec($curl);
if ($curlResponse === FALSE && !file_exists($tempCAFile)) {
$errNo = curl_errno($curl);
$errStr = curl_error($curl);
if ($errNo === CURLE_SSL_CERTPROBLEM || substr_count(strtolower($errStr), "ssl")) {
$pathToCABundle = __DIR__ . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . "ca-bundle.crt";
$caContent = file_get_contents($pathToCABundle);
// Create the temporal CA file, so it can be reused later on if needed.
file_put_contents($tempCAFile, $caContent);

// Try again the request, this time with the CA bundle provided by this SDK.
$apiClient->setCertificateAuthority($tempCAFile);
curl_setopt($curl, CURLOPT_CAINFO, $apiClient->getCertificateAuthority());
$response = curl_exec($curl);
$response = $this->handleResponse($apiClient, $request, $curl, $response, $request->getUrl());
$curlResponse = curl_exec($curl);
if ($curlResponse === FALSE) {
// The request still failed, so the CA bundle did not help.
// Restore system CA, and an error will be triggered later on.
unlink($tempCAFile);
}
}
}

curl_close($curl);
fclose($debugFilePointer);
try {
$httpResponse = $this->handleResponse($apiClient, $request, $curl, $curlResponse, $request->getUrl());
}
catch (ConnectionException $e) {
throw $e;
}
finally {
curl_close($curl);
fclose($debugFilePointer);
}

return $response;
return $httpResponse;
}

/**
* Puts together the HTTP response.
*
* @param ApiClient $apiClient the API client instance
* @param HttpRequest $request the HTTP request
* @param resource $curl the cURL handler
* @param mixed $response the response the of HTTP request
* @param string $url the url of the HTTP request
* @param ApiClient $apiClient
* The API client instance
* @param HttpRequest $request
* The HTTP request
* @param resource \CurlHandle $curl
* The cURL handler
* @param string|bool $curlResponse
* The response the from the $request, via curl_exec
* @param string $url
* The url of the HTTP request
* @return HttpResponse
* @throws ConnectionException
*/
private function handleResponse(ApiClient $apiClient, HttpRequest $request, $curl, $response, $url) {
private function handleResponse(ApiClient $apiClient, HttpRequest $request, \CurlHandle $curl, string|bool $curlResponse, string $url): HttpResponse {
$httpHeaderSize = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
$httpHeader = substr($response, 0, $httpHeaderSize);
$httpBody = substr($response, $httpHeaderSize);

// Handle the case where $curlResponse is false (indicating an error)
if ($curlResponse === FALSE) {
$errStr = curl_error($curl);

if (!empty($errStr)) {
throw new ConnectionException($url, $request->getLogToken(), $errStr);
} else {
throw new ConnectionException($url, $request->getLogToken(), 'API call failed for an unknown reason.');
}
}
$httpHeader = substr($curlResponse, 0, $httpHeaderSize);
$httpBody = substr($curlResponse, $httpHeaderSize);
$responseInfo = curl_getinfo($curl);

// debug HTTP response body
if ($apiClient->isDebuggingEnabled()) {
error_log("[DEBUG] HTTP Response body ~BEGIN~".PHP_EOL.print_r($httpBody, true).PHP_EOL."~END~".PHP_EOL, 3, $apiClient->getDebugFile());
error_log("[DEBUG] HTTP Response body ~BEGIN~" . PHP_EOL . print_r($httpBody, true) . PHP_EOL . "~END~".PHP_EOL, 3, $apiClient->getDebugFile());
}

if ($responseInfo['http_code'] === 0) {
Expand All @@ -165,5 +218,4 @@ private function handleResponse(ApiClient $apiClient, HttpRequest $request, $cur
return new HttpResponse($responseInfo['http_code'], $httpHeader, $httpBody);
}
}

}
14 changes: 7 additions & 7 deletions wallee-sdk/lib/Model/AbstractDebtCollectionCaseUpdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ public function getBillingAddress()
/**
* Sets billing_address
*
* @param \Wallee\Sdk\Model\AddressCreate $billing_address The billing address of the case identifies the debtor.
* @param \Wallee\Sdk\Model\AddressCreate $billing_address The billing address that identifies the debtor.
*
* @return $this
*/
Expand All @@ -286,7 +286,7 @@ public function getContractDate()
/**
* Sets contract_date
*
* @param \DateTime $contract_date The contract date is the date on which the contract with the debtor was signed on.
* @param \DateTime $contract_date The date and time when the contract with the debtor was signed.
*
* @return $this
*/
Expand All @@ -311,7 +311,7 @@ public function getCurrency()
/**
* Sets currency
*
* @param string $currency The currency defines the billing currency of the debt collection case.
* @param string $currency The three-letter code (ISO 4217 format) of the case's currency.
*
* @return $this
*/
Expand All @@ -336,7 +336,7 @@ public function getDueDate()
/**
* Sets due_date
*
* @param \DateTime $due_date The due date indicates the date on which the amount receivable was due. This date has to be always in the past.
* @param \DateTime $due_date The date and time when the claim was due.
*
* @return $this
*/
Expand All @@ -361,7 +361,7 @@ public function getEnvironment()
/**
* Sets environment
*
* @param \Wallee\Sdk\Model\DebtCollectionEnvironment $environment The environment in which this case will be processed. There must be a debt collector configuration present which supports the chosen environment.
* @param \Wallee\Sdk\Model\DebtCollectionEnvironment $environment The environment in which the case is processed.
*
* @return $this
*/
Expand All @@ -386,7 +386,7 @@ public function getLanguage()
/**
* Sets language
*
* @param string $language The language indicates the language to be used in the communication with the debtor.
* @param string $language The language that is linked to the object.
*
* @return $this
*/
Expand All @@ -411,7 +411,7 @@ public function getLineItems()
/**
* Sets line_items
*
* @param \Wallee\Sdk\Model\LineItemCreate[] $line_items The line items of the debt collection case will be shown on documents sent to the debtor and the total of them makes up total amount to collect.
* @param \Wallee\Sdk\Model\LineItemCreate[] $line_items The line items that are subject of this debt collection case.
*
* @return $this
*/
Expand Down
Loading

0 comments on commit 11d1fca

Please sign in to comment.