Skip to content

Commit

Permalink
Merge pull request #178 from TransbankDevelopers/fix/kiuwan-bugs-2
Browse files Browse the repository at this point in the history
fix: kiuwan bugs 2
  • Loading branch information
mvarlic authored Oct 31, 2023
2 parents 5515fad + fbded2b commit 3980021
Show file tree
Hide file tree
Showing 73 changed files with 552 additions and 897 deletions.
33 changes: 29 additions & 4 deletions plugin/libwebpay/ConnectionCheck.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,43 @@
<?php

use Transbank\WooCommerce\WebpayRest\Helpers\HealthCheckFactory;
use Transbank\WooCommerce\WebpayRest\WebpayplusTransbankSdk;

class ConnectionCheck
{
public static function check()
{
$healthCheck = HealthCheckFactory::create();

$resp = $healthCheck->setCreateTransaction();
$resp = ConnectionCheck::setCreateTransaction();

header('Content-Type: application/json');
ob_clean();
echo json_encode($resp);
wp_die();
}

public static function setCreateTransaction()
{
$amount = 990;
$buyOrder = '_Healthcheck_';
$sessionId = uniqid();
$returnUrl = 'http://test.com/test';

$status = 'Error';
try {
$webpayplusTransbankSdk = new WebpayplusTransbankSdk();
$result = $webpayplusTransbankSdk->createInner(0, $buyOrder, $sessionId, $amount, $returnUrl);
$status = 'OK';

} catch (\Exception $e) {
$status = 'Error';
$result = [
'error' => 'Error al crear la transacción',
'detail' => $e->getMessage()
];
}

return [
'status' => ['string' => $status],
'response' => $result
];
}
}
12 changes: 12 additions & 0 deletions plugin/shared/Exceptions/BaseException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace Transbank\Plugin\Exceptions;

use Transbank\Plugin\Helpers\ExceptionConstants;

class BaseException extends \Exception
{
public function __construct($message, \Exception $previous = null) {
parent::__construct($message, ExceptionConstants::DEFAULT_CODE, $previous);
}
}
8 changes: 2 additions & 6 deletions plugin/shared/Exceptions/EcommerceException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@

namespace Transbank\Plugin\Exceptions;

use Transbank\Plugin\Helpers\ExceptionConstants;

class EcommerceException extends \Exception
class EcommerceException extends BaseException
{
public function __construct($message, \Exception $previous = null) {
parent::__construct($message, ExceptionConstants::DEFAULT_CODE, $previous);
}

}
7 changes: 7 additions & 0 deletions plugin/shared/Exceptions/InvalidOrderException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

namespace Transbank\Plugin\Exceptions;

class InvalidOrderException extends BaseException
{
}
10 changes: 10 additions & 0 deletions plugin/shared/Exceptions/Oneclick/AuthorizeOneclickException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace Transbank\Plugin\Exceptions\Oneclick;

use Transbank\Plugin\Exceptions\BaseException;

class AuthorizeOneclickException extends BaseException
{

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace Transbank\Plugin\Exceptions\Oneclick;

use Transbank\Plugin\Exceptions\BaseException;

class ConstraintsViolatedAuthorizeOneclickException extends BaseException
{
private $authorizeResponse;

public function __construct($message, $authorizeResponse, \Exception $previous = null) {
$this->authorizeResponse = $authorizeResponse;
parent::__construct($message, $previous);
}

public function getAuthorizeResponse() {
return $this->authorizeResponse;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace Transbank\Plugin\Exceptions\Oneclick;

use Transbank\Plugin\Exceptions\BaseException;

class CreateTransactionOneclickException extends BaseException
{

}
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
<?php

namespace Transbank\WooCommerce\WebpayRest\Exceptions\Oneclick;
namespace Transbank\Plugin\Exceptions\Oneclick;

class FinishInscriptionOneclickException extends \Exception
use Transbank\Plugin\Exceptions\BaseException;

class FinishInscriptionOneclickException extends BaseException
{
private $tbkToken;
private $inscription;

public function __construct($message, $tbkToken, $inscription, $code = 0, \Exception $previous = null) {
public function __construct($message, $tbkToken, $inscription, \Exception $previous = null) {
$this->tbkToken = $tbkToken;
$this->inscription = $inscription;
parent::__construct($message, $code, $previous);
parent::__construct($message, $previous);
}

public function getTbkToken() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace Transbank\Plugin\Exceptions\Oneclick;

use Transbank\Plugin\Exceptions\BaseException;

class GetInscriptionOneclickException extends BaseException
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace Transbank\Plugin\Exceptions\Oneclick;

use Transbank\Plugin\Exceptions\BaseException;

class GetTransactionOneclickException extends BaseException
{
private $orderId;

public function __construct($message, $orderId, \Exception $previous = null) {
$this->orderId = $orderId;
parent::__construct($message, $previous);
}

public function getOrderId() {
return $this->orderId;
}

}
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
<?php

namespace Transbank\WooCommerce\WebpayRest\Exceptions\Oneclick;
namespace Transbank\Plugin\Exceptions\Oneclick;

class UserCancelInscriptionOneclickException extends \Exception
use Transbank\Plugin\Exceptions\BaseException;

class InvalidStatusInscriptionOneclickException extends BaseException
{
private $tbkToken;
private $inscription;

public function __construct($message, $tbkToken, $inscription, $code = 0, \Exception $previous = null) {
public function __construct($message, $tbkToken, $inscription, \Exception $previous = null) {
$this->tbkToken = $tbkToken;
$this->inscription = $inscription;
parent::__construct($message, $code, $previous);
parent::__construct($message, $previous);
}

public function getTbkToken() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace Transbank\Plugin\Exceptions\Oneclick;

use Transbank\Plugin\Exceptions\BaseException;

class NotFoundTransactionOneclickException extends BaseException
{
private $orderId;

public function __construct($message, $orderId, \Exception $previous = null) {
$this->orderId = $orderId;
parent::__construct($message, $previous);
}

public function getOrderId() {
return $this->orderId;
}

}
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
<?php

namespace Transbank\WooCommerce\WebpayRest\Exceptions\Oneclick;
namespace Transbank\Plugin\Exceptions\Oneclick;

class RefundOneclickException extends \Exception
use Transbank\Plugin\Exceptions\BaseException;

class RefundOneclickException extends BaseException
{
private $buyOrder;
private $childBuyOrder;
private $transaction;

public function __construct($message, $buyOrder, $childBuyOrder, $transaction, $code = 0, \Exception $previous = null) {
public function __construct($message, $buyOrder, $childBuyOrder, $transaction,
\Exception $previous = null) {
$this->buyOrder = $buyOrder;
$this->childBuyOrder = $childBuyOrder;
$this->transaction = $transaction;
parent::__construct($message, $code, $previous);
parent::__construct($message, $previous);
}

public function getBuyOrder() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace Transbank\Plugin\Exceptions\Oneclick;

use Transbank\Plugin\Exceptions\BaseException;

class RejectedAuthorizeOneclickException extends BaseException
{
private $authorizeResponse;

public function __construct($message, $authorizeResponse, \Exception $previous = null) {
$this->authorizeResponse = $authorizeResponse;
parent::__construct($message, $previous);
}

public function getAuthorizeResponse() {
return $this->authorizeResponse;
}
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
<?php

namespace Transbank\WooCommerce\WebpayRest\Exceptions\Oneclick;
namespace Transbank\Plugin\Exceptions\Oneclick;

class RejectedInscriptionOneclickException extends \Exception
use Transbank\Plugin\Exceptions\BaseException;

class RejectedInscriptionOneclickException extends BaseException
{
private $tbkToken;
private $inscription;
private $finishInscriptionResponse;

public function __construct($message, $tbkToken, $inscription, $finishInscriptionResponse, $code = 0, \Exception $previous = null) {
public function __construct($message, $tbkToken, $inscription, $finishInscriptionResponse,
\Exception $previous = null) {
$this->tbkToken = $tbkToken;
$this->inscription = $inscription;
$this->finishInscriptionResponse = $finishInscriptionResponse;
parent::__construct($message, $code, $previous);
parent::__construct($message, $previous);
}

public function getTbkToken() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
<?php

namespace Transbank\WooCommerce\WebpayRest\Exceptions\Oneclick;
namespace Transbank\Plugin\Exceptions\Oneclick;

class RejectedRefundOneclickException extends \Exception
use Transbank\Plugin\Exceptions\BaseException;

class RejectedRefundOneclickException extends BaseException
{
private $buyOrder;
private $childBuyOrder;
private $transaction;
private $refundResponse;

public function __construct($message, $buyOrder, $childBuyOrder, $transaction, $refundResponse, $code = 0, \Exception $previous = null) {
public function __construct($message, $buyOrder, $childBuyOrder, $transaction, $refundResponse,
\Exception $previous = null) {
$this->buyOrder = $buyOrder;
$this->childBuyOrder = $childBuyOrder;
$this->transaction = $transaction;
$this->refundResponse = $refundResponse;
parent::__construct($message, $code, $previous);
parent::__construct($message, $previous);
}

public function getBuyOrder() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace Transbank\Plugin\Exceptions\Oneclick;

use Transbank\Plugin\Exceptions\BaseException;

class StartInscriptionOneclickException extends BaseException
{

}
10 changes: 10 additions & 0 deletions plugin/shared/Exceptions/Oneclick/StartOneclickException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace Transbank\Plugin\Exceptions\Oneclick;

use Transbank\Plugin\Exceptions\BaseException;

class StartOneclickException extends BaseException
{

}
20 changes: 20 additions & 0 deletions plugin/shared/Exceptions/Oneclick/StatusOneclickException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace Transbank\Plugin\Exceptions\Oneclick;

use Transbank\Plugin\Exceptions\BaseException;

class StatusOneclickException extends BaseException
{
private $buyOrder;

public function __construct($message, $buyOrder, \Exception $previous = null) {
$this->buyOrder = $buyOrder;
parent::__construct($message, $previous);
}

public function getBuyOrder() {
return $this->buyOrder;
}

}
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
<?php

namespace Transbank\WooCommerce\WebpayRest\Exceptions\Oneclick;
namespace Transbank\Plugin\Exceptions\Oneclick;

class TimeoutInscriptionOneclickException extends \Exception
use Transbank\Plugin\Exceptions\BaseException;

class TimeoutInscriptionOneclickException extends BaseException
{
private $tbkToken;
private $inscription;

public function __construct($message, $tbkToken, $inscription, $code = 0, \Exception $previous = null) {
public function __construct($message, $tbkToken, $inscription, \Exception $previous = null) {
$this->tbkToken = $tbkToken;
$this->inscription = $inscription;
parent::__construct($message, $code, $previous);
parent::__construct($message, $previous);
}

public function getTbkToken() {
Expand Down
Loading

0 comments on commit 3980021

Please sign in to comment.