forked from Adyen/adyen-php-api-library
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PW-2250] Outsource the builders from PrestaShop to the php api libra…
…ry (Adyen#206) * Added: The remaining request builders The functionality for Open Invoice The unit test for the utils and builders * Convert id to string in the openinvoiceTest * Sonar cloud code smell fixes * Sonar cloud code smell fixes 2 * Suppress sonar cloud wanring for many paramater on builder * try to suppress sonar warning for paramaters on builder * try to suppress sonar anotate class * try to suppress sonar warnings with Suppress anotation * Try to suppress warnings again * Id and ItemId to string * Fix suggested changes * Refactor isAuthenticated * Add copyright
- Loading branch information
1 parent
f6e8f38
commit 51f54e0
Showing
12 changed files
with
694 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<?php | ||
/** | ||
* ###### | ||
* ###### | ||
* ############ ####( ###### #####. ###### ############ ############ | ||
* ############# #####( ###### #####. ###### ############# ############# | ||
* ###### #####( ###### #####. ###### ##### ###### ##### ###### | ||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ###### | ||
* ###### ###### #####( ###### #####. ###### ##### ##### ###### | ||
* ############# ############# ############# ############# ##### ###### | ||
* ############ ############ ############# ############ ##### ###### | ||
* ###### | ||
* ############# | ||
* ############ | ||
* | ||
* Adyen API Library for PHP | ||
* | ||
* Copyright (c) 2020 Adyen N.V. | ||
* This file is open source and available under the MIT license. | ||
* See the LICENSE file for more info. | ||
* | ||
*/ | ||
|
||
namespace Adyen\Service\Builder; | ||
|
||
class Browser | ||
{ | ||
const BROWSER_INFO = 'browserInfo'; | ||
|
||
/** | ||
* @param string $userAgent | ||
* @param string $acceptHeader | ||
* @param int $screenWidth | ||
* @param int $screenHeight | ||
* @param int $colorDepth | ||
* @param int $timeZoneOffsetß | ||
* @param string $language | ||
* @param bool $javaEnabled | ||
* @param array $request | ||
* @return array | ||
* @SuppressWarnings:php:S107 | ||
*/ | ||
public function buildBrowserData( | ||
$userAgent = '', | ||
$acceptHeader = '', | ||
$screenWidth = 0, | ||
$screenHeight = 0, | ||
$colorDepth = 0, | ||
$timeZoneOffset = 0, | ||
$language = '', | ||
$javaEnabled = false, | ||
$request = array() | ||
) { | ||
if (!empty($userAgent)) { | ||
$request[self::BROWSER_INFO]['userAgent'] = $userAgent; | ||
} | ||
|
||
if (!empty($acceptHeader)) { | ||
$request[self::BROWSER_INFO]['acceptHeader'] = $acceptHeader; | ||
} | ||
|
||
if (!empty($screenWidth)) { | ||
$request[self::BROWSER_INFO]['screenWidth'] = $screenWidth; | ||
} | ||
|
||
if (!empty($screenHeight)) { | ||
$request[self::BROWSER_INFO]['screenHeight'] = $screenHeight; | ||
} | ||
|
||
if (!empty($colorDepth)) { | ||
$request[self::BROWSER_INFO]['colorDepth'] = $colorDepth; | ||
} | ||
|
||
if (!empty($timeZoneOffset)) { | ||
$request[self::BROWSER_INFO]['timeZoneOffset'] = $timeZoneOffset; | ||
} | ||
|
||
if (!empty($language)) { | ||
$request[self::BROWSER_INFO]['language'] = $language; | ||
} | ||
|
||
$request[self::BROWSER_INFO]['javaEnabled'] = $javaEnabled; | ||
|
||
return $request; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
/** | ||
* ###### | ||
* ###### | ||
* ############ ####( ###### #####. ###### ############ ############ | ||
* ############# #####( ###### #####. ###### ############# ############# | ||
* ###### #####( ###### #####. ###### ##### ###### ##### ###### | ||
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ###### | ||
* ###### ###### #####( ###### #####. ###### ##### ##### ###### | ||
* ############# ############# ############# ############# ##### ###### | ||
* ############ ############ ############# ############ ##### ###### | ||
* ###### | ||
* ############# | ||
* ############ | ||
* | ||
* Adyen API Library for PHP | ||
* | ||
* Copyright (c) 2020 Adyen N.V. | ||
* This file is open source and available under the MIT license. | ||
* See the LICENSE file for more info. | ||
* | ||
*/ | ||
|
||
namespace Adyen\Service\Builder; | ||
|
||
use Adyen\Util\Currency; | ||
|
||
class Refund | ||
{ | ||
/** | ||
* @param $orderAmount | ||
* @param stirng $orderId | ||
* @param stirng $pspReference | ||
* @param string $currency | ||
* @param string $merchantAccount | ||
* | ||
* @return array | ||
*/ | ||
public function buildRefundRequest($orderAmount, $orderId, $pspReference, $currency, $merchantAccount) | ||
{ | ||
$currencyConverter = new Currency(); | ||
$amount = $currencyConverter->sanitize($orderAmount, $currency); | ||
|
||
return | ||
array( | ||
'originalReference' => $pspReference, | ||
'modificationAmount' => array( | ||
'value' => $amount, | ||
'currency' => $currency | ||
), | ||
'reference' => $orderId, | ||
'merchantAccount' => $merchantAccount | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.