Skip to content

Commit

Permalink
Use API Certificate for making API calls
Browse files Browse the repository at this point in the history
  • Loading branch information
srmklive committed Dec 10, 2016
1 parent d4b0da9 commit c645938
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Services/AdaptivePayments.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down
9 changes: 8 additions & 1 deletion src/Traits/PayPalRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
];
Expand Down

0 comments on commit c645938

Please sign in to comment.