Commit 1e538537 authored by Andy J's avatar Andy J

lib update, 7.2 rdy

parent 2368e126
......@@ -4,7 +4,7 @@
"description": "JTL-Shop Plugin",
"require": {
"php": ">=5.4.0",
"paypal/rest-api-sdk-php": "1.11.0",
"paypal/rest-api-sdk-php": "^1.13",
"paypal/merchant-sdk-php": "v3.9.1"
},
"autoload": {
......@@ -18,7 +18,6 @@
]
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.1",
"phpunit/phpunit": "^4.5 || ^5.0.5",
"phpunit/phpunit-mock-objects": "2.3.0 || ^3.0",
"Symfony/Finder": "^3.2"
......
This diff is collapsed.
......@@ -379,9 +379,9 @@ class ClassLoader
$subPath = substr($subPath, 0, $lastPos);
$search = $subPath.'\\';
if (isset($this->prefixDirsPsr4[$search])) {
$pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
foreach ($this->prefixDirsPsr4[$search] as $dir) {
$length = $this->prefixLengthsPsr4[$first][$search];
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) {
if (file_exists($file = $dir . $pathEnd)) {
return $file;
}
}
......
This diff is collapsed.
This diff is collapsed.
[
{
"name": "psr/log",
"version": "1.0.2",
"version_normalized": "1.0.2.0",
"name": "paypal/merchant-sdk-php",
"version": "v3.9.1",
"version_normalized": "3.9.1.0",
"source": {
"type": "git",
"url": "https://github.com/php-fig/log.git",
"reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d"
"url": "https://github.com/paypal/merchant-sdk-php.git",
"reference": "b2dd6628177904d9fe118da13df373e59be61b31"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/log/zipball/4ebe3a8bf773a19edfe0a84b6585ba3d401b724d",
"reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d",
"url": "https://api.github.com/repos/paypal/merchant-sdk-php/zipball/b2dd6628177904d9fe118da13df373e59be61b31",
"reference": "b2dd6628177904d9fe118da13df373e59be61b31",
"shasum": ""
},
"require": {
"ext-curl": "*",
"paypal/sdk-core-php": "3.*",
"php": ">=5.3.0"
},
"time": "2016-10-10T12:19:37+00:00",
"time": "2015-12-09T17:55:30+00:00",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-4": {
"Psr\\Log\\": "Psr/Log/"
"psr-0": {
"PayPal\\Service": "lib/",
"PayPal\\CoreComponentTypes": "lib/",
"PayPal\\EBLBaseComponents": "lib/",
"PayPal\\EnhancedDataTypes": "lib/",
"PayPal\\PayPalAPI": "lib/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
"Apache2"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "http://www.php-fig.org/"
"name": "PayPal",
"homepage": "https://github.com/paypal/merchant-sdk-php/contributors"
}
],
"description": "Common interface for logging libraries",
"homepage": "https://github.com/php-fig/log",
"description": "PayPal Merchant SDK for PHP",
"homepage": "https://developer.paypal.com",
"keywords": [
"log",
"psr",
"psr-3"
"paypal",
"php",
"sdk"
]
},
{
"name": "paypal/rest-api-sdk-php",
"version": "1.11.0",
"version_normalized": "1.11.0.0",
"version": "1.13.0",
"version_normalized": "1.13.0.0",
"source": {
"type": "git",
"url": "https://github.com/paypal/PayPal-PHP-SDK.git",
"reference": "7e664f12be32b975575371e8ad3bc17b6b318851"
"reference": "192e217beed14c8e75624e821fdc8ec51e2a21f5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/paypal/PayPal-PHP-SDK/zipball/7e664f12be32b975575371e8ad3bc17b6b318851",
"reference": "7e664f12be32b975575371e8ad3bc17b6b318851",
"url": "https://api.github.com/repos/paypal/PayPal-PHP-SDK/zipball/192e217beed14c8e75624e821fdc8ec51e2a21f5",
"reference": "192e217beed14c8e75624e821fdc8ec51e2a21f5",
"shasum": ""
},
"require": {
......@@ -70,9 +71,9 @@
"psr/log": "^1.0.0"
},
"require-dev": {
"phpunit/phpunit": "3.7.*"
"phpunit/phpunit": "^4.8.35"
},
"time": "2016-12-14T21:59:21+00:00",
"time": "2017-11-13T19:21:59+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
......@@ -101,17 +102,17 @@
},
{
"name": "paypal/sdk-core-php",
"version": "3.3.2",
"version_normalized": "3.3.2.0",
"version": "3.4.0",
"version_normalized": "3.4.0.0",
"source": {
"type": "git",
"url": "https://github.com/paypal/sdk-core-php.git",
"reference": "6e4ebde3bc2978f80ddf96441194577f59fe5045"
"reference": "d2174f69f9811a8f2e79af7498fdf89586457d76"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/paypal/sdk-core-php/zipball/6e4ebde3bc2978f80ddf96441194577f59fe5045",
"reference": "6e4ebde3bc2978f80ddf96441194577f59fe5045",
"url": "https://api.github.com/repos/paypal/sdk-core-php/zipball/d2174f69f9811a8f2e79af7498fdf89586457d76",
"reference": "d2174f69f9811a8f2e79af7498fdf89586457d76",
"shasum": ""
},
"require": {
......@@ -121,7 +122,7 @@
"require-dev": {
"phpunit/phpunit": "3.7.*"
},
"time": "2016-10-25T17:18:46+00:00",
"time": "2017-11-13T18:53:13+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
......@@ -148,53 +149,52 @@
]
},
{
"name": "paypal/merchant-sdk-php",
"version": "v3.9.1",
"version_normalized": "3.9.1.0",
"name": "psr/log",
"version": "1.1.0",
"version_normalized": "1.1.0.0",
"source": {
"type": "git",
"url": "https://github.com/paypal/merchant-sdk-php.git",
"reference": "b2dd6628177904d9fe118da13df373e59be61b31"
"url": "https://github.com/php-fig/log.git",
"reference": "6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/paypal/merchant-sdk-php/zipball/b2dd6628177904d9fe118da13df373e59be61b31",
"reference": "b2dd6628177904d9fe118da13df373e59be61b31",
"url": "https://api.github.com/repos/php-fig/log/zipball/6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd",
"reference": "6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd",
"shasum": ""
},
"require": {
"ext-curl": "*",
"paypal/sdk-core-php": "3.*",
"php": ">=5.3.0"
},
"time": "2015-12-09T17:55:30+00:00",
"time": "2018-11-20T15:27:04+00:00",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-0": {
"PayPal\\Service": "lib/",
"PayPal\\CoreComponentTypes": "lib/",
"PayPal\\EBLBaseComponents": "lib/",
"PayPal\\EnhancedDataTypes": "lib/",
"PayPal\\PayPalAPI": "lib/"
"psr-4": {
"Psr\\Log\\": "Psr/Log/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"Apache2"
"MIT"
],
"authors": [
{
"name": "PayPal",
"homepage": "https://github.com/paypal/merchant-sdk-php/contributors"
"name": "PHP-FIG",
"homepage": "http://www.php-fig.org/"
}
],
"description": "PayPal Merchant SDK for PHP",
"homepage": "https://developer.paypal.com",
"description": "Common interface for logging libraries",
"homepage": "https://github.com/php-fig/log",
"keywords": [
"paypal",
"php",
"sdk"
"log",
"psr",
"psr-3"
]
}
]
......@@ -6,8 +6,9 @@ use PayPal\Common\PayPalModel;
/**
* Class BankAccount
*
*
* A resource representing a bank account that can be used to fund a payment.
* @deprecated Deprecated. It is for internal use only. It may be removed in next major revision.
*
* @package PayPal\Api
*
......
......@@ -19,6 +19,7 @@ use PayPal\Validation\UrlValidator;
* @property string note_to_payee
* @property string custom
* @property string invoice_number
* @property string purchase_order
* @property string soft_descriptor
* @property \PayPal\Api\PaymentOptions payment_options
* @property \PayPal\Api\ItemList item_list
......@@ -188,6 +189,29 @@ class CartBase extends PayPalModel
return $this->invoice_number;
}
/**
* purchase order is number or id specific to this payment
*
* @param string $purchase_order
*
* @return $this
*/
public function setPurchaseOrder($purchase_order)
{
$this->purchase_order = $purchase_order;
return $this;
}
/**
* purchase order is number or id specific to this payment
*
* @return string
*/
public function getPurchaseOrder()
{
return $this->purchase_order;
}
/**
* Soft descriptor used when charging this funding source. If length exceeds max length, the value will be truncated
*
......
......@@ -18,13 +18,11 @@ class FuturePayment extends Payment
*
* @param null $apiContext
* @param string|null $clientMetadataId
* @param PayPalRestCall|null $restCall is the Rest Call Service that is used to make rest calls
* @return $this
*/
public function create($apiContext = null, $clientMetadataId = null)
public function create($apiContext = null, $clientMetadataId = null, $restCall = null)
{
if ($apiContext == null) {
$apiContext = new ApiContext(self::$credential);
}
$headers = array();
if ($clientMetadataId != null) {
$headers = array(
......@@ -32,18 +30,16 @@ class FuturePayment extends Payment
);
}
$payLoad = $this->toJSON();
$call = new PayPalRestCall($apiContext);
$json = $call->execute(
array('PayPal\Handler\RestHandler'),
$json = self::executeCall(
"/v1/payments/payment",
"POST",
$payLoad,
$headers
$headers,
$apiContext,
$restCall
);
$this->fromJson($json);
return $this;
}
/**
......
......@@ -219,9 +219,10 @@ class OpenIdTokeninfo extends PayPalResourceModel
* (optional) grant_type is the Token grant type. Defaults to refresh_token
* (optional) scope is an array that either the same or a subset of the scope passed to the authorization request
* @param APIContext $apiContext Optional API Context
* @param PayPalRestCall $restCall
* @return OpenIdTokeninfo
*/
public function createFromRefreshToken($params, $apiContext = null)
public function createFromRefreshToken($params, $apiContext = null, $restCall = null)
{
static $allowedParams = array('grant_type' => 1, 'refresh_token' => 1, 'scope' => 1);
$apiContext = $apiContext ? $apiContext : new ApiContext(self::$credential);
......@@ -244,7 +245,8 @@ class OpenIdTokeninfo extends PayPalResourceModel
'Content-Type' => 'application/x-www-form-urlencoded',
'Authorization' => 'Basic ' . base64_encode($clientId . ":" . $clientSecret)
),
$apiContext
$apiContext,
$restCall
);
$this->fromJson($json);
......
......@@ -505,9 +505,10 @@ class OpenIdUserinfo extends PayPalResourceModel
* @param array $params (allowed values are access_token)
* access_token - access token from the createFromAuthorizationCode / createFromRefreshToken calls
* @param ApiContext $apiContext Optional API Context
* @param PayPalRestCall $restCall
* @return OpenIdUserinfo
*/
public static function getUserinfo($params, $apiContext = null)
public static function getUserinfo($params, $apiContext = null, $restCall = null)
{
static $allowedParams = array('schema' => 1);
......@@ -527,7 +528,8 @@ class OpenIdUserinfo extends PayPalResourceModel
'Authorization' => "Bearer " . $params['access_token'],
'Content-Type' => 'x-www-form-urlencoded'
),
$apiContext
$apiContext,
$restCall
);
$ret = new OpenIdUserinfo();
......
......@@ -544,7 +544,19 @@ class Payment extends PayPalResourceModel
{
return $this->getLink(PayPalConstants::APPROVAL_URL);
}
/**
* Get token from Approval Link
*
* @return null|string
*/
public function getToken()
{
$parameter_name = "token";
parse_str(parse_url($this->getApprovalLink(), PHP_URL_QUERY), $query);
return !isset($query[$parameter_name]) ? null : $query[$parameter_name];
}
/**
* Creates and processes a payment. In the JSON request body, include a `payment` object with the intent, payer, and transactions. For PayPal payments, include redirect URLs in the `payment` object.
*
......
......@@ -29,7 +29,7 @@ class VerifyWebhookSignature extends PayPalResourceModel
* The algorithm that PayPal uses to generate the signature and that you can use to verify the signature. Extract this value from the `PAYPAL-AUTH-ALGO` response header, which is received with the webhook notification.
*
* @param string $auth_algo
*
*
* @return $this
*/
public function setAuthAlgo($auth_algo)
......@@ -76,7 +76,7 @@ class VerifyWebhookSignature extends PayPalResourceModel
* The ID of the HTTP transmission. Contained in the `PAYPAL-TRANSMISSION-ID` header of the notification message.
*
* @param string $transmission_id
*
*
* @return $this
*/
public function setTransmissionId($transmission_id)
......@@ -99,7 +99,7 @@ class VerifyWebhookSignature extends PayPalResourceModel
* The PayPal-generated asymmetric signature. Extract this value from the `PAYPAL-TRANSMISSION-SIG` response header, which is received with the webhook notification.
*
* @param string $transmission_sig
*
*
* @return $this
*/
public function setTransmissionSig($transmission_sig)
......@@ -122,7 +122,7 @@ class VerifyWebhookSignature extends PayPalResourceModel
* The date and time of the HTTP transmission. Contained in the `PAYPAL-TRANSMISSION-TIME` header of the notification message.
*
* @param string $transmission_time
*
*
* @return $this
*/
public function setTransmissionTime($transmission_time)
......@@ -145,7 +145,7 @@ class VerifyWebhookSignature extends PayPalResourceModel
* The ID of the webhook as configured in your Developer Portal account.
*
* @param string $webhook_id
*
*
* @return $this
*/
public function setWebhookId($webhook_id)
......@@ -166,9 +166,9 @@ class VerifyWebhookSignature extends PayPalResourceModel
/**
* The webhook notification, which is the content of the HTTP `POST` request body.
*
* @deprecated Please use setRequestBody($request_body) instead.
* @param \PayPal\Api\WebhookEvent $webhook_event
*
*
* @return $this
*/
public function setWebhookEvent($webhook_event)
......@@ -187,6 +187,29 @@ class VerifyWebhookSignature extends PayPalResourceModel
return $this->webhook_event;
}
/**
* The content of the HTTP `POST` request body of the webhook notification you received as a string.
*
* @param string $request_body
*
* @return $this
*/
public function setRequestBody($request_body)
{
$this->request_body = $request_body;
return $this;
}
/**
* The content of the HTTP `POST` request body of the webhook notification you received as a string.
*
* @return string
*/
public function getRequestBody()
{
return $this->request_body;
}
/**
* Verifies a webhook signature.
*
......@@ -197,6 +220,7 @@ class VerifyWebhookSignature extends PayPalResourceModel
public function post($apiContext = null, $restCall = null)
{
$payLoad = $this->toJSON();
$json = self::executeCall(
"/v1/notifications/verify-webhook-signature",
"POST",
......@@ -210,4 +234,23 @@ class VerifyWebhookSignature extends PayPalResourceModel
return $ret;
}
public function toJSON($options = 0)
{
if (!is_null($this->request_body)) {
$valuesToEncode = $this->toArray();
unset($valuesToEncode['webhook_event']);
unset($valuesToEncode['request_body']);
$payLoad = "{";
foreach ($valuesToEncode as $field => $value) {
$payLoad .= "\"$field\": \"$value\",";
}
$payLoad .= "\"webhook_event\": $this->request_body";
$payLoad .= "}";
return $payLoad;
} else {
$payLoad = parent::toJSON($options);
return $payLoad;
}
}
}
......@@ -226,6 +226,11 @@ class OAuthTokenCredential extends PayPalResourceModel
{
$httpConfig = new PayPalHttpConfig(null, 'POST', $config);
// if proxy set via config, add it
if (!empty($config['http.Proxy'])) {
$httpConfig->setHttpProxy($config['http.Proxy']);
}
$handlers = array(self::$AUTH_HANDLER);
/** @var IPayPalHandler $handler */
......
......@@ -3,7 +3,6 @@
namespace PayPal\Common;
use PayPal\Validation\JsonValidator;
use PayPal\Validation\ModelAccessorValidator;
/**
* Generic Model class that all API domain classes extend
......@@ -39,7 +38,7 @@ class PayPalModel
* You can pass data as a json representation or array object. This argument eliminates the need
* to do $obj->fromJson($data) later after creating the object.
*
* @param null $data
* @param array|string|null $data
* @throws \InvalidArgumentException
*/
public function __construct($data = null)
......@@ -176,7 +175,7 @@ class PayPalModel
foreach ($param as $k => $v) {
if ($v instanceof PayPalModel) {
$ret[$k] = $v->toArray();
} elseif (sizeof($v) <= 0 && is_array($v)) {
} elseif (is_array($v) && sizeof($v) <= 0) {
$ret[$k] = array();
} elseif (is_array($v)) {
$ret[$k] = $this->_convertToArray($v);
......
......@@ -41,9 +41,11 @@ class PayPalResourceModel extends PayPalModel implements IResource
public function getLink($rel)
{
foreach ($this->links as $link) {
if ($link->getRel() == $rel) {
return $link->getHref();
if (is_array($this->links)) {
foreach ($this->links as $link) {
if ($link->getRel() == $rel) {
return $link->getHref();
}
}
}
return null;
......
......@@ -46,10 +46,10 @@ class FormatConverter
public static function formatToPrice($value, $currency = null)
{
$decimals = 2;
$currencyDecimals = array('JPY' => 0, 'TWD' => 0);
$currencyDecimals = array('JPY' => 0, 'TWD' => 0, 'HUF' => 0);
if ($currency && array_key_exists($currency, $currencyDecimals)) {
if (strpos($value, ".") !== false && (floor($value) != $value)) {
//throw exception if it has decimal values for JPY and TWD which does not ends with .00
//throw exception if it has decimal values for JPY, TWD and HUF which does not ends with .00
throw new \InvalidArgumentException("value cannot have decimals for $currency currency");
}
$decimals = $currencyDecimals[$currency];
......
......@@ -99,9 +99,11 @@ class PayPalConfigManager
return $this->configs[$searchKey];
} else {
$arr = array();
foreach ($this->configs as $k => $v) {
if (strstr($k, $searchKey)) {
$arr[$k] = $v;
if ($searchKey !== '') {
foreach ($this->configs as $k => $v) {
if (strstr($k, $searchKey)) {
$arr[$k] = $v;
}
}
}
......
......@@ -12,7 +12,7 @@ class PayPalConstants
{
const SDK_NAME = 'PayPal-PHP-SDK';
const SDK_VERSION = '1.11.0';
const SDK_VERSION = '1.13.0';
/**
* Approval URL for Payment
......
......@@ -27,7 +27,7 @@ class PayPalHttpConfig
CURLOPT_HTTPHEADER => array(),
CURLOPT_SSL_VERIFYHOST => 2,
CURLOPT_SSL_VERIFYPEER => 1,
CURLOPT_SSL_CIPHER_LIST => 'TLSv1'
CURLOPT_SSL_CIPHER_LIST => 'TLSv1:TLSv1.2'
//Allowing TLSv1 cipher list.
//Adding it like this for backward compatibility with older versions of curl
);
......
......@@ -25,6 +25,16 @@ class PayPalHttpConnection
*/
private $logger;
/**
* @var array
*/
private $responseHeaders = array();
/**
* @var bool
*/
private $skippedHttpStatusLine = false;
/**
* Default Constructor
*
......@@ -55,6 +65,57 @@ class PayPalHttpConnection
return $ret;
}
/**
* Parses the response headers for debugging.
*
* @param resource $ch
* @param string $data
* @return int
*/
protected function parseResponseHeaders($ch, $data) {
if (!$this->skippedHttpStatusLine) {
$this->skippedHttpStatusLine = true;
return strlen($data);
}
$trimmedData = trim($data);
if (strlen($trimmedData) == 0) {
return strlen($data);
}
list($key, $value) = explode(":", $trimmedData, 2);
$key = trim($key);
$value = trim($value);
// This will skip over the HTTP Status Line and any other lines
// that don't look like header lines with values
if (strlen($key) > 0 && strlen($value) > 0) {
// This is actually a very basic way of looking at response headers
// and may miss a few repeated headers with different (appended)
// values but this should work for debugging purposes.
$this->responseHeaders[$key] = $value;
}
return strlen($data);
}
/**
* Implodes a key/value array for printing.
*
* @param array $arr
* @return string
*/
protected function implodeArray($arr) {
$retStr = '';
foreach($arr as $key => $value) {
$retStr .= $key . ': ' . $value . ', ';
}
rtrim($retStr, ', ');
return $retStr;
}