Description
SDK Version: 14.1.0
PHP Version: 8.3
Integration Path: XML API (Hosted Solution)
Summary: Following the official Hosted Solution guide, the integration fails during serialization. The AuthorizationBuilder handles the transaction type as a string, but GPEcomConnector expects an int, causing a strict comparison failure.
Technical Breakdown
1. The Constructor mismatch:
In src/Builders/AuthorizationBuilder.php at line 563:
public function __construct(TransactionType|string $type, ?IPaymentMethod $paymentMethod = null)
While TransactionType::SALE is an integer (64), the builder logic results in the value being treated as a string ("64").
2. The Validation Failure:
In GPEcomConnector.php, the serializeRequest method uses a strict identity check (dummy code):
if ($builder->transactionType !== TransactionType::SALE) {
// Fails because "64" !== 64
throw new Exception("Only Charge and Authorize are supported through HPP.");
}
This results in a misleading exception being thrown, even when the setup follows the documentation exactly.
Steps to Reproduce
- Implement the standard XML API Hosted Solution as described in the official documentation.
- Initialize the
HostedService with ->charge([amount]).
- Attempt to serialize the request.
- Result: Exception thrown: "Only Charge and Authorize are supported through HPP."
Suggested Fixes
- Type Preservation: Ensure
$type in the AuthorizationBuilder constructor is not cast to a string if an integer or TransactionType enum-like constant is provided.
- Visibility: Make
withTransactionType() a public method (currently @internal) to allow developers to manually correct the type state during the build process.
Context
I discovered this while debugging an integration update for a client. Standard HPP flows using the XML API are currently blocked by this type-juggling issue in the SDK.
Thanks.
Description
SDK Version: 14.1.0
PHP Version: 8.3
Integration Path: XML API (Hosted Solution)
Summary: Following the official Hosted Solution guide, the integration fails during serialization. The
AuthorizationBuilderhandles the transaction type as astring, butGPEcomConnectorexpects anint, causing a strict comparison failure.Technical Breakdown
1. The Constructor mismatch:
In
src/Builders/AuthorizationBuilder.phpat line 563:While
TransactionType::SALEis an integer (64), the builder logic results in the value being treated as a string ("64").2. The Validation Failure:
In
GPEcomConnector.php, theserializeRequestmethod uses a strict identity check (dummy code):This results in a misleading exception being thrown, even when the setup follows the documentation exactly.
Steps to Reproduce
HostedServicewith->charge([amount]).Suggested Fixes
$typein theAuthorizationBuilderconstructor is not cast to a string if an integer orTransactionTypeenum-like constant is provided.withTransactionType()apublicmethod (currently@internal) to allow developers to manually correct the type state during the build process.Context
I discovered this while debugging an integration update for a client. Standard HPP flows using the XML API are currently blocked by this type-juggling issue in the SDK.
Thanks.