Skip to content

bug: Type mismatch in AuthorizationBuilder (v14.1.0) prevents HPP serialization #137

@ixpack

Description

@ixpack

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

  1. Implement the standard XML API Hosted Solution as described in the official documentation.
  2. Initialize the HostedService with ->charge([amount]).
  3. Attempt to serialize the request.
  4. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions