Skip to content

Commit

Permalink
Merge pull request #10 from sudiptpa/fix/ssl-verification-error
Browse files Browse the repository at this point in the history
Added a way to assign CA certificate path
  • Loading branch information
rotassator committed Mar 20, 2019
2 parents 59f956b + 02e8487 commit 4241c1f
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,28 @@ $response = $gateway->createSingleUseBankToken([

$singleUseTokenId = $response->getData('singleUseTokenId');
```
## Known Issue

[curl] 60: SSL certificate problem: unable to get local issuer certificate.

### Solution

[Download CA certificate](https://curl.haxx.se/docs/caextract.html) and place somewhere in your project root.

eg. project/certificate/cacert.pem

In the gateway initialization object do like below.

```php
$gateway = Omnipay::create('PaywayRest_DirectDebit');

$gateway->setApiKeyPublic('REPLACE');
$gateway->setApiKeySecret('REPLACE');
$gateway->setMerchantId('REPLACE');
$gateway->setTestMode(true);

$gateway->setSSLCertificatePath('path/cacert.pem');
```

## Contributing

Expand Down
18 changes: 18 additions & 0 deletions src/Gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,24 @@ public function setMerchantId($value)
return $this->setParameter('merchantId', $value);
}

/**
* Set SSL Certificate Path
* @param string $value SSL Certificate Path
*/
public function setSSLCertificatePath($value)
{
return $this->setParameter('sslCertificatePath', $value);
}

/**
* Get SSL Certificate Path
* @return string SSL Certificate Path
*/
public function getSSLCertificatePath()
{
return $this->getParameter('sslCertificatePath');
}

/**
* Test the PayWay gateway
* @param array $parameters Request parameters
Expand Down
13 changes: 13 additions & 0 deletions src/Message/AbstractRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,15 @@ public function setFinalPrincipalAmount($value)
return $this->setParameter('finalPrincipalAmount', $value);
}

public function setSSLCertificatePath($value)
{
return $this->setParameter('sslCertificatePath', $value);
}

public function getSSLCertificatePath()
{
return $this->getParameter('sslCertificatePath');
}

/**
* Get HTTP method
Expand Down Expand Up @@ -460,6 +469,10 @@ function ($event) {
}
);

if ($this->getSSLCertificatePath()) {
$this->httpClient->setSslVerification($this->getSSLCertificatePath());
}

$request = $this->httpClient->createRequest(
$this->getHttpMethod(),
$this->getEndpoint(),
Expand Down

0 comments on commit 4241c1f

Please sign in to comment.