diff --git a/src/Services/AdaptivePayments.php b/src/Services/AdaptivePayments.php index 346c42f4..897020d7 100644 --- a/src/Services/AdaptivePayments.php +++ b/src/Services/AdaptivePayments.php @@ -27,7 +27,7 @@ private function setHeaders() $headers = [ 'X-PAYPAL-SECURITY-USERID' => $this->config['username'], 'X-PAYPAL-SECURITY-PASSWORD' => $this->config['password'], - 'X-PAYPAL-SECURITY-SIGNATURE' => $this->config['secret'], + 'X-PAYPAL-SECURITY-SIGNATURE' => $this->config['signature'], 'X-PAYPAL-REQUEST-DATA-FORMAT' => 'JSON', 'X-PAYPAL-RESPONSE-DATA-FORMAT' => 'JSON', 'X-PAYPAL-APPLICATION-ID' => $this->config['app_id'], diff --git a/src/Traits/PayPalRequest.php b/src/Traits/PayPalRequest.php index a9da1461..7aa37674 100644 --- a/src/Traits/PayPalRequest.php +++ b/src/Traits/PayPalRequest.php @@ -88,6 +88,13 @@ public function setApiCredentials($credentials, $mode = '') $this->config[$key] = $value; } + // Setup PayPal API Signature value to use. + if (!empty($this->config['secret'])) { + $this->config['signature'] = $this->config['secret']; + } else { + $this->config['signature'] = file_get_contents($this->config['certificate']); + } + if ($this instanceof \Srmklive\PayPal\Services\AdaptivePayments) { $this->setAdaptivePaymentsOptions($mode); } else { @@ -248,7 +255,7 @@ private function doPayPalRequest($method, $params) $post = [ 'USER' => $this->config['username'], 'PWD' => $this->config['password'], - 'SIGNATURE' => $this->config['secret'], + 'SIGNATURE' => $this->config['signature'], 'VERSION' => 123, 'METHOD' => $method, ];