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

Unauthorized Access (401) with Test Credentials in TransactionApiExample #77

Open
TomaszLach2 opened this issue Feb 13, 2025 · 0 comments

Comments

@TomaszLach2
Copy link

I am encountering an issue when attempting to create a transaction using the TransactionApiExample class provided in this repository. Previously, the test credentials worked correctly, but now I am experiencing authentication failures.

Steps to Reproduce:

  1. Use the example TransactionApiExample class.
  2. Call the createTransaction() method.
  3. Observe that the request fails with a 401 Unauthorized error.

Additional Information:

  • The test credentials (merchantId, merchantSecret, trApiKey, and trApiPass) were working previously but now result in an authentication failure.
  • Has there been any change to the test environment credentials?
  • Is there an alternative way to authenticate, such as using sandbox credentials?
  • Could you please provide clarification on this issue and suggest how we can proceed with testing transactions?

Thank you in advance!

Error:

[Tpay\OriginApi\Utilities\TException](file:///var/www/html/vendor/tpay-com/tpay-php/src/Utilities/TException.php#L7) {#1602
  #message: "0 : tpay.com server return 401: Unauthorized access in file /var/www/html/vendor/tpay-com/tpay-php/src/Curl/Curl.php line: 192"
  #code: 0
  #file: "
/var/www/html/vendor
/tpay-com/tpay-php/
src/Curl/Curl.php
"
  #line: 192
  trace: {
    
/var/www/html/vendor
/tpay-com/tpay-php/
src/Curl/Curl.php:192
 {
      
Tpay\OriginApi\Curl
\
Curl->getResponseCode($code)
 …
      ›     $codeDescription = sprintf('tpay.com server return %s', HttpCodesDictionary::HTTP_CODES[$code]);
      ›    [ throw new TException($codeDescription);](file:///var/www/html/vendor/tpay-com/tpay-php/src/Curl/Curl.php#L192)
      › }
    }
    
/var/www/html/vendor
/tpay-com/tpay-php/
src/Curl/Curl.php:178
 {
      
Tpay\OriginApi\Curl
\
Curl->checkResponse()
 …
      › 
      ›    [ return $successCall ? true : $this->getResponseCode($responseCode);](file:///var/www/html/vendor/tpay-com/tpay-php/src/Curl/Curl.php#L178)
      › }
      arguments: {
        $code: 401
      }
    }
    
/var/www/html/vendor
/tpay-com/tpay-php/
src/Curl/Curl.php:144
 {
      
Tpay\OriginApi\Curl
\
Curl->doRequest()
 …
      › $this->curlErrorNumber = curl_errno($ch);
      › [$this->checkResponse();](file:///var/www/html/vendor/tpay-com/tpay-php/src/Curl/Curl.php#L144)
      › curl_close($ch);
    }
    
/var/www/html/vendor
/tpay-com/tpay-php/
src/Utilities/ObjectsHelper.php:98
 {
      
Tpay\OriginApi\Utilities
\
ObjectsHelper->requests($url, $params)
 …
      › ->enableJSONResponse()
      › [->doRequest()](file:///var/www/html/vendor/tpay-com/tpay-php/src/Utilities/ObjectsHelper.php#L98)
      › ->getResult();
    }
    
/var/www/html/vendor
/tpay-com/tpay-php/
src/TransactionApi.php:85
 {
      
Tpay\OriginApi
\
TransactionApi->requests($url, $params)
 …
      › 
      ›    [ return parent::requests($url, $params);](file:///var/www/html/vendor/tpay-com/tpay-php/src/TransactionApi.php#L85)
      › }
      arguments: {
        $url: "https://secure.tpay.com/api/gw/75f86137a6635df826e3efe2e66f7c9a946fdde1/transaction/create"
        $params: array:13 [ …13]
      }
    }
    
/var/www/html/vendor
/tpay-com/tpay-php/
src/TransactionApi.php:63
 {
      
Tpay\OriginApi
\
TransactionApi->create($config)
 …
      › Util::log('Transaction create request params', print_r($config, true));
      › [$response = $this->requests($url, $config);](file:///var/www/html/vendor/tpay-com/tpay-php/src/TransactionApi.php#L63)
      › Util::log('Transaction create response', print_r($response, true));
      arguments: {
        $url: "https://secure.tpay.com/api/gw/75f86137a6635df826e3efe2e66f7c9a946fdde1/transaction/create"
        $params: array:13 [ …13]
      }
    }
    
/var/www/html/vendor
/store.shopware.com/tpayshopwarepayment/
src/Config/Util/TransactionApiExample.php:39
 {
      
Tpay\ShopwarePayment\Config\Util
\
TransactionApiExample->createTransaction()
 …
      › try {
      ›    [ $res = $this->create($config);](file:///var/www/html/vendor/store.shopware.com/tpayshopwarepayment/src/Config/Util/TransactionApiExample.php#L39)
      ›     $this->trUrl = $res['url'];
      arguments: {
        $config: array:12 [ …12]
      }
    }
    
/var/www/html/vendor
/store.shopware.com/tpayshopwarepayment/
src/Config/TpayConfigController.php:41
 {
      
Tpay\ShopwarePayment\Config
\
TpayConfigController->validateMerchantCredentials(Request $request): JsonResponse
 …
      › 
      › [(new TransactionApiExample())->createTransaction();](file:///var/www/html/vendor/store.shopware.com/tpayshopwarepayment/src/Config/TpayConfigController.php#L41)
      › 
    }
    
/var/www/html/vendor
/symfony/http-kernel/
HttpKernel.php:181
 {
      
Symfony\Component\HttpKernel
\
HttpKernel->handleRaw(Request $request, int $type = self::MAIN_REQUEST): Response
 …
      › // call controller
      › [$response = $controller(...$arguments);](file:///var/www/html/vendor/symfony/http-kernel/HttpKernel.php#L181)
      › 
      arguments: {
        $request: 
Symfony\Component\HttpFoundation
\
Request
 {[#15](https://github.com/tpay-com/tpay-php/issues/new#sf-dump-393046590-ref215) …}
      }
    }
    
/var/www/html/vendor
/symfony/http-kernel/
HttpKernel.php:76
 {
      
Symfony\Component\HttpKernel
\
HttpKernel->handle(Request $request, int $type = HttpKernelInterface::MAIN_REQUEST, bool $catch = true): Response
 …
      › try {
      ›    [ return $response = $this->handleRaw($request, $type);](file:///var/www/html/vendor/symfony/http-kernel/HttpKernel.php#L76)
      › } catch (\Throwable $e) {
      arguments: {
        $request: 
Symfony\Component\HttpFoundation
\
Request
 {[#15](https://github.com/tpay-com/tpay-php/issues/new#sf-dump-393046590-ref215) …}
        $type: 1
      }
    }
    
/var/www/html/vendor
/shopware/core/
Framework/Adapter/Kernel/HttpKernel.php:44
 {
      
Shopware\Core\Framework\Adapter\Kernel
\
HttpKernel->handle(Request $request, int $type = HttpKernelInterface::MAIN_REQUEST, bool $catch = true): Response
 …
      › if (!KernelFactory::$active) {
      ›    [ return parent::handle($request, $type, $catch);](file:///var/www/html/vendor/shopware/core/Framework/Adapter/Kernel/HttpKernel.php#L44)
      › }
      arguments: {
        $request: 
Symfony\Component\HttpFoundation
\
Request
 {[#15](https://github.com/tpay-com/tpay-php/issues/new#sf-dump-393046590-ref215) …}
        $type: 1
        $catch: true
      }
    }
    
/var/www/html/vendor
/shopware/core/
Framework/Adapter/Kernel/HttpCacheKernel.php:50
 {
      
Shopware\Core\Framework\Adapter\Kernel
\
HttpCacheKernel->handle(Request $request, int $type = HttpKernelInterface::MAIN_REQUEST, bool $catch = true): Response
 …
      › if (!KernelFactory::$active) {
      ›    [ return $this->getKernel()->handle($request, $type, $catch);](file:///var/www/html/vendor/shopware/core/Framework/Adapter/Kernel/HttpCacheKernel.php#L50)
      › }
      arguments: {
        $request: 
Symfony\Component\HttpFoundation
\
Request
 {[#15](https://github.com/tpay-com/tpay-php/issues/new#sf-dump-393046590-ref215) …}
        $type: 1
        $catch: true
      }
    }
    
/var/www/html/vendor
/shopware/core/
Kernel.php:158
 {
      
Shopware\Core
\
Kernel->handle(Request $request, int $type = HttpKernelInterface::MAIN_REQUEST, bool $catch = true): Response
 …
      › 
      ›    [ return $this->getHttpKernel()->handle($request, $type, $catch);](file:///var/www/html/vendor/shopware/core/Kernel.php#L158)
      › }
      arguments: {
        $request: 
Symfony\Component\HttpFoundation
\
Request
 {[#15](https://github.com/tpay-com/tpay-php/issues/new#sf-dump-393046590-ref215) …}
        $type: 1
        $catch: true
      }
    }
    
/var/www/html/vendor
/symfony/http-kernel/
HttpCache/SubRequestHandler.php:86
 {
      
Symfony\Component\HttpKernel\HttpCache
\
SubRequestHandler::handle(HttpKernelInterface $kernel, Request $request, int $type, bool $catch): Response
 …
      › try {
      ›    [ return $kernel->handle($request, $type, $catch);](file:///var/www/html/vendor/symfony/http-kernel/HttpCache/SubRequestHandler.php#L86)
      › } finally {
      arguments: {
        $request: 
Symfony\Component\HttpFoundation
\
Request
 {[#15](https://github.com/tpay-com/tpay-php/issues/new#sf-dump-393046590-ref215) …}
        $type: 1
        $catch: true
      }
    }
    
/var/www/html/vendor
/symfony/http-kernel/
HttpCache/HttpCache.php:476
 {
      
Symfony\Component\HttpKernel\HttpCache
\
HttpCache->forward(Request $request, bool $catch = false, ?Response $entry = null)
 …
      › // always a "master" request (as the real master request can be in cache)
      › [$response = SubRequestHandler::handle($this->kernel, $request, HttpKernelInterface::MAIN_REQUEST, $catch);](file:///var/www/html/vendor/symfony/http-kernel/HttpCache/HttpCache.php#L476)
      › 
      arguments: {
        $kernel: 
Shopware\Core
\
Kernel
 {#23 …}
        $request: 
Symfony\Component\HttpFoundation
\
Request
 {[#15](https://github.com/tpay-com/tpay-php/issues/new#sf-dump-393046590-ref215) …}
        $type: 1
        $catch: true
      }
    }
    
/var/www/html/vendor
/symfony/http-kernel/
HttpCache/HttpCache.php:276
 {
      
Symfony\Component\HttpKernel\HttpCache
\
HttpCache->pass(Request $request, bool $catch = false): Response
 …
      › 
      ›    [ return $this->forward($request, $catch);](file:///var/www/html/vendor/symfony/http-kernel/HttpCache/HttpCache.php#L276)
      › }
      arguments: {
        $request: 
Symfony\Component\HttpFoundation
\
Request
 {[#15](https://github.com/tpay-com/tpay-php/issues/new#sf-dump-393046590-ref215) …}
        $catch: true
      }
    }
    
/var/www/html/vendor
/symfony/http-kernel/
HttpCache/HttpCache.php:290
 {
      
Symfony\Component\HttpKernel\HttpCache
\
HttpCache->invalidate(Request $request, bool $catch = false): Response
 …
      › {
      ›    [ $response = $this->pass($request, $catch);](file:///var/www/html/vendor/symfony/http-kernel/HttpCache/HttpCache.php#L290)
      › 
      arguments: {
        $request: 
Symfony\Component\HttpFoundation
\
Request
 {[#15](https://github.com/tpay-com/tpay-php/issues/new#sf-dump-393046590-ref215) …}
        $catch: true
      }
    }
    
/var/www/html/vendor
/symfony/http-kernel/
HttpCache/HttpCache.php:211
 {
      
Symfony\Component\HttpKernel\HttpCache
\
HttpCache->handle(Request $request, int $type = HttpKernelInterface::MAIN_REQUEST, bool $catch = true): Response
 …
      › if (!$request->isMethodSafe()) {
      ›    [ $response = $this->invalidate($request, $catch);](file:///var/www/html/vendor/symfony/http-kernel/HttpCache/HttpCache.php#L211)
      › } elseif ($request->headers->has('expect') || !$request->isMethodCacheable()) {
      arguments: {
        $request: 
Symfony\Component\HttpFoundation
\
Request
 {[#15](https://github.com/tpay-com/tpay-php/issues/new#sf-dump-393046590-ref215) …}
        $catch: true
      }
    }
    
/var/www/html/vendor
/shopware/core/
HttpKernel.php:146
 {
      
Shopware\Core
\
HttpKernel->doHandle(Request $request, int $type, bool $catch): HttpKernelResult
 …
      › 
      › [$response = $kernel->handle($transformed, $type, $catch);](file:///var/www/html/vendor/shopware/core/HttpKernel.php#L146)
      › 
      arguments: {
        $request: 
Symfony\Component\HttpFoundation
\
Request
 {[#15](https://github.com/tpay-com/tpay-php/issues/new#sf-dump-393046590-ref215) …}
        $type: 1
        $catch: true
      }
    }
    
/var/www/html/vendor
/shopware/core/
HttpKernel.php:67
 {
      
Shopware\Core
\
HttpKernel->handle(Request $request, int $type = HttpKernelInterface::MAIN_REQUEST, bool $catch = true): HttpKernelResult
 …
      › try {
      ›    [ return $this->doHandle($request, $type, $catch);](file:///var/www/html/vendor/shopware/core/HttpKernel.php#L67)
      › } catch (Exception $e) {
      arguments: {
        $request: 
Symfony\Component\HttpFoundation
\
Request
 {[#15](https://github.com/tpay-com/tpay-php/issues/new#sf-dump-393046590-ref215) …}
        $type: 1
        $catch: true
      }
    }
    
/var/www/html
/
public/index.php:73
 {
      
Symfony\Component\HttpKernel
\
HttpKernelInterface@anonymous\x00/var/www/html/public/index.php:63$13c83->handle(Request $request, int $type = self::MAIN_REQUEST, bool $catch = true): Response
 …
      › {
      ›    [ return $this->httpKernel->handle($request, $type, $catch)->getResponse();](file:///var/www/html/public/index.php#L73)
      › }
      arguments: {
        $request: 
Symfony\Component\HttpFoundation
\
Request
 {[#15](https://github.com/tpay-com/tpay-php/issues/new#sf-dump-393046590-ref215) …}
        $type: 1
        $catch: true
      }
    }
    
/var/www/html/vendor
/symfony/runtime/
Runner/Symfony/HttpKernelRunner.php:35
 {
      
Symfony\Component\Runtime\Runner\Symfony
\
HttpKernelRunner->run(): int
 …
      › {
      ›    [ $response = $this->kernel->handle($this->request);](file:///var/www/html/vendor/symfony/runtime/Runner/Symfony/HttpKernelRunner.php#L35)
      › 
      arguments: {
        $request: 
Symfony\Component\HttpFoundation
\
Request
 {[#15](https://github.com/tpay-com/tpay-php/issues/new#sf-dump-393046590-ref215) …}
      }
    }
    
/var/www/html/vendor
/autoload_runtime.php:2
9
 {
      [require_once](file:///var/www/html/vendor/autoload_runtime.php#L29) …
      ›         ->getRunner($app)
      ›        [ ->run()](file:///var/www/html/vendor/autoload_runtime.php#L29)
      › );
    }
    
/var/www/html
/
public/index.php:14
 {
      › 
      › [require_once __DIR__ . '/../vendor/autoload_runtime.php';](file:///var/www/html/public/index.php#L14)
      › 
      arguments: {
        "/var/www/html/vendor/autoload_runtime.php"
      }
    }
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant