diff --git a/src/Common/Responses/BaseDeferredStatusResponse.php b/src/Common/Responses/BaseDeferredStatusResponse.php index 722429c0..0cb4cac0 100644 --- a/src/Common/Responses/BaseDeferredStatusResponse.php +++ b/src/Common/Responses/BaseDeferredStatusResponse.php @@ -14,16 +14,11 @@ class BaseDeferredStatusResponse public function __construct($json) { - $authorizationCode = Utils::returnValueIfExists($json, 'authorization_code'); - $this->setAuthorizationCode($authorizationCode); - $authorizationDate = Utils::returnValueIfExists($json, 'authorization_date'); - $this->setAuthorizationDate($authorizationDate); - $totalAmount = Utils::returnValueIfExists($json, 'total_amount'); - $this->setTotalAmount($totalAmount); - $expirationDate = Utils::returnValueIfExists($json, 'expiration_date'); - $this->setExpirationDate($expirationDate); - $responseCode = Utils::returnValueIfExists($json, 'response_code'); - $this->setResponseCode($responseCode); + $this->authorizationCode = Utils::returnValueIfExists($json, 'authorization_code'); + $this->authorizationDate = Utils::returnValueIfExists($json, 'authorization_date'); + $this->totalAmount = Utils::returnValueIfExists($json, 'total_amount'); + $this->expirationDate = Utils::returnValueIfExists($json, 'expiration_date'); + $this->responseCode = Utils::returnValueIfExists($json, 'response_code'); } public function setAuthorizationCode($authorizationCode) diff --git a/src/Patpass/PatpassByWebpay/Responses/TransactionCommitResponse.php b/src/Patpass/PatpassByWebpay/Responses/TransactionCommitResponse.php index 41277fa7..28ccab02 100644 --- a/src/Patpass/PatpassByWebpay/Responses/TransactionCommitResponse.php +++ b/src/Patpass/PatpassByWebpay/Responses/TransactionCommitResponse.php @@ -2,6 +2,8 @@ namespace Transbank\Patpass\PatpassByWebpay\Responses; +use Transbank\Utils\Utils; + class TransactionCommitResponse { private $vci; @@ -22,23 +24,18 @@ class TransactionCommitResponse */ public function __construct($json) { - $this->setVci($this->returnValueIfExists($json, 'vci')); - $this->setAmount($this->returnValueIfExists($json, 'amount')); - $this->setStatus($this->returnValueIfExists($json, 'status')); - $this->setBuyOrder($this->returnValueIfExists($json, 'buy_order')); - $this->setSessionId($this->returnValueIfExists($json, 'session_id')); - $this->setCardDetail($this->returnValueIfExists($json, 'card_detail')); - $this->setAccountingDate($this->returnValueIfExists($json, 'accounting_date')); - $this->setTransactionDate($this->returnValueIfExists($json, 'transaction_date')); - $this->setAuthorizationCode($this->returnValueIfExists($json, 'authorization_code')); - $this->setPaymentTypeCode($this->returnValueIfExists($json, 'payment_type_code')); - $this->setResponseCode($this->returnValueIfExists($json, 'response_code')); - $this->setInstallmentsNumber($this->returnValueIfExists($json, 'installments_number')); - } - - public function returnValueIfExists($json, $key) - { - return isset($json[$key]) ? $json[$key] : null; + $this->vci = Utils::returnValueIfExists($json, 'vci'); + $this->amount = Utils::returnValueIfExists($json, 'amount'); + $this->status = Utils::returnValueIfExists($json, 'status'); + $this->buyOrder = Utils::returnValueIfExists($json, 'buy_order'); + $this->sessionId = Utils::returnValueIfExists($json, 'session_id'); + $this->cardDetail = Utils::returnValueIfExists($json, 'card_detail'); + $this->accountingDate = Utils::returnValueIfExists($json, 'accounting_date'); + $this->transactionDate = Utils::returnValueIfExists($json, 'transaction_date'); + $this->authorizationCode = Utils::returnValueIfExists($json, 'authorization_code'); + $this->paymentTypeCode = Utils::returnValueIfExists($json, 'payment_type_code'); + $this->responseCode = Utils::returnValueIfExists($json, 'response_code'); + $this->installmentsNumber = Utils::returnValueIfExists($json, 'installments_number'); } /** diff --git a/src/Patpass/PatpassByWebpay/Responses/TransactionCreateResponse.php b/src/Patpass/PatpassByWebpay/Responses/TransactionCreateResponse.php index c3cfb598..f2ba18d6 100644 --- a/src/Patpass/PatpassByWebpay/Responses/TransactionCreateResponse.php +++ b/src/Patpass/PatpassByWebpay/Responses/TransactionCreateResponse.php @@ -2,6 +2,8 @@ namespace Transbank\Patpass\PatpassByWebpay\Responses; +use Transbank\Utils\Utils; + class TransactionCreateResponse { public $token; @@ -14,10 +16,8 @@ class TransactionCreateResponse */ public function __construct($json) { - $token = isset($json['token']) ? $json['token'] : null; - $this->setToken($token); - $url = isset($json['url']) ? $json['url'] : null; - $this->setUrl($url); + $this->token = Utils::returnValueIfExists($json, 'token'); + $this->url = Utils::returnValueIfExists($json, 'url'); } /** diff --git a/src/Patpass/PatpassComercio/Exceptions/InscriptionStartException.php b/src/Patpass/PatpassComercio/Exceptions/InscriptionStartException.php index 150683c4..dfb84032 100644 --- a/src/Patpass/PatpassComercio/Exceptions/InscriptionStartException.php +++ b/src/Patpass/PatpassComercio/Exceptions/InscriptionStartException.php @@ -8,7 +8,7 @@ namespace Transbank\Patpass\PatpassComercio\Exceptions; -use Transbank\PatPass\Exceptions\PatpassException; +use Transbank\Patpass\Exceptions\PatpassException; class InscriptionStartException extends PatpassException { diff --git a/src/Patpass/PatpassComercio/Responses/InscriptionFinishResponse.php b/src/Patpass/PatpassComercio/Responses/InscriptionFinishResponse.php index d545eb8a..133ee151 100644 --- a/src/Patpass/PatpassComercio/Responses/InscriptionFinishResponse.php +++ b/src/Patpass/PatpassComercio/Responses/InscriptionFinishResponse.php @@ -15,17 +15,13 @@ class InscriptionFinishResponse public function __construct($httpCode) { - $this->setCode($httpCode); + $this->code = $httpCode; if ($httpCode == 204) { - $this->setStatus('OK'); - - return; + $this->status = 'OK'; } if ($httpCode == 404) { - $this->setStatus('Not Found'); - - return; + $this->status = 'Not Found'; } } diff --git a/src/Patpass/PatpassComercio/Responses/InscriptionStartResponse.php b/src/Patpass/PatpassComercio/Responses/InscriptionStartResponse.php index d4aa6ca2..7fd84071 100644 --- a/src/Patpass/PatpassComercio/Responses/InscriptionStartResponse.php +++ b/src/Patpass/PatpassComercio/Responses/InscriptionStartResponse.php @@ -22,11 +22,8 @@ class InscriptionStartResponse */ public function __construct($json) { - $token = Utils::returnValueIfExists($json, 'token'); - $this->setToken($token); - - $url = Utils::returnValueIfExists($json, 'url'); - $this->setUrlWebpay($url); + $this->token = Utils::returnValueIfExists($json, 'token'); + $this->urlWebpay = Utils::returnValueIfExists($json, 'url'); } /** diff --git a/src/Patpass/PatpassComercio/Responses/InscriptionStatusResponse.php b/src/Patpass/PatpassComercio/Responses/InscriptionStatusResponse.php index 2cac6e08..08dd3830 100644 --- a/src/Patpass/PatpassComercio/Responses/InscriptionStatusResponse.php +++ b/src/Patpass/PatpassComercio/Responses/InscriptionStatusResponse.php @@ -17,10 +17,8 @@ class InscriptionStatusResponse public function __construct($json) { - $status = Utils::returnValueIfExists($json, 'authorized'); - $this->setStatus($status); - $urlVoucher = Utils::returnValueIfExists($json, 'voucherUrl'); - $this->setUrlVoucher($urlVoucher); + $this->status = Utils::returnValueIfExists($json, 'authorized'); + $this->urlVoucher = Utils::returnValueIfExists($json, 'voucherUrl'); } /** diff --git a/src/TransaccionCompleta/MallTransaction.php b/src/TransaccionCompleta/MallTransaction.php index 1f50a368..35ec4f67 100644 --- a/src/TransaccionCompleta/MallTransaction.php +++ b/src/TransaccionCompleta/MallTransaction.php @@ -8,10 +8,6 @@ namespace Transbank\TransaccionCompleta; -use Transbank\TransaccionCompleta\Responses\MallDeferredCaptureHistoryResponse; -use Transbank\TransaccionCompleta\Responses\MallIncreaseAmountResponse; -use Transbank\TransaccionCompleta\Responses\MallIncreaseAuthorizationDateResponse; -use Transbank\TransaccionCompleta\Responses\MallReversePreAuthorizedAmountResponse; use Transbank\TransaccionCompleta\Exceptions\MallTransactionCaptureException; use Transbank\TransaccionCompleta\Exceptions\MallTransactionCommitException; use Transbank\TransaccionCompleta\Exceptions\MallTransactionCreateException; @@ -24,10 +20,6 @@ use Transbank\TransaccionCompleta\Responses\MallTransactionRefundResponse; use Transbank\TransaccionCompleta\Responses\MallTransactionStatusResponse; use Transbank\Utils\InteractsWithWebpayApi; -use Transbank\Webpay\Exceptions\MallDeferredCaptureHistoryException; -use Transbank\Webpay\Exceptions\MallIncreaseAmountException; -use Transbank\Webpay\Exceptions\MallIncreaseAuthorizationDateException; -use Transbank\Webpay\Exceptions\MallReversePreAuthorizedAmountException; use Transbank\Webpay\Exceptions\WebpayRequestException; use Transbank\Webpay\Options; diff --git a/src/TransaccionCompleta/Responses/MallTransactionCreateResponse.php b/src/TransaccionCompleta/Responses/MallTransactionCreateResponse.php index 4b60cd0e..089b3615 100644 --- a/src/TransaccionCompleta/Responses/MallTransactionCreateResponse.php +++ b/src/TransaccionCompleta/Responses/MallTransactionCreateResponse.php @@ -10,8 +10,7 @@ class MallTransactionCreateResponse public function __construct($json) { - $token = Utils::returnValueIfExists($json, 'token'); - $this->setToken($token); + $this->token = Utils::returnValueIfExists($json, 'token'); } /** diff --git a/src/TransaccionCompleta/Responses/MallTransactionInstallmentsResponse.php b/src/TransaccionCompleta/Responses/MallTransactionInstallmentsResponse.php index 3931ab41..58a9f9b1 100644 --- a/src/TransaccionCompleta/Responses/MallTransactionInstallmentsResponse.php +++ b/src/TransaccionCompleta/Responses/MallTransactionInstallmentsResponse.php @@ -12,12 +12,9 @@ class MallTransactionInstallmentsResponse public function __construct($json) { - $installmentsAmount = Utils::returnValueIfExists($json, 'installments_amount'); - $this->setInstallmentsAmount($installmentsAmount); - $idQueryInstallments = Utils::returnValueIfExists($json, 'id_query_installments'); - $this->setIdQueryInstallments($idQueryInstallments); - $deferredPeriods = Utils::returnValueIfExists($json, 'deferred_periods'); - $this->setDeferredPeriods($deferredPeriods); + $this->installmentsAmount = Utils::returnValueIfExists($json, 'installments_amount'); + $this->idQueryInstallments = Utils::returnValueIfExists($json, 'id_query_installments'); + $this->deferredPeriods = Utils::returnValueIfExists($json, 'deferred_periods'); } /** diff --git a/src/TransaccionCompleta/Responses/MallTransactionRefundResponse.php b/src/TransaccionCompleta/Responses/MallTransactionRefundResponse.php index c2ba91a4..3c2bbfcc 100644 --- a/src/TransaccionCompleta/Responses/MallTransactionRefundResponse.php +++ b/src/TransaccionCompleta/Responses/MallTransactionRefundResponse.php @@ -15,18 +15,12 @@ class MallTransactionRefundResponse public function __construct($json) { - $type = Utils::returnValueIfExists($json, 'type'); - $this->setType($type); - $authorizationCode = Utils::returnValueIfExists($json, 'authorization_code'); - $this->setAuthorizationCode($authorizationCode); - $authorizationDate = Utils::returnValueIfExists($json, 'authorization_date'); - $this->setAuthorizationDate($authorizationDate); - $nullifiedAmount = Utils::returnValueIfExists($json, 'nullified_amount'); - $this->setNullifiedAmount($nullifiedAmount); - $balance = Utils::returnValueIfExists($json, 'balance'); - $this->setBalance($balance); - $responseCode = Utils::returnValueIfExists($json, 'response_code'); - $this->setResponseCode($responseCode); + $this->type = Utils::returnValueIfExists($json, 'type'); + $this->authorizationCode = Utils::returnValueIfExists($json, 'authorization_code'); + $this->authorizationDate = Utils::returnValueIfExists($json, 'authorization_date'); + $this->nullifiedAmount = Utils::returnValueIfExists($json, 'nullified_amount'); + $this->balance = Utils::returnValueIfExists($json, 'balance'); + $this->responseCode = Utils::returnValueIfExists($json, 'response_code'); } /** diff --git a/src/TransaccionCompleta/Responses/MallTransactionStatusResponse.php b/src/TransaccionCompleta/Responses/MallTransactionStatusResponse.php index c82571ba..8eca7f48 100644 --- a/src/TransaccionCompleta/Responses/MallTransactionStatusResponse.php +++ b/src/TransaccionCompleta/Responses/MallTransactionStatusResponse.php @@ -2,6 +2,8 @@ namespace Transbank\TransaccionCompleta\Responses; +use Transbank\Utils\Utils; + class MallTransactionStatusResponse { protected $buyOrder; @@ -13,14 +15,13 @@ class MallTransactionStatusResponse public function __construct($json) { - print_r($json); - $this->buyOrder = $json['buy_order'] ?? null; - $this->cardDetail = $json['card_detail'] ?? null; - $this->cardNumber = $json['card_detail']['card_number'] ?? null; - $this->accountingDate = $json['accounting_date'] ?? null; - $this->transactionDate = $json['transaction_date'] ?? null; - $details = $json['details'] ?? null; + $this->buyOrder = Utils::returnValueIfExists($json, 'buyOrder'); + $this->accountingDate = Utils::returnValueIfExists($json, 'accounting_date'); + $this->transactionDate = Utils::returnValueIfExists($json, 'transaction_date'); + $this->cardDetail = Utils::returnValueIfExists($json, 'card_detail'); + $this->cardNumber = Utils::returnValueIfExists($this->cardDetail, 'card_number'); + $details = Utils::returnValueIfExists($json, 'details'); $this->details = null; if (is_array($details)) { $this->details = []; diff --git a/src/TransaccionCompleta/Responses/TransactionCreateResponse.php b/src/TransaccionCompleta/Responses/TransactionCreateResponse.php index 78538c72..ff233f83 100644 --- a/src/TransaccionCompleta/Responses/TransactionCreateResponse.php +++ b/src/TransaccionCompleta/Responses/TransactionCreateResponse.php @@ -10,8 +10,7 @@ class TransactionCreateResponse public function __construct($json) { - $token = Utils::returnValueIfExists($json, 'token'); - $this->setToken($token); + $this->token = Utils::returnValueIfExists($json, 'token'); } /** diff --git a/src/TransaccionCompleta/Responses/TransactionInstallmentsResponse.php b/src/TransaccionCompleta/Responses/TransactionInstallmentsResponse.php index 7ade9fbd..23df79a7 100644 --- a/src/TransaccionCompleta/Responses/TransactionInstallmentsResponse.php +++ b/src/TransaccionCompleta/Responses/TransactionInstallmentsResponse.php @@ -12,12 +12,9 @@ class TransactionInstallmentsResponse public function __construct($json) { - $installmentsAmount = Utils::returnValueIfExists($json, 'installments_amount'); - $this->setInstallmentsAmount($installmentsAmount); - $idQueryInstallments = Utils::returnValueIfExists($json, 'id_query_installments'); - $this->setIdQueryInstallments($idQueryInstallments); - $deferredPeriods = Utils::returnValueIfExists($json, 'deferred_periods'); - $this->setDeferredPeriods($deferredPeriods); + $this->installmentsAmount = Utils::returnValueIfExists($json, 'installments_amount'); + $this->idQueryInstallments = Utils::returnValueIfExists($json, 'id_query_installments'); + $this->deferredPeriods = Utils::returnValueIfExists($json, 'deferred_periods'); } /** diff --git a/src/TransaccionCompleta/Responses/TransactionRefundResponse.php b/src/TransaccionCompleta/Responses/TransactionRefundResponse.php index 6d219883..6cc19578 100644 --- a/src/TransaccionCompleta/Responses/TransactionRefundResponse.php +++ b/src/TransaccionCompleta/Responses/TransactionRefundResponse.php @@ -15,18 +15,12 @@ class TransactionRefundResponse public function __construct($json) { - $type = Utils::returnValueIfExists($json, 'type'); - $this->setType($type); - $authorizationCode = Utils::returnValueIfExists($json, 'authorization_code'); - $this->setAuthorizationCode($authorizationCode); - $authorizationDate = Utils::returnValueIfExists($json, 'authorization_date'); - $this->setAuthorizationDate($authorizationDate); - $nullifiedAmount = Utils::returnValueIfExists($json, 'nullified_amount'); - $this->setNullifiedAmount($nullifiedAmount); - $balance = Utils::returnValueIfExists($json, 'balance'); - $this->setBalance($balance); - $responseCode = Utils::returnValueIfExists($json, 'response_code'); - $this->setResponseCode($responseCode); + $this->type = Utils::returnValueIfExists($json, 'type'); + $this->authorizationCode = Utils::returnValueIfExists($json, 'authorization_code'); + $this->authorizationDate = Utils::returnValueIfExists($json, 'authorization_date'); + $this->nullifiedAmount = Utils::returnValueIfExists($json, 'nullified_amount'); + $this->balance = Utils::returnValueIfExists($json, 'balance'); + $this->responseCode = Utils::returnValueIfExists($json, 'response_code'); } /** diff --git a/src/TransaccionCompleta/Responses/TransactionStatusResponse.php b/src/TransaccionCompleta/Responses/TransactionStatusResponse.php index 6842f599..b92d9e5a 100644 --- a/src/TransaccionCompleta/Responses/TransactionStatusResponse.php +++ b/src/TransaccionCompleta/Responses/TransactionStatusResponse.php @@ -3,6 +3,7 @@ namespace Transbank\TransaccionCompleta\Responses; use Transbank\Utils\HasTransactionStatus; +use Transbank\Utils\Utils; class TransactionStatusResponse { @@ -12,7 +13,7 @@ class TransactionStatusResponse public function __construct($json) { - $this->vci = isset($json['vci']) ? $json['vci'] : null; + $this->vci = Utils::returnValueIfExists($json, 'vci'); $this->setTransactionStatusFields($json); } diff --git a/src/TransaccionCompleta/Transaction.php b/src/TransaccionCompleta/Transaction.php index f5624f58..578c0fdb 100644 --- a/src/TransaccionCompleta/Transaction.php +++ b/src/TransaccionCompleta/Transaction.php @@ -2,10 +2,6 @@ namespace Transbank\TransaccionCompleta; -use Transbank\TransaccionCompleta\Responses\DeferredCaptureHistoryResponse; -use Transbank\TransaccionCompleta\Responses\IncreaseAmountResponse; -use Transbank\TransaccionCompleta\Responses\IncreaseAuthorizationDateResponse; -use Transbank\TransaccionCompleta\Responses\ReversePreAuthorizedAmountResponse; use Transbank\TransaccionCompleta\Exceptions\TransactionCaptureException; use Transbank\TransaccionCompleta\Exceptions\TransactionCommitException; use Transbank\TransaccionCompleta\Exceptions\TransactionCreateException; @@ -18,10 +14,6 @@ use Transbank\TransaccionCompleta\Responses\TransactionRefundResponse; use Transbank\Utils\InteractsWithWebpayApi; use Transbank\Webpay\Exceptions\WebpayRequestException; -use Transbank\Webpay\Exceptions\DeferredCaptureHistoryException; -use Transbank\Webpay\Exceptions\IncreaseAmountException; -use Transbank\Webpay\Exceptions\IncreaseAuthorizationDateException; -use Transbank\Webpay\Exceptions\ReversePreAuthorizedAmountException; use Transbank\Webpay\Options; /** diff --git a/src/Utils/HasTransactionStatus.php b/src/Utils/HasTransactionStatus.php index 74e0169c..5c5624e1 100644 --- a/src/Utils/HasTransactionStatus.php +++ b/src/Utils/HasTransactionStatus.php @@ -188,20 +188,20 @@ public function getAccountingDate() */ public function setTransactionStatusFields($json) { - $this->amount = isset($json['amount']) ? $json['amount'] : null; - $this->status = isset($json['status']) ? $json['status'] : null; - $this->buyOrder = isset($json['buy_order']) ? $json['buy_order'] : null; - $this->sessionId = isset($json['session_id']) ? $json['session_id'] : null; - $this->cardDetail = isset($json['card_detail']) ? $json['card_detail'] : null; - $this->cardNumber = isset($json['card_detail']['card_number']) ? $json['card_detail']['card_number'] : null; - $this->accountingDate = isset($json['accounting_date']) ? $json['accounting_date'] : null; - $this->transactionDate = isset($json['transaction_date']) ? $json['transaction_date'] : null; - $this->authorizationCode = isset($json['authorization_code']) ? $json['authorization_code'] : null; - $this->paymentTypeCode = isset($json['payment_type_code']) ? $json['payment_type_code'] : null; - $this->responseCode = isset($json['response_code']) ? $json['response_code'] : null; - $this->installmentsAmount = isset($json['installments_amount']) ? $json['installments_amount'] : null; - $this->installmentsNumber = isset($json['installments_number']) ? $json['installments_number'] : null; - $this->balance = isset($json['balance']) ? $json['balance'] : null; + $this->amount = Utils::returnValueIfExists($json, 'amount'); + $this->status = Utils::returnValueIfExists($json, 'status'); + $this->buyOrder = Utils::returnValueIfExists($json, 'buy_order'); + $this->sessionId = Utils::returnValueIfExists($json, 'session_id'); + $this->cardDetail = Utils::returnValueIfExists($json, 'card_detail'); + $this->cardNumber = Utils::returnValueIfExists($this->cardDetail, 'card_number'); + $this->accountingDate = Utils::returnValueIfExists($json, 'accounting_date'); + $this->transactionDate = Utils::returnValueIfExists($json, 'transaction_date'); + $this->authorizationCode = Utils::returnValueIfExists($json, 'authorization_code'); + $this->paymentTypeCode = Utils::returnValueIfExists($json, 'payment_type_code'); + $this->responseCode = Utils::returnValueIfExists($json, 'response_code'); + $this->installmentsAmount = Utils::returnValueIfExists($json, 'installments_amount'); + $this->installmentsNumber = Utils::returnValueIfExists($json, 'installments_number'); + $this->balance = Utils::returnValueIfExists($json, 'balance'); } diff --git a/src/Webpay/Modal/Responses/TransactionCreateResponse.php b/src/Webpay/Modal/Responses/TransactionCreateResponse.php index 96570342..d822e3a9 100644 --- a/src/Webpay/Modal/Responses/TransactionCreateResponse.php +++ b/src/Webpay/Modal/Responses/TransactionCreateResponse.php @@ -2,6 +2,8 @@ namespace Transbank\Webpay\Modal\Responses; +use Transbank\Utils\Utils; + class TransactionCreateResponse { /** @@ -11,7 +13,7 @@ class TransactionCreateResponse public function __construct(array $json) { - $this->token = $json['token']; + $this->token = Utils::returnValueIfExists($json, 'token'); } /** diff --git a/src/Webpay/Oneclick/MallTransaction.php b/src/Webpay/Oneclick/MallTransaction.php index 6385aa75..6cb0902c 100644 --- a/src/Webpay/Oneclick/MallTransaction.php +++ b/src/Webpay/Oneclick/MallTransaction.php @@ -2,15 +2,7 @@ namespace Transbank\Webpay\Oneclick; -use Transbank\Webpay\Oneclick\Responses\MallDeferredCaptureHistoryResponse; -use Transbank\Webpay\Oneclick\Responses\MallIncreaseAmountResponse; -use Transbank\Webpay\Oneclick\Responses\MallIncreaseAuthorizationDateResponse; -use Transbank\Webpay\Oneclick\Responses\MallReversePreAuthorizedAmountResponse; use Transbank\Utils\InteractsWithWebpayApi; -use Transbank\Webpay\Exceptions\MallDeferredCaptureHistoryException; -use Transbank\Webpay\Exceptions\MallIncreaseAmountException; -use Transbank\Webpay\Exceptions\MallIncreaseAuthorizationDateException; -use Transbank\Webpay\Exceptions\MallReversePreAuthorizedAmountException; use Transbank\Webpay\Exceptions\WebpayRequestException; use Transbank\Webpay\Oneclick; use Transbank\Webpay\Oneclick\Exceptions\MallRefundTransactionException; @@ -94,7 +86,7 @@ public function status($buyOrder) return new MallTransactionStatusResponse($response); } - public function refund($buyOrder, $childCommerceCode, $childBuyOrder, $amount, $options = null) + public function refund($buyOrder, $childCommerceCode, $childBuyOrder, $amount) { $payload = [ 'detail_buy_order' => $childBuyOrder, diff --git a/src/Webpay/Oneclick/Responses/InscriptionFinishResponse.php b/src/Webpay/Oneclick/Responses/InscriptionFinishResponse.php index fdd4af93..9435f7d9 100644 --- a/src/Webpay/Oneclick/Responses/InscriptionFinishResponse.php +++ b/src/Webpay/Oneclick/Responses/InscriptionFinishResponse.php @@ -3,6 +3,7 @@ namespace Transbank\Webpay\Oneclick\Responses; use Transbank\Utils\ResponseCodesEnum; +use Transbank\Utils\Utils; class InscriptionFinishResponse { @@ -14,20 +15,11 @@ class InscriptionFinishResponse public function __construct($json) { - $responseCode = isset($json['response_code']) ? $json['response_code'] : null; - $this->setResponseCode($responseCode); - - $tbkUser = isset($json['tbk_user']) ? $json['tbk_user'] : null; - $this->setTbkUser($tbkUser); - - $authorizationCode = isset($json['authorization_code']) ? $json['authorization_code'] : null; - $this->setAuthorizationCode($authorizationCode); - - $cardType = isset($json['card_type']) ? $json['card_type'] : null; - $this->setCardType($cardType); - - $cardNumber = isset($json['card_number']) ? $json['card_number'] : null; - $this->setCardNumber($cardNumber); + $this->responseCode = Utils::returnValueIfExists($json, 'response_code'); + $this->tbkUser = Utils::returnValueIfExists($json, 'tbk_user'); + $this->authorizationCode = Utils::returnValueIfExists($json, 'authorization_code'); + $this->cardType = Utils::returnValueIfExists($json, 'card_type'); + $this->cardNumber = Utils::returnValueIfExists($json, 'card_number'); } public function isApproved() diff --git a/src/Webpay/Oneclick/Responses/InscriptionStartResponse.php b/src/Webpay/Oneclick/Responses/InscriptionStartResponse.php index ed423c17..dfff11a5 100644 --- a/src/Webpay/Oneclick/Responses/InscriptionStartResponse.php +++ b/src/Webpay/Oneclick/Responses/InscriptionStartResponse.php @@ -2,6 +2,8 @@ namespace Transbank\Webpay\Oneclick\Responses; +use Transbank\Utils\Utils; + class InscriptionStartResponse { public $token; @@ -9,10 +11,8 @@ class InscriptionStartResponse public function __construct($json) { - $token = $json['token']; - $urlWebpay = $json['url_webpay']; - $this->setToken($token); - $this->setUrlWebpay($urlWebpay); + $this->token = Utils::returnValueIfExists($json, 'token'); + $this->urlWebpay = Utils::returnValueIfExists($json, 'url_webpay'); } public function getRedirectUrl() diff --git a/src/Webpay/Oneclick/Responses/MallTransactionCaptureResponse.php b/src/Webpay/Oneclick/Responses/MallTransactionCaptureResponse.php index 4df73ecd..9cf767c1 100644 --- a/src/Webpay/Oneclick/Responses/MallTransactionCaptureResponse.php +++ b/src/Webpay/Oneclick/Responses/MallTransactionCaptureResponse.php @@ -2,6 +2,8 @@ namespace Transbank\Webpay\Oneclick\Responses; +use Transbank\Utils\Utils; + class MallTransactionCaptureResponse { public $authorizationCode; @@ -11,10 +13,10 @@ class MallTransactionCaptureResponse public function __construct($json) { - $this->setAuthorizationCode(isset($json['authorization_code']) ? $json['authorization_code'] : null); - $this->setAuthorizationDate(isset($json['authorization_date']) ? $json['authorization_date'] : null); - $this->setCapturedAmount(isset($json['captured_amount']) ? $json['captured_amount'] : null); - $this->setResponseCode(isset($json['response_code']) ? $json['response_code'] : null); + $this->authorizationCode = Utils::returnValueIfExists($json, 'authorization_code'); + $this->authorizationDate = Utils::returnValueIfExists($json, 'authorization_date'); + $this->capturedAmount = Utils::returnValueIfExists($json, 'captured_amount'); + $this->responseCode = Utils::returnValueIfExists($json, 'response_code'); } public function getAuthorizationCode() diff --git a/src/Webpay/Oneclick/Responses/MallTransactionRefundResponse.php b/src/Webpay/Oneclick/Responses/MallTransactionRefundResponse.php index 33a146ea..a1005f0b 100644 --- a/src/Webpay/Oneclick/Responses/MallTransactionRefundResponse.php +++ b/src/Webpay/Oneclick/Responses/MallTransactionRefundResponse.php @@ -2,6 +2,8 @@ namespace Transbank\Webpay\Oneclick\Responses; +use Transbank\Utils\Utils; + class MallTransactionRefundResponse { public $type; @@ -13,23 +15,12 @@ class MallTransactionRefundResponse public function __construct($json) { - $type = isset($json['type']) ? $json['type'] : null; - $this->setType($type); - - $authorizationCode = isset($json['authorization_code']) ? $json['authorization_code'] : null; - $this->setAuthorizationCode($authorizationCode); - - $authorizationDate = isset($json['authorization_date']) ? $json['authorization_date'] : null; - $this->setAuthorizationDate($authorizationDate); - - $nullifiedAmount = isset($json['nullified_amount']) ? $json['nullified_amount'] : null; - $this->setNullifiedAmount($nullifiedAmount); - - $balance = isset($json['balance']) ? $json['balance'] : null; - $this->setBalance($balance); - - $responseCode = isset($json['response_code']) ? $json['response_code'] : null; - $this->setResponseCode($responseCode); + $this->type = Utils::returnValueIfExists($json, 'type'); + $this->authorizationCode = Utils::returnValueIfExists($json, 'authorization_code'); + $this->authorizationDate = Utils::returnValueIfExists($json, 'authorization_date'); + $this->nullifiedAmount = Utils::returnValueIfExists($json, 'nullified_amount'); + $this->balance = Utils::returnValueIfExists($json, 'balance'); + $this->responseCode = Utils::returnValueIfExists($json, 'response_code'); } /** diff --git a/src/Webpay/Oneclick/Responses/MallTransactionStatusResponse.php b/src/Webpay/Oneclick/Responses/MallTransactionStatusResponse.php index e486a263..0ddcd143 100644 --- a/src/Webpay/Oneclick/Responses/MallTransactionStatusResponse.php +++ b/src/Webpay/Oneclick/Responses/MallTransactionStatusResponse.php @@ -2,6 +2,8 @@ namespace Transbank\Webpay\Oneclick\Responses; +use Transbank\Utils\Utils; + class MallTransactionStatusResponse { public $buyOrder; @@ -18,34 +20,22 @@ class MallTransactionStatusResponse public function __construct($json) { - $buyOrder = isset($json['buy_order']) ? $json['buy_order'] : null; - $this->setBuyOrder($buyOrder); - - $sessionId = isset($json['session_id']) ? $json['session_id'] : null; - $this->setSessionId($sessionId); - - $cardNumber = isset($json['card_detail']) ? isset($json['card_detail']['card_number']) ? - $json['card_detail']['card_number'] : null : null; - $this->setCardNumber($cardNumber); - - $expirationDate = isset($json['expiration_date']) ? $json['expiration_date'] : null; - $this->setExpirationDate($expirationDate); - - $accountingDate = isset($json['accounting_date']) ? $json['accounting_date'] : null; - $this->setAccountingDate($accountingDate); - - $transactionDate = isset($json['transaction_date']) ? $json['transaction_date'] : null; - $this->setTransactionDate($transactionDate); - - $details = isset($json['details']) ? $json['details'] : null; - + $this->buyOrder = Utils::returnValueIfExists($json, 'buy_order'); + $this->sessionId = Utils::returnValueIfExists($json, 'session_id'); + $this->expirationDate = Utils::returnValueIfExists($json, 'expiration_date'); + $this->accountingDate = Utils::returnValueIfExists($json, 'accounting_date'); + $this->transactionDate = Utils::returnValueIfExists($json, 'transaction_date'); + $cardDetail = Utils::returnValueIfExists($json, 'card_detail'); + $this->cardNumber = Utils::returnValueIfExists($cardDetail, 'card_number'); + + $details = Utils::returnValueIfExists($json, 'details'); $detailsObjectArray = []; if (is_array($details)) { foreach ($details as $detail) { $detailsObjectArray[] = TransactionDetail::createFromArray($detail); } } - $this->setDetails($detailsObjectArray); + $this->details = $detailsObjectArray; } /** diff --git a/src/Webpay/Options.php b/src/Webpay/Options.php index 231a9f4d..2e625505 100644 --- a/src/Webpay/Options.php +++ b/src/Webpay/Options.php @@ -34,9 +34,9 @@ class Options public function __construct($apiKey, $commerceCode, $integrationType = self::ENVIRONMENT_INTEGRATION) { - $this->setApiKey($apiKey); - $this->setCommerceCode($commerceCode); - $this->setIntegrationType($integrationType); + $this->apiKey = $apiKey; + $this->commerceCode = $commerceCode; + $this->integrationType = $integrationType; } public static function forProduction($commerceCode, $apiKey) diff --git a/src/Webpay/WebpayPlus/MallTransaction.php b/src/Webpay/WebpayPlus/MallTransaction.php index 43a55989..7fe860ca 100644 --- a/src/Webpay/WebpayPlus/MallTransaction.php +++ b/src/Webpay/WebpayPlus/MallTransaction.php @@ -2,15 +2,7 @@ namespace Transbank\Webpay\WebpayPlus; -use Transbank\Webpay\WebpayPlus\Responses\MallDeferredCaptureHistoryResponse; -use Transbank\Webpay\WebpayPlus\Responses\MallIncreaseAmountResponse; -use Transbank\Webpay\WebpayPlus\Responses\MallIncreaseAuthorizationDateResponse; -use Transbank\Webpay\WebpayPlus\Responses\MallReversePreAuthorizedAmountResponse; use Transbank\Utils\InteractsWithWebpayApi; -use Transbank\Webpay\Exceptions\MallDeferredCaptureHistoryException; -use Transbank\Webpay\Exceptions\MallIncreaseAmountException; -use Transbank\Webpay\Exceptions\MallIncreaseAuthorizationDateException; -use Transbank\Webpay\Exceptions\MallReversePreAuthorizedAmountException; use Transbank\Webpay\Exceptions\WebpayRequestException; use Transbank\Webpay\Options; use Transbank\Webpay\WebpayPlus; @@ -19,11 +11,6 @@ use Transbank\Webpay\WebpayPlus\Exceptions\MallTransactionCreateException; use Transbank\Webpay\WebpayPlus\Exceptions\MallTransactionRefundException; use Transbank\Webpay\WebpayPlus\Exceptions\MallTransactionStatusException; -use Transbank\Webpay\WebpayPlus\Exceptions\TransactionCaptureException; -use Transbank\Webpay\WebpayPlus\Exceptions\TransactionCommitException; -use Transbank\Webpay\WebpayPlus\Exceptions\TransactionCreateException; -use Transbank\Webpay\WebpayPlus\Exceptions\TransactionRefundException; -use Transbank\Webpay\WebpayPlus\Exceptions\TransactionStatusException; use Transbank\Webpay\WebpayPlus\Responses\MallTransactionCaptureResponse; use Transbank\Webpay\WebpayPlus\Responses\MallTransactionCommitResponse; use Transbank\Webpay\WebpayPlus\Responses\MallTransactionCreateResponse; @@ -48,7 +35,7 @@ class MallTransaction * @param $returnUrl * @param $details * - * @throws TransactionCreateException + * @throws MallTransactionCreateException * @throws \GuzzleHttp\Exception\GuzzleException * * @return MallTransactionCreateResponse @@ -78,7 +65,7 @@ public function create($buyOrder, $sessionId, $returnUrl, $details) /** * @param $token * - * @throws TransactionCommitException + * @throws MallTransactionCommitException * @throws \GuzzleHttp\Exception\GuzzleException * * @return MallTransactionCommitResponse @@ -86,10 +73,10 @@ public function create($buyOrder, $sessionId, $returnUrl, $details) public function commit($token) { if (!is_string($token)) { - throw new InvalidArgumentException('Token parameter given is not string.'); + throw new \InvalidArgumentException('Token parameter given is not string.'); } if (!isset($token) || trim($token) === '') { - throw new InvalidArgumentException('Token parameter given is empty.'); + throw new \InvalidArgumentException('Token parameter given is empty.'); } try { @@ -111,7 +98,7 @@ public function commit($token) * @param $childCommerceCode * @param $amount * - * @throws TransactionRefundException + * @throws MallTransactionRefundException * @throws \GuzzleHttp\Exception\GuzzleException * * @return TransactionRefundResponse @@ -140,7 +127,7 @@ public function refund($token, $buyOrder, $childCommerceCode, $amount) /** * @param $token * - * @throws TransactionStatusException + * @throws MallTransactionStatusException * @throws \GuzzleHttp\Exception\GuzzleException * * @return MallTransactionStatusResponse @@ -167,7 +154,7 @@ public function status($token) * @param $authorizationCode * @param null $captureAmount * - * @throws TransactionCaptureException + * @throws MallTransactionCaptureException * @throws \GuzzleHttp\Exception\GuzzleException * * @return TransactionCaptureResponse diff --git a/src/Webpay/WebpayPlus/Responses/MallTransactionStatusResponse.php b/src/Webpay/WebpayPlus/Responses/MallTransactionStatusResponse.php index 3210a326..f337936a 100644 --- a/src/Webpay/WebpayPlus/Responses/MallTransactionStatusResponse.php +++ b/src/Webpay/WebpayPlus/Responses/MallTransactionStatusResponse.php @@ -2,6 +2,8 @@ namespace Transbank\Webpay\WebpayPlus\Responses; +use Transbank\Utils\Utils; + /** * Class MallTransactionStatusResponse. */ @@ -23,15 +25,15 @@ class MallTransactionStatusResponse public function __construct($json) { - $this->vci = isset($json['vci']) ? $json['vci'] : null; - $this->buyOrder = isset($json['buy_order']) ? $json['buy_order'] : null; - $this->sessionId = isset($json['session_id']) ? $json['session_id'] : null; - $this->cardDetail = isset($json['card_detail']) ? $json['card_detail'] : null; - $this->cardNumber = isset($json['card_detail']['card_number']) ? $json['card_detail']['card_number'] : null; - $this->expirationDate = isset($json['expiration_date']) ? $json['expiration_date'] : null; - $this->accountingDate = isset($json['accounting_date']) ? $json['accounting_date'] : null; - $this->transactionDate = isset($json['transaction_date']) ? $json['transaction_date'] : null; - $details = isset($json['details']) ? $json['details'] : null; + $this->vci = Utils::returnValueIfExists($json, 'vci'); + $this->buyOrder = Utils::returnValueIfExists($json, 'buy_order'); + $this->sessionId = Utils::returnValueIfExists($json, 'session_id'); + $this->cardDetail = Utils::returnValueIfExists($json, 'card_detail'); + $this->cardNumber = Utils::returnValueIfExists($this->cardDetail, 'card_number'); + $this->expirationDate = Utils::returnValueIfExists($json, 'expiration_date'); + $this->accountingDate = Utils::returnValueIfExists($json, 'accounting_date'); + $this->transactionDate = Utils::returnValueIfExists($json, 'transaction_date'); + $details = Utils::returnValueIfExists($json, 'details'); $this->details = null; if (is_array($details)) { diff --git a/src/Webpay/WebpayPlus/Responses/TransactionCaptureResponse.php b/src/Webpay/WebpayPlus/Responses/TransactionCaptureResponse.php index 37b51b16..a3a30d13 100644 --- a/src/Webpay/WebpayPlus/Responses/TransactionCaptureResponse.php +++ b/src/Webpay/WebpayPlus/Responses/TransactionCaptureResponse.php @@ -3,6 +3,7 @@ namespace Transbank\Webpay\WebpayPlus\Responses; use Transbank\Utils\ResponseCodesEnum; +use Transbank\Utils\Utils; class TransactionCaptureResponse { @@ -18,10 +19,10 @@ class TransactionCaptureResponse public function __construct($json) { - $this->authorizationCode = isset($json['authorization_code']) ? $json['authorization_code'] : null; - $this->authorizationDate = isset($json['authorization_date']) ? $json['authorization_date'] : null; - $this->capturedAmount = isset($json['captured_amount']) ? $json['captured_amount'] : null; - $this->responseCode = isset($json['response_code']) ? $json['response_code'] : null; + $this->authorizationCode = Utils::returnValueIfExists($json, 'authorization_code'); + $this->authorizationDate = Utils::returnValueIfExists($json, 'authorization_date'); + $this->capturedAmount = Utils::returnValueIfExists($json, 'captured_amount'); + $this->responseCode = Utils::returnValueIfExists($json, 'response_code'); } public function isApproved() diff --git a/src/Webpay/WebpayPlus/Responses/TransactionCreateResponse.php b/src/Webpay/WebpayPlus/Responses/TransactionCreateResponse.php index 605f22ea..1799fb2e 100644 --- a/src/Webpay/WebpayPlus/Responses/TransactionCreateResponse.php +++ b/src/Webpay/WebpayPlus/Responses/TransactionCreateResponse.php @@ -2,6 +2,8 @@ namespace Transbank\Webpay\WebpayPlus\Responses; +use Transbank\Utils\Utils; + class TransactionCreateResponse { /** @@ -25,7 +27,8 @@ class TransactionCreateResponse */ public function __construct($json) { - $this->fromJSON($json); + $this->token = Utils::returnValueIfExists($json, 'token'); + $this->url = Utils::returnValueIfExists($json, 'url'); } /** @@ -39,8 +42,8 @@ public function __construct($json) */ public function fromJSON($json) { - $this->setToken($json['token']); - $this->setUrl($json['url']); + $this->token = Utils::returnValueIfExists($json, 'token'); + $this->url = Utils::returnValueIfExists($json, 'url'); return $this; } diff --git a/src/Webpay/WebpayPlus/Responses/TransactionDetail.php b/src/Webpay/WebpayPlus/Responses/TransactionDetail.php index 242fc0e3..41f8cd82 100644 --- a/src/Webpay/WebpayPlus/Responses/TransactionDetail.php +++ b/src/Webpay/WebpayPlus/Responses/TransactionDetail.php @@ -4,6 +4,7 @@ use Transbank\Utils\ResponseCodesEnum; use Transbank\Utils\TransactionStatusEnum; +use Transbank\Utils\Utils; class TransactionDetail { @@ -26,6 +27,7 @@ class TransactionDetail * @param $paymentTypeCode * @param $responseCode * @param $installmentsNumber + * @param $installmentsAmount * @param $commerceCode * @param $buyOrder */ @@ -53,15 +55,15 @@ public function __construct( public static function createFromArray(array $array) { - $amount = isset($array['amount']) ? $array['amount'] : null; - $status = isset($array['status']) ? $array['status'] : null; - $authorizationCode = isset($array['authorization_code']) ? $array['authorization_code'] : null; - $paymentTypeCode = isset($array['payment_type_code']) ? $array['payment_type_code'] : null; - $responseCode = isset($array['response_code']) ? $array['response_code'] : null; - $installmentsNumber = isset($array['installments_number']) ? $array['installments_number'] : null; - $installmentsAmount = isset($array['installments_amount']) ? $array['installments_amount'] : null; - $commerceCode = isset($array['commerce_code']) ? $array['commerce_code'] : null; - $buyOrder = isset($array['buy_order']) ? $array['buy_order'] : null; + $amount = Utils::returnValueIfExists($array, 'amount'); + $status = Utils::returnValueIfExists($array, 'status'); + $authorizationCode = Utils::returnValueIfExists($array, 'authorization_code'); + $paymentTypeCode = Utils::returnValueIfExists($array, 'payment_type_code'); + $responseCode = Utils::returnValueIfExists($array, 'response_code'); + $installmentsNumber = Utils::returnValueIfExists($array, 'installments_number'); + $installmentsAmount = Utils::returnValueIfExists($array, 'installments_amount'); + $commerceCode = Utils::returnValueIfExists($array, 'commerce_code'); + $buyOrder = Utils::returnValueIfExists($array, 'buy_order'); return new static($amount, $status, $authorizationCode, $paymentTypeCode, $responseCode, $installmentsNumber, $installmentsAmount, $commerceCode, $buyOrder); diff --git a/src/Webpay/WebpayPlus/Responses/TransactionRefundResponse.php b/src/Webpay/WebpayPlus/Responses/TransactionRefundResponse.php index ca25b819..a4bde32f 100644 --- a/src/Webpay/WebpayPlus/Responses/TransactionRefundResponse.php +++ b/src/Webpay/WebpayPlus/Responses/TransactionRefundResponse.php @@ -2,6 +2,8 @@ namespace Transbank\Webpay\WebpayPlus\Responses; +use Transbank\Utils\Utils; + class TransactionRefundResponse { const TYPE_REVERSED = 'REVERSED'; @@ -38,12 +40,12 @@ class TransactionRefundResponse */ public function __construct($json) { - $this->type = isset($json['type']) ? $json['type'] : null; - $this->authorizationCode = isset($json['authorization_code']) ? $json['authorization_code'] : null; - $this->authorizationDate = isset($json['authorization_date']) ? $json['authorization_date'] : null; - $this->nullifiedAmount = isset($json['nullified_amount']) ? $json['nullified_amount'] : null; - $this->balance = isset($json['balance']) ? $json['balance'] : null; - $this->responseCode = isset($json['response_code']) ? $json['response_code'] : null; + $this->type = Utils::returnValueIfExists($json, 'type'); + $this->authorizationCode = Utils::returnValueIfExists($json, 'authorization_code'); + $this->authorizationDate = Utils::returnValueIfExists($json, 'authorization_date'); + $this->nullifiedAmount = Utils::returnValueIfExists($json, 'nullified_amount'); + $this->balance = Utils::returnValueIfExists($json, 'balance'); + $this->responseCode = Utils::returnValueIfExists($json, 'response_code'); } public function success() diff --git a/src/Webpay/WebpayPlus/Responses/TransactionStatusResponse.php b/src/Webpay/WebpayPlus/Responses/TransactionStatusResponse.php index a7ffce78..35c3b861 100644 --- a/src/Webpay/WebpayPlus/Responses/TransactionStatusResponse.php +++ b/src/Webpay/WebpayPlus/Responses/TransactionStatusResponse.php @@ -5,6 +5,7 @@ use Transbank\Utils\HasTransactionStatus; use Transbank\Utils\ResponseCodesEnum; use Transbank\Utils\TransactionStatusEnum; +use Transbank\Utils\Utils; class TransactionStatusResponse { @@ -13,7 +14,7 @@ class TransactionStatusResponse public function __construct($json) { - $this->vci = isset($json['vci']) ? $json['vci'] : null; + $this->vci = Utils::returnValueIfExists($json, 'vci'); $this->setTransactionStatusFields($json); } diff --git a/src/Webpay/WebpayPlus/Transaction.php b/src/Webpay/WebpayPlus/Transaction.php index e7eec34b..9aa1360c 100644 --- a/src/Webpay/WebpayPlus/Transaction.php +++ b/src/Webpay/WebpayPlus/Transaction.php @@ -3,15 +3,7 @@ namespace Transbank\Webpay\WebpayPlus; use GuzzleHttp\Exception\GuzzleException; -use Transbank\Webpay\WebpayPlus\Responses\DeferredCaptureHistoryResponse; -use Transbank\Webpay\WebpayPlus\Responses\IncreaseAmountResponse; -use Transbank\Webpay\WebpayPlus\Responses\IncreaseAuthorizationDateResponse; -use Transbank\Webpay\WebpayPlus\Responses\ReversePreAuthorizedAmountResponse; use Transbank\Utils\InteractsWithWebpayApi; -use Transbank\Webpay\Exceptions\DeferredCaptureHistoryException; -use Transbank\Webpay\Exceptions\IncreaseAmountException; -use Transbank\Webpay\Exceptions\IncreaseAuthorizationDateException; -use Transbank\Webpay\Exceptions\ReversePreAuthorizedAmountException; use Transbank\Webpay\Exceptions\WebpayRequestException; use Transbank\Webpay\Options; use Transbank\Webpay\WebpayPlus; @@ -79,10 +71,10 @@ public function create($buyOrder, $sessionId, $amount, $returnUrl) public function commit($token) { if (!is_string($token)) { - throw new InvalidArgumentException('Token parameter given is not string.'); + throw new \InvalidArgumentException('Token parameter given is not string.'); } if (!isset($token) || trim($token) === '') { - throw new InvalidArgumentException('Token parameter given is empty.'); + throw new \InvalidArgumentException('Token parameter given is empty.'); } try {