Skip to content

feat: add PHP, .NET, and Java language support to Lego system builder#3

Open
theCreedo wants to merge 12 commits into
mainfrom
feature/multi-language-scaffold
Open

feat: add PHP, .NET, and Java language support to Lego system builder#3
theCreedo wants to merge 12 commits into
mainfrom
feature/multi-language-scaffold

Conversation

@theCreedo

Copy link
Copy Markdown

No description provided.

theCreedo added 12 commits June 18, 2026 12:55
…arsing

- Remove Node-only guard; supported languages are now node and php
- Add resolveForLanguage() helper: flat arrays/maps treated as node-only
  shorthand; language-keyed objects select by spec.language
- Add .php and .sh to textExtensions so PHP scaffold files get slot-rendered
- router.php: static file serving from public/ + route dispatch to index.php
  modeled on dispute-management/php/router.php
- index.php: generated entry point with {{ SLOT }} markers mirroring index.js
- core/config.php: GpApiConfig setup from env, ServicesContainer registration
  modeled on dispute-management/php/sdk-config.php
- core/error-handler.php: sendError() normalizes SDK exceptions to JSON
- composer.json: globalpayments/php-sdk ^13.4, vlucas/phpdotenv ^5.5, phpunit ^11
- run.sh: composer install + php -S built-in server
- README.md: gold-standard per-language format with {{ SLOT }} markers
- tests/ProjectTest.php: PHPUnit smoke test, skips without credentials
- public/: shared branded assets copied from scaffold/node/public/
- token-helper.php: generateAccessToken() via direct cURL + SHA-512
  (per AGENTS.md from online-card-payments — not PHP SDK method)
- studs/fragments/token-helper-route.php: GET /api/access-token handler
- bricks/payments.php: charge(), authorize(), capture() using PHP SDK
  CreditCardData->charge()->withCurrency()->execute()
- bricks/fragments/charge-route.php: POST /api/charge handler
- bricks/fragments/authorize-route.php: POST /api/authorize handler
- bricks/fragments/capture-route.php: POST /api/capture/:id handler
- All manifests updated with language-keyed files/inserts (node + php)
- builder: skip core/ vendoring for PHP (baked into scaffold); apply
  resolveForLanguage to test_fragments; language-aware next-steps output
- specs/simple-checkout-php.yaml: first PHP spec (tiles: hosted-fields, bricks: charge)
- Verified: two builds produce byte-identical output
ASP.NET Core Minimal API shell (net9.0) with named slot markers,
ServicesContainer baseplate config, and static-file serving from public/.
Jakarta EE Servlet dispatching on method+URI (mirrors PHP routing pattern),
embedded Tomcat 10.x via Cargo Maven plugin, mvn integration-test to build
and start in one step.
Direct REST call to /ucp/accesstoken with SHA-512(nonce+appKey) secret,
scoped to PMT_POST_Create_Single permission. Returns { accessToken, environment }.
Stateless Payments class wrapping CreditCardData SDK calls. Amount parsed
from string to handle JSON string values from the frontend.
Adds files/inserts entries for dotnet and java to token-helper, charge,
authorize, capture, and hosted-fields manifests.
Adds dotnet/java to SUPPORTED_LANGUAGES, nextSteps, and textExtensions.
Java component files are vendored to src/main/java/com/globalpayments/sample/
instead of components/ to satisfy Maven package structure requirements.
simple-checkout and delayed-capture variants for both languages.
All four generate and build verified clean.
Drops "Node vertical slice" title, adds language support matrix,
updates layout section and quick start for all 4 languages,
marks Phase 1-2 complete in roadmap.
var token = body.TryGetProperty("token", out var t) ? t.GetString() ?? "" : "";
var amount = body.TryGetProperty("amount", out var a) ? decimal.Parse(a.GetString() ?? "29.99", System.Globalization.CultureInfo.InvariantCulture) : 29.99m;
var currency = body.TryGetProperty("currency", out var c) ? c.GetString() ?? "USD" : "USD";
var result = await Payments.Authorize(token, amount, currency);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In node, the import happens in this file. Would be good to follow the same pattern. Let's each file stand alone as a code example with the necessary context to have it compile and "run"

Comment thread builder/build-project.js
],
php: [
' composer install',
' ./run.sh # branded checkout on http://localhost:3000',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only one that uses the run script. We should make the call to either use it across all languages or none of them.

Comment thread builder/build-project.js
' ./vendor/bin/phpunit tests/ # smoke tests (skip without credentials)',
],
dotnet: [
' dotnet run # branded checkout on http://localhost:3000',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just the run command here. Should include dotnet install and dotnet test to match the others.

Comment thread builder/build-project.js
' dotnet run # branded checkout on http://localhost:3000',
],
java: [
' mvn integration-test # builds + starts embedded Tomcat on http://localhost:3000',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here. should include the other commands.

Comment thread studs/token-helper.php
$response = curl_exec($ch);
$httpCode = (int) curl_getinfo($ch, CURLINFO_HTTP_CODE);
$curlError = curl_error($ch);
curl_close($ch);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should use the SDK to generate the access token similar to the Node version.

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

Successfully merging this pull request may close these issues.

2 participants