Skip to content

Take the Zip SDK from Composer instead of a copy in the tree - #114

Closed
alphadp wants to merge 8 commits into
masterfrom
improve/ZES-91/sdk-1-0-24
Closed

alphadp wants to merge 8 commits into
masterfrom
improve/ZES-91/sdk-1-0-24

Conversation

@alphadp

@alphadp alphadp commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor

The Zip merchant SDK now comes from Composer — zipmoney/merchantapi-php — instead of a copy committed under MerchantApi/.

vendor/ is no longer tracked, so a checkout needs composer install.

This was the only one of the four plugin repositories without it: the
button to stand a branch up shipped here first, before the shape of the
documentation had settled, and never got the text.

Same two files as zip.woocommerce, zip.prestashop and zip.opencart3.x.
README.md keeps the introduction and links onward; QA-STORE.md carries
the procedure, with BOTH the direct URL and the sidebar path at every
step, because people navigate one way or the other and a bare link is
useless once a page moves.

Two things are specific to this store and are written down rather than
left to be rediscovered: the build is slower, because the image runs
di:compile and static-content:deploy so a pod can start fast; and the
store provisions a test product — category Zip QA, SKU ZIP-QA-001 — for
driving a real checkout, which reaches a live Zip sandbox session.
docs(ZES-86): document the QA store, matching the other three plugins

See merge request zip-au/plugins/zip-magento-2!4
The two hosts drifted apart on 2026-08-12: GitHub took "Update composer.lock
for version 1.2.13" while GitLab took the QA store documentation, so neither
master was a superset of the other and the QA store — which clones from GitLab
— was building from a tree that did not match the released one.

No conflicting edits: the GitLab side only adds QA-STORE.md and a section in
README.md. This merge makes both hosts carry the same master.
PHP 8 stopped coercing arguments to strlen() and strtolower(): a non-string
now throws a TypeError. The bundled Merchant API library validates field
lengths with bare calls, so an integer reaching a Model setter — an order or
cart id, typically — fatals the checkout.

Add a (string) cast at all 60 call sites in MerchantApi/. Beyond the setters
this covers listInvalidProperties() and valid(), where several Address checks
(line1, city, state, postal_code, country) carry no is_null guard and would
reach strlen(null), deprecated since 8.1; and strlen($apiKey) in
MerchantApi/Lib/Api/*, where the key is null until one is configured. The cast
is a no-op on values that are already strings, so nothing changes for callers
that work today.

This library is a hard copy, so the fix does not arrive through Composer the
way it does for the WooCommerce and PrestaShop plugins; it matches
zipmoney/merchantapi-php 1.0.21, which carries the same change upstream.

Bump to 1.2.14. etc/module.xml had drifted to 1.2.12 while composer.json said
1.2.13, so both now move together — the value is vestigial here, since the
module uses declarative schema and ships no Setup scripts or data patches, but
two version numbers that disagree are worse than one that is unused.

Also refresh composer.lock: its content-hash covers composer.json's version
field, so bumping without it leaves every build warning that the lock is stale.
Add the 1.2.13 changelog entry, which was released without one.
The bundled Merchant API library is a hard copy, so fixes made upstream never
arrive on their own. 1.0.22 has just taken this module's retry policy (ZES-49);
these two go the other way.

A refused call now reports what Zip actually said. The library answers a decline
with error.message, or a list in error.details, and all of it was being thrown
away in favour of "[500] Error connecting to the API (url)" — a message that
tells a merchant nothing and leaves the logs just as blank. Helper\Data::
handleException() switches on the HTTP code and reads the error object, never
the message text, so nothing downstream depends on the old wording; it only
logs it, and that log is now worth reading.

    before   [500] Error connecting to the API (http://.../checkouts)
    after    boom            <- error.message from the response body

A transport-level cURL failure also no longer hands substr() a boolean:
curl_exec() returns false when TLS, DNS or the connection itself fails, and
there is no payload to slice. The http_code === 0 branch below already turns
that into a proper ApiException — it just has to be reached first.

Measured against a local server answering 500 with a JSON error body, an
Idempotency-Key present: 4 requests over 6.0s, ending in an ApiException whose
message is the one Zip sent and whose code is 500.

Configuration::getPackageVersion() is deliberately not ported. It reads a
composer.json next to the library, and this copy has none, so it would only ever
return null.
The module carried its own re-namespaced copy of the Merchant API library under
MerchantApi/Lib. It had drifted from zipmoney/merchantapi-php in both directions
over the years, and this ticket made the cost plain: the same PHP 8 strlen fix
had to be written twice, by hand, in two repositories.

Everything the copy had and the library did not is now upstream in 1.0.23 —
is_partial_capture on a capture, a required currency on a refund, a tolerated
null gender, a blank state left out of the payload, and the sanitizeFilename()
call that was reaching for a global function. So nothing is given up by dropping
the copy.

- require zipmoney/merchantapi-php ^1.0.23. Not lower: 1.0.22 has no
  setCaptureIsPartial() or setCurrency(), and every capture and every refund
  calls one of them.
- 101 references across 26 files move from Zip\ZipPayment\MerchantApi\Lib\ to
  zipMoney\, including etc/di.xml, and MerchantApi/ is deleted.
- Model/CommonUtil stays ours — it is a holder for the sandbox and production
  constants, not part of the library — and moves to Zip\ZipPayment\Model.
- vendor/ is gitignored now that Composer fills it.

Verified against the installed 1.0.23, not by reading: setCaptureIsPartial() and
setCurrency() resolve, setGender(null) is accepted, an address with no state
serialises without the field rather than with "state": "", and
sanitizeFilename() is reachable from the static deserialize(). php -l passes on
all 68 files on PHP 8.1 and composer validate reports no lock error.

Installation changes with this, so the README does too. Composer is the way in:
`composer require zip/magento2` resolves the library into the store's own
vendor/, and a merchant never sees a version number. Nothing in Magento reads a
module's composer.json when the module is dropped into app/code, so the file
route now points at a release archive instead — and .github/workflows/release.yml
builds one on a tag, with the library inside and a check that refuses to publish
an archive without it. The archive is assembled from an allow list: anything new
in the repository stays out until someone adds it deliberately.
ZES-91: take the Zip SDK from Composer and fix the PHP 8 typing bug

See merge request zip-au/plugins/zip-magento-2!5
1.0.24 is 1.0.23 with export-ignore rules in the SDK's .gitattributes, so its
dist no longer carries Makefile, rector.php, build/, build.xml, composer.lock,
phpunit.xml.dist, docs/ and test/ — 52 files instead of 125, verified by
installing it from Packagist. No behaviour change, and nothing else was folded
into that release on purpose.

This module resolves the SDK at build time rather than committing vendor/, so the
gain here is a smaller download and a slightly faster image build, not a lighter
package for a merchant. The plugins that vendor the tree — OpenCart, PrestaShop,
and the WooCommerce build published to WordPress.org — are where the shipped
weight actually drops.

The constraint moves to ^1.0.24 rather than being left at ^1.0.23 for the caret
to pick up: the floor should state the version that was tested, not the oldest one
that happens to work. composer.lock is refreshed in the same commit, so
`composer validate` stays quiet.

Module version left at 1.2.14 — bumping it is a release decision, and the QA
stand is indifferent to it.
@alphadp alphadp changed the title Sync master with GitLab: Zip SDK via Composer, SDK 1.0.24, QA store docs Take the Zip SDK from Composer instead of a copy in the tree Aug 20, 2026
@alphadp alphadp closed this Aug 20, 2026
@alphadp
alphadp deleted the improve/ZES-91/sdk-1-0-24 branch August 20, 2026 11:22
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