Skip to content

Commit

Permalink
V1.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Webtica committed Mar 13, 2022
1 parent 0de1615 commit b098ca2
Show file tree
Hide file tree
Showing 9 changed files with 132 additions and 27 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ Yes, all the other form widget integrations will be available.

## Changelog

### 1.2.1 - 13-03-2022
* Update composer libaries
* Tested Elementor PRO up to 3.6.3
* Tested Elementor up to 3.5.6
* Tested WordPress up to 5.9.2

### 1.2.0 - 24-01-2022
* Added support link
* Update composer libaries
Expand Down
12 changes: 6 additions & 6 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions mollie-elementor-integration.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
* Description: Easily create payments with Mollie after an elementor form submission.
* Author: Webtica
* Author URI: https://webtica.be/
* Version: 1.2.0
* Elementor tested up to: 3.5.4
* Elementor Pro tested up to: 3.5.2
* Version: 1.2.1
* Elementor tested up to: 3.5.6
* Elementor Pro tested up to: 3.6.3
*/

// Exit if accessed directly
Expand Down
10 changes: 8 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
Contributors: webtica
Tags: mollie, elementor, elementor pro, forms, integration, marketing, lists, payments, automation
Requires at least: 5.0
Tested up to: 5.9
Tested up to: 5.9.2
Requires PHP: 5.4
Stable tag: 1.2.0
Stable tag: 1.2.1
License: GPLv3
License URI: https://www.gnu.org/licenses/gpl-3.0.html

Expand Down Expand Up @@ -50,6 +50,12 @@ Yes, all the other form widget integrations will be available.

== Changelog ==

= 1.2.1 - 2022-03-13 =
* Update composer libaries
* Tested Elementor PRO up to 3.6.3
* Tested Elementor up to 3.5.6
* Tested WordPress up to 5.9.2

= 1.2.0 - 2022-01-24 =
* Added support link
* Update composer libaries
Expand Down
14 changes: 7 additions & 7 deletions vendor/composer/installed.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,17 @@
},
{
"name": "mollie/mollie-api-php",
"version": "v2.40.1",
"version_normalized": "2.40.1.0",
"version": "v2.40.2",
"version_normalized": "2.40.2.0",
"source": {
"type": "git",
"url": "https://github.com/mollie/mollie-api-php.git",
"reference": "b99ad3662b4141efa9ee8eb83a04c2d3c100f83c"
"reference": "ac3e079bbc86e95dc77d4f33965a62e9e6b95ed8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/mollie/mollie-api-php/zipball/b99ad3662b4141efa9ee8eb83a04c2d3c100f83c",
"reference": "b99ad3662b4141efa9ee8eb83a04c2d3c100f83c",
"url": "https://api.github.com/repos/mollie/mollie-api-php/zipball/ac3e079bbc86e95dc77d4f33965a62e9e6b95ed8",
"reference": "ac3e079bbc86e95dc77d4f33965a62e9e6b95ed8",
"shasum": ""
},
"require": {
Expand All @@ -110,7 +110,7 @@
"suggest": {
"mollie/oauth2-mollie-php": "Use OAuth to authenticate with the Mollie API. This is needed for some endpoints. Visit https://docs.mollie.com/ for more information."
},
"time": "2022-01-18T18:16:13+00:00",
"time": "2022-02-08T08:53:18+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
Expand Down Expand Up @@ -169,7 +169,7 @@
],
"support": {
"issues": "https://github.com/mollie/mollie-api-php/issues",
"source": "https://github.com/mollie/mollie-api-php/tree/v2.40.1"
"source": "https://github.com/mollie/mollie-api-php/tree/v2.40.2"
},
"install-path": "../mollie/mollie-api-php"
}
Expand Down
10 changes: 5 additions & 5 deletions vendor/composer/installed.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
'type' => 'library',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
'reference' => 'aa248abd3dc49bb1c85318904e50ad3418e6b9b6',
'reference' => '0de16159ec4d15ec0f134e9a9c3b861c66ff21a2',
'name' => '__root__',
'dev' => true,
),
Expand All @@ -16,7 +16,7 @@
'type' => 'library',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
'reference' => 'aa248abd3dc49bb1c85318904e50ad3418e6b9b6',
'reference' => '0de16159ec4d15ec0f134e9a9c3b861c66ff21a2',
'dev_requirement' => false,
),
'composer/ca-bundle' => array(
Expand All @@ -29,12 +29,12 @@
'dev_requirement' => false,
),
'mollie/mollie-api-php' => array(
'pretty_version' => 'v2.40.1',
'version' => '2.40.1.0',
'pretty_version' => 'v2.40.2',
'version' => '2.40.2.0',
'type' => 'library',
'install_path' => __DIR__ . '/../mollie/mollie-api-php',
'aliases' => array(),
'reference' => 'b99ad3662b4141efa9ee8eb83a04c2d3c100f83c',
'reference' => 'ac3e079bbc86e95dc77d4f33965a62e9e6b95ed8',
'dev_requirement' => false,
),
),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

namespace Mollie\Api\Exceptions;

class CurlConnectTimeoutException extends ApiException
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Composer\CaBundle\CaBundle;
use Mollie\Api\Exceptions\ApiException;
use Mollie\Api\Exceptions\CurlConnectTimeoutException;
use Mollie\Api\MollieApiClient;

final class CurlMollieHttpAdapter implements MollieHttpAdapterInterface
Expand All @@ -23,15 +24,51 @@ final class CurlMollieHttpAdapter implements MollieHttpAdapterInterface
*/
const HTTP_NO_CONTENT = 204;

/**
* The maximum number of retries
*/
const MAX_RETRIES = 5;

/**
* The amount of milliseconds the delay is being increased with on each retry.
*/
const DELAY_INCREASE_MS = 1000;

/**
* @param string $httpMethod
* @param string $url
* @param array $headers
* @param $httpBody
* @return \stdClass|null
* @return \stdClass|void|null
* @throws \Mollie\Api\Exceptions\ApiException
* @throws \Mollie\Api\Exceptions\CurlConnectTimeoutException
*/
public function send($httpMethod, $url, $headers, $httpBody)
{
for ($i = 0; $i <= self::MAX_RETRIES; $i++) {
usleep($i * self::DELAY_INCREASE_MS);

try {
return $this->attemptRequest($httpMethod, $url, $headers, $httpBody);
} catch (CurlConnectTimeoutException $e) {
// Nothing
}
}

throw new CurlConnectTimeoutException(
"Unable to connect to Mollie. Maximum number of retries (". self::MAX_RETRIES .") reached."
);
}

/**
* @param string $httpMethod
* @param string $url
* @param array $headers
* @param $httpBody
* @return \stdClass|void|null
* @throws \Mollie\Api\Exceptions\ApiException
*/
protected function attemptRequest($httpMethod, $url, $headers, $httpBody)
{
$curl = curl_init($url);
$headers["Content-Type"] = "application/json";
Expand Down Expand Up @@ -65,14 +102,23 @@ public function send($httpMethod, $url, $headers, $httpBody)
throw new \InvalidArgumentException("Invalid http method: ". $httpMethod);
}

$startTime = microtime(true);
$response = curl_exec($curl);
$endTime = microtime(true);

if ($response === false) {
throw new ApiException("Curl error: " . curl_error($curl));
$executionTime = $endTime - $startTime;
$curlErrorNumber = curl_errno($curl);
$curlErrorMessage = "Curl error: " . curl_error($curl);

if ($this->isConnectTimeoutError($curlErrorNumber, $executionTime)) {
throw new CurlConnectTimeoutException("Unable to connect to Mollie. " . $curlErrorMessage);
}

throw new ApiException($curlErrorMessage);
}

$statusCode = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);

curl_close($curl);

return $this->parseResponseBody($response, $statusCode, $httpBody);
Expand All @@ -89,6 +135,46 @@ public function versionString()
return 'Curl/*';
}

/**
* Whether this http adapter provides a debugging mode. If debugging mode is enabled, the
* request will be included in the ApiException.
*
* @return false
*/
public function supportsDebugging()
{
return false;
}

/**
* @param $curlErrorNumber
* @param $executionTime
* @return bool
*/
protected function isConnectTimeoutError($curlErrorNumber, $executionTime)
{
$connectErrors = [
\CURLE_COULDNT_RESOLVE_HOST => true,
\CURLE_COULDNT_CONNECT => true,
\CURLE_SSL_CONNECT_ERROR => true,
\CURLE_GOT_NOTHING => true,
];

if (isset($connectErrors[$curlErrorNumber])) {
return true;
};

if ($curlErrorNumber === \CURLE_OPERATION_TIMEOUTED) {
if ($executionTime > self::DEFAULT_TIMEOUT) {
return false;
}

return true;
}

return false;
}

/**
* @param string $response
* @param int $statusCode
Expand Down
2 changes: 1 addition & 1 deletion vendor/mollie/mollie-api-php/src/MollieApiClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class MollieApiClient
/**
* Version of our client.
*/
const CLIENT_VERSION = "2.40.1";
const CLIENT_VERSION = "2.40.2";

/**
* Endpoint of the remote API.
Expand Down

0 comments on commit b098ca2

Please sign in to comment.