-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #130 from wtfzdotnet/feature/CORE-258--sdk
[CORE-258] SDK modifications for CSE.
- Loading branch information
Showing
8 changed files
with
350 additions
and
14 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
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,84 @@ | ||
<?php | ||
|
||
namespace Paynl\Api\Creditcard; | ||
|
||
use Paynl\Api\Api; | ||
|
||
/** | ||
* Encrypted transaction | ||
* | ||
* @author Michael Roterman <[email protected]> | ||
*/ | ||
abstract class AbstractCseRequest extends Api | ||
{ | ||
private $orderId; | ||
private $payload; | ||
private $threeDSTransactionId; | ||
|
||
/** | ||
* @var int the version of the api | ||
*/ | ||
protected $version = 2; | ||
|
||
/** | ||
* @var bool Is the ApiToken required for this API | ||
*/ | ||
protected $apiTokenRequired = true; | ||
|
||
public function getData() | ||
{ | ||
return array_merge(parent::getData(), array( | ||
'orderId' => $this->getOrderId(), | ||
'threeDSTransactionId' => $this->getThreeDSTransactionId(), | ||
'payload' => $this->getPayload() | ||
)); | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getOrderId() | ||
{ | ||
return $this->orderId; | ||
} | ||
|
||
/** | ||
* @param string $orderId | ||
*/ | ||
public function setOrderId($orderId) | ||
{ | ||
$this->orderId = $orderId; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getPayload() | ||
{ | ||
return $this->payload; | ||
} | ||
|
||
/** | ||
* @param string $payload | ||
*/ | ||
public function setPayload($payload) | ||
{ | ||
$this->payload = $payload; | ||
} | ||
|
||
/** | ||
* @return string|null | ||
*/ | ||
public function getThreeDSTransactionId() | ||
{ | ||
return $this->threeDSTransactionId; | ||
} | ||
|
||
/** | ||
* @param string|null $threeDSTransactionId | ||
*/ | ||
public function setThreeDSTransactionId($threeDSTransactionId) | ||
{ | ||
$this->threeDSTransactionId = $threeDSTransactionId; | ||
} | ||
} |
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,21 @@ | ||
<?php | ||
|
||
namespace Paynl\Api\Creditcard; | ||
|
||
use Paynl\Api\Api; | ||
|
||
/** | ||
* Encrypted transaction | ||
* | ||
* @author Michael Roterman <[email protected]> | ||
*/ | ||
class CseAuthenticate extends AbstractCseRequest | ||
{ | ||
/** | ||
* @inheritdoc | ||
*/ | ||
public function doRequest($endpoint = null, $version = null) | ||
{ | ||
return parent::doRequest('creditcard/cseAuthenticate'); | ||
} | ||
} |
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,21 @@ | ||
<?php | ||
|
||
namespace Paynl\Api\Creditcard; | ||
|
||
use Paynl\Api\Api; | ||
|
||
/** | ||
* Encrypted transaction | ||
* | ||
* @author Michael Roterman <[email protected]> | ||
*/ | ||
class CseAuthorize extends AbstractCseRequest | ||
{ | ||
/** | ||
* @inheritdoc | ||
*/ | ||
public function doRequest($endpoint = null, $version = null) | ||
{ | ||
return parent::doRequest('creditcard/cseAuthorize'); | ||
} | ||
} |
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,57 @@ | ||
<?php | ||
|
||
namespace Paynl\Api\Creditcard; | ||
|
||
use Paynl\Api\Api; | ||
|
||
/** | ||
* Encrypted transaction | ||
* | ||
* @author Michael Roterman <[email protected]> | ||
*/ | ||
class CseTdsStatus extends Api | ||
{ | ||
/** | ||
* @var int the version of the api | ||
*/ | ||
protected $version = 2; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $transactionId; | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function doRequest($endpoint = null, $version = null) | ||
{ | ||
return parent::doRequest('creditcard/cseTdsStatus'); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function getData() | ||
{ | ||
return array_merge(parent::getData(), array( | ||
'transactionId' => $this->transactionId | ||
)); | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getTransactionId() | ||
{ | ||
return $this->transactionId; | ||
} | ||
|
||
/** | ||
* @param string $transactionId | ||
*/ | ||
public function setTransactionId($transactionId) | ||
{ | ||
$this->transactionId = $transactionId; | ||
} | ||
} |
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,22 @@ | ||
<?php | ||
namespace Paynl\Api\Creditcard; | ||
|
||
use Paynl\Api\Api; | ||
|
||
/** | ||
* Api class to obtain public keys for encryption. | ||
*/ | ||
class PublicKeys extends Api | ||
{ | ||
protected $apiTokenRequired = false; | ||
|
||
protected $version = 2; | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function doRequest($endpoint = null, $version = null) | ||
{ | ||
return parent::doRequest('creditcard/cseGetPublicKeys'); | ||
} | ||
} |
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,132 @@ | ||
<?php | ||
|
||
namespace Paynl; | ||
|
||
use Paynl\Api\Creditcard as Api; | ||
use Paynl\Result\Transaction as Result; | ||
|
||
/** | ||
* Description of Creditcard | ||
* | ||
* @author Michael Roterman <[email protected]> | ||
*/ | ||
class Creditcard | ||
{ | ||
/** | ||
* Attempt to authorize a encrypted transaction. | ||
* | ||
* @param string $orderId | ||
* | ||
* @param string $payload | ||
* | ||
* @return array|Result\Details | ||
* @throws Error\Api | ||
* @throws Error\Error | ||
* @throws Error\Required\ApiToken | ||
*/ | ||
public static function cseAuthorize( | ||
$orderId, | ||
$threeDSTransactionId, | ||
$payload | ||
) { | ||
$api = new Api\CseAuthorize(); | ||
|
||
$api->setOrderId($orderId); | ||
$api->setThreeDSTransactionId($threeDSTransactionId); | ||
$api->setPayload($payload); | ||
|
||
try { | ||
return $api->doRequest(); | ||
} catch (\Exception $e) { | ||
return array( | ||
'type' => 'error', | ||
'message' => $e->getMessage(), | ||
'file' => $e->getFile(), | ||
'line' => $e->getLine(), | ||
'trace' => $e->getTraceAsString() | ||
); | ||
} | ||
} | ||
|
||
/** | ||
* Attempt to authenticate a encrypted transaction. | ||
* | ||
* @param string $orderId | ||
* @param string $payload | ||
* @param string|null $threeDSTransactionId | ||
* | ||
* @return array|Result\Details | ||
* @throws Error\Api | ||
* @throws Error\Error | ||
* @throws Error\Required\ApiToken | ||
*/ | ||
public static function cseAuthenticate( | ||
$orderId, | ||
$payload, | ||
$threeDSTransactionId = null | ||
) { | ||
$api = new Api\CseAuthenticate(); | ||
|
||
$api->setOrderId($orderId); | ||
$api->setPayload($payload); | ||
$api->setThreeDSTransactionId($threeDSTransactionId); | ||
|
||
try { | ||
return $api->doRequest(); | ||
} catch (\Exception $e) { | ||
return array( | ||
'type' => 'error', | ||
'message' => $e->getMessage(), | ||
'file' => $e->getFile(), | ||
'line' => $e->getLine(), | ||
'trace' => $e->getTraceAsString() | ||
); | ||
} | ||
} | ||
|
||
|
||
/** | ||
* Attempt to authenticate a encrypted transaction. | ||
* | ||
* @param string $transactionId | ||
* | ||
* @return array|Result\Details | ||
* @throws Error\Api | ||
* @throws Error\Error | ||
* @throws Error\Required\ApiToken | ||
*/ | ||
public static function cseTdsStatus( | ||
$transactionId | ||
) { | ||
$api = new Api\CseTdsStatus(); | ||
$api->setTransactionId($transactionId); | ||
|
||
try { | ||
return $api->doRequest(); | ||
} catch (\Exception $e) { | ||
return array( | ||
'type' => 'error', | ||
'message' => $e->getMessage(), | ||
'file' => $e->getFile(), | ||
'line' => $e->getLine(), | ||
'trace' => $e->getTraceAsString() | ||
); | ||
} | ||
} | ||
|
||
|
||
/** | ||
* Obtain cryptographic keys to use. | ||
* | ||
* @return array | ||
* @throws Error\Api | ||
* @throws Error\Error | ||
* @throws Error\Required\ApiToken | ||
*/ | ||
public static function publicKeys() | ||
{ | ||
$api = new Api\PublicKeys(); | ||
|
||
return $api->doRequest(); | ||
} | ||
} |
Oops, something went wrong.