Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: kiuwan bugs 02 #271

Merged
merged 5 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/Contracts/RequestService.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Transbank\Contracts;

use Transbank\Webpay\Exceptions\WebpayRequestException;
use Transbank\Webpay\Options;

interface RequestService
Expand All @@ -13,7 +12,7 @@ interface RequestService
* @param $payload
* @param Options $options
*
* @throws WebpayRequestException
* @throws Transbank\Webpay\Exceptions\WebpayRequestException
*
* @return array Response from the API as json.
*/
Expand Down
5 changes: 2 additions & 3 deletions src/Patpass/PatpassByWebpay/Transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Transbank\Patpass\PatpassByWebpay;

use Transbank\Patpass\Options;
use Transbank\Patpass\PatpassByWebpay;
use Transbank\Patpass\PatpassByWebpay\Exceptions\TransactionCommitException;
use Transbank\Patpass\PatpassByWebpay\Exceptions\TransactionCreateException;
Expand Down Expand Up @@ -49,7 +48,7 @@ public function commit($token)
$endpoint = static::COMMIT_TRANSACTION_ENDPOINT;

try {
$response = $this->sendRequest('PUT', $endpoint, $payload);
$response = $this->sendRequest('PUT', $endpoint.'/'.$token, $payload);
} catch (WebpayRequestException $exception) {
throw TransactionCommitException::raise($exception);
}
Expand All @@ -74,7 +73,7 @@ public function status($token)
/**
* Get the default options if none are given.
*
* @return Options|null
* @return Transbank\Patpass\Options|null
*/
public static function getGlobalOptions()
{
Expand Down
5 changes: 2 additions & 3 deletions src/Patpass/PatpassComercio/Inscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

namespace Transbank\Patpass\PatpassComercio;

use GuzzleHttp\Exception\GuzzleException;
use Transbank\Patpass\PatpassComercio;
use Transbank\Patpass\PatpassComercio\Exceptions\InscriptionStartException;
use Transbank\Patpass\PatpassComercio\Exceptions\InscriptionStatusException;
Expand Down Expand Up @@ -42,7 +41,7 @@ class Inscription
* @param $city
*
* @throws InscriptionStartException
* @throws GuzzleException
* @throws GuzzleHttp\Exception\GuzzleException
*
* @return InscriptionStartResponse
*/
Expand Down Expand Up @@ -97,7 +96,7 @@ public function start(
* @param null $options
*
* @throws InscriptionStatusException
* @throws GuzzleException
* @throws GuzzleHttp\Exception\GuzzleException
*
* @return InscriptionStatusResponse
*/
Expand Down
10 changes: 4 additions & 6 deletions src/Utils/HttpClientRequestService.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace Transbank\Utils;

use GuzzleHttp\Exception\GuzzleException;
use Psr\Http\Message\ResponseInterface;
use Transbank\Contracts\HttpClientInterface;
use Transbank\Contracts\RequestService;
use Transbank\Webpay\Exceptions\TransbankApiRequest;
Expand All @@ -13,7 +11,7 @@
class HttpClientRequestService implements RequestService
{
/**
* @var ResponseInterface|null
* @var Psr\Http\Message\ResponseInterface|null
*/
protected $lastResponse = null;

Expand Down Expand Up @@ -53,7 +51,7 @@ public function setHttpClient($httpClient)
* @param $payload
* @param Options $options
*
* @throws GuzzleException
* @throws GuzzleHttp\Exception\GuzzleException
* @throws WebpayRequestException
*
* @return array
Expand Down Expand Up @@ -96,15 +94,15 @@ public function request(
}

/**
* @return ResponseInterface|null
* @return Psr\Http\Message\ResponseInterface|null
*/
public function getLastResponse()
{
return $this->lastResponse;
}

/**
* @param ResponseInterface|null $lastResponse
* @param Psr\Http\Message\ResponseInterface|null $lastResponse
*/
protected function setLastResponse($lastResponse)
{
Expand Down
3 changes: 1 addition & 2 deletions src/Utils/InteractsWithWebpayApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Transbank\Utils;

use Transbank\Contracts\RequestService;
use Transbank\Webpay\Exceptions\WebpayRequestException;
use Transbank\Webpay\Options;

/**
Expand Down Expand Up @@ -41,7 +40,7 @@ public function __construct(
* @param $endpoint
* @param array|null $payload
*
* @throws WebpayRequestException
* @throws Transbank\Webpay\Exceptions\WebpayRequestException
*
* @return mixed
*/
Expand Down
9 changes: 4 additions & 5 deletions src/Webpay/Modal/Transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Transbank\Webpay\Modal;

use GuzzleHttp\Exception\GuzzleException;
use Transbank\Utils\InteractsWithWebpayApi;
use Transbank\Webpay\Exceptions\WebpayRequestException;
use Transbank\Webpay\Modal\Exceptions\TransactionCommitException;
Expand Down Expand Up @@ -30,7 +29,7 @@ class Transaction
* @param int $amount
*
* @throws TransactionCreateException
* @throws GuzzleException|TransactionCreateException
* @throws GuzzleHttp\Exception\GuzzleException|TransactionCreateException
*
* @return TransactionCreateResponse
**
Expand Down Expand Up @@ -59,7 +58,7 @@ public function create($amount, $buyOrder, $sessionId = null)
/**
* @param string $token
*
* @throws TransactionCommitException|GuzzleException
* @throws TransactionCommitException|GuzzleHttp\Exception\GuzzleException
*
* @return TransactionCommitResponse
**
Expand All @@ -80,7 +79,7 @@ public function commit($token)
/**
* @param $token
*
* @throws GuzzleException
* @throws GuzzleHttp\Exception\GuzzleException
* @throws TransactionStatusException
*
* @return TransactionStatusResponse
Expand All @@ -103,7 +102,7 @@ public function status($token)
* @param $amount
* @param Options|null $options
*
* @throws GuzzleException|TransactionRefundException
* @throws GuzzleHttp\Exception\GuzzleException|TransactionRefundException
*
* @return TransactionRefundResponse
*/
Expand Down
6 changes: 2 additions & 4 deletions src/Webpay/WebpayPlus/MallTransaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
use Transbank\Webpay\WebpayPlus\Responses\MallTransactionCreateResponse;
use Transbank\Webpay\WebpayPlus\Responses\MallTransactionRefundResponse;
use Transbank\Webpay\WebpayPlus\Responses\MallTransactionStatusResponse;
use Transbank\Webpay\WebpayPlus\Responses\TransactionCaptureResponse;
use Transbank\Webpay\WebpayPlus\Responses\TransactionRefundResponse;

class MallTransaction
{
Expand Down Expand Up @@ -101,7 +99,7 @@ public function commit($token)
* @throws MallTransactionRefundException
* @throws \GuzzleHttp\Exception\GuzzleException
*
* @return TransactionRefundResponse
* @return MallTransactionRefundResponse
*/
public function refund($token, $buyOrder, $childCommerceCode, $amount)
{
Expand Down Expand Up @@ -157,7 +155,7 @@ public function status($token)
* @throws MallTransactionCaptureException
* @throws \GuzzleHttp\Exception\GuzzleException
*
* @return TransactionCaptureResponse
* @return MallTransactionCaptureResponse
*/
public function capture(
$childCommerceCode,
Expand Down
11 changes: 5 additions & 6 deletions src/Webpay/WebpayPlus/Transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Transbank\Webpay\WebpayPlus;

use GuzzleHttp\Exception\GuzzleException;
use Transbank\Utils\InteractsWithWebpayApi;
use Transbank\Webpay\Exceptions\WebpayRequestException;
use Transbank\Webpay\Options;
Expand Down Expand Up @@ -38,7 +37,7 @@ class Transaction
* @param string $returnUrl
*
* @throws TransactionCreateException
* @throws GuzzleException
* @throws GuzzleHttp\Exception\GuzzleException
*
* @return TransactionCreateResponse
*/
Expand All @@ -64,7 +63,7 @@ public function create($buyOrder, $sessionId, $amount, $returnUrl)
* @param $token
*
* @throws TransactionCommitException
* @throws GuzzleException
* @throws GuzzleHttp\Exception\GuzzleException
*
* @return TransactionCommitResponse
*/
Expand Down Expand Up @@ -95,7 +94,7 @@ public function commit($token)
* @param $amount
*
* @throws TransactionRefundException
* @throws GuzzleException
* @throws GuzzleHttp\Exception\GuzzleException
*
* @return TransactionRefundResponse
*/
Expand All @@ -118,7 +117,7 @@ public function refund($token, $amount)
* @param $token
*
* @throws TransactionStatusException
* @throws GuzzleException
* @throws GuzzleHttp\Exception\GuzzleException
*
* @return TransactionStatusResponse
*/
Expand All @@ -144,7 +143,7 @@ public function status($token)
* @param $captureAmount
*
* @throws TransactionCaptureException
* @throws GuzzleException
* @throws GuzzleHttp\Exception\GuzzleException
*
* @return TransactionCaptureResponse
*/
Expand Down
9 changes: 4 additions & 5 deletions tests/Webpay/OneClick/TransbankOneclickTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use DMS\PHPUnitExtensions\ArraySubset\ArraySubsetAsserts;
use PHPUnit\Framework\TestCase;
use Transbank\Patpass\PatpassComercio\Inscription;
use Transbank\Webpay\Oneclick;
use Transbank\Webpay\Oneclick\Exceptions\InscriptionStartException;
use Transbank\Webpay\Oneclick\Exceptions\MallTransactionAuthorizeException;
Expand Down Expand Up @@ -40,14 +39,14 @@ public function it_creates_an_inscription()
public function it_fails_creating_an_inscription_with_invalid_email()
{
$this->expectException(InscriptionStartException::class, 'Invalid value for parameter: email');
$response = MallInscription::build()->start($this->username, 'not_an_email', $this->responseUrl);
MallInscription::build()->start($this->username, 'not_an_email', $this->responseUrl);
}

/** @test */
public function it_fails_creating_an_inscription_with_invalid_data()
{
$this->expectException(InscriptionStartException::class, 'username is required');
$response = MallInscription::build()->start('', $this->email, $this->responseUrl);
MallInscription::build()->start('', $this->email, $this->responseUrl);
}

/** @test */
Expand All @@ -68,7 +67,7 @@ public function it_fails_authorizing_a_transaction_with_a_fake_token()
$mallTransaction = new MallTransaction();

try {
$response = $mallTransaction->authorize($this->username, 'fakeToken', 'buyOrder2132312', [
$mallTransaction->authorize($this->username, 'fakeToken', 'buyOrder2132312', [
[
'commerce_code' => MallInscription::DEFAULT_CHILD_COMMERCE_CODE_1,
'buy_order' => 'buyOrder122412',
Expand Down Expand Up @@ -103,7 +102,7 @@ public function it_fails_authorizing_a_transaction_with_a_fake_token()
public function it_fails_authorizing_a_transaction_with_no_username()
{
$this->expectException(MallTransactionAuthorizeException::class, 'username is required');
$response = MallTransaction::build()->authorize('', 'fakeToken', 'buyOrder2132312', [
MallTransaction::build()->authorize('', 'fakeToken', 'buyOrder2132312', [
[
'commerce_code' => Oneclick::DEFAULT_CHILD_COMMERCE_CODE_1,
'buy_order' => 'buyOrder122412',
Expand Down
Loading