Let sites map custom payment gateways to their own Splash code - #14
Open
Pichinov-Jose wants to merge 1 commit into
Open
Pichinov-Jose wants to merge 1 commit into
Pichinov-Jose wants to merge 1 commit into
Conversation
encodePaymentMethod() matches six known gateway ids and sends everything else as "DirectDebit". A bank transfer, a holiday voucher and a card therefore reach the target as the same thing, and getGatewaysList() collapses every custom gateway under a single key. Targets are more capable than that. Dolibarr's PaymentMethods::getDoliCode(), for one, falls back to searching its own payment methods by code and by label when a code is not in its dictionary — so a site that sends "ANCV" gets its holiday-voucher method resolved. The information is lost before it leaves WooCommerce, not on arrival. Add two symmetrical filters: - splash_encode_payment_method($code, $gatewayId) - splash_decode_payment_method($gatewayId, $code) Symmetry matters: setPaymentsFields() compares the encoded method with the incoming one and writes back decodePaymentMethod(). Without the second filter, a custom code mapped on the way out would come back as "other" and overwrite the order's real gateway. The detection logic moves unchanged into detectPaymentMethod() and detectGateway(). Default behaviour is identical when no filter is registered. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Pichinov-Jose
marked this pull request as ready for review
September 5, 2026 00:21
Pichinov-Jose
marked this pull request as draft
September 5, 2026 00:50
Pichinov-Jose
marked this pull request as ready for review
September 5, 2026 00:52
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The problem
encodePaymentMethod()matches six known gateway ids and sends everything else asDirectDebit:A bank transfer, a holiday voucher and a card therefore reach the target as the same thing. There is
no extension point, so a site using a custom gateway has nowhere to say what its gateway actually is.
It also makes
getGatewaysList()misleading: it indexes available gateways by their encodedcode, so every custom gateway on a site collapses under the single
DirectDebitkey.Targets are more capable than this
Dolibarr's
PaymentMethods::getDoliCode()does not stop at its own dictionary — when the code isunknown it searches the site's payment methods by code, then by label:
So a site sending
ANCVwould get its holiday-voucher method resolved on arrival. The information islost before it leaves WooCommerce, not on the target.
What this costs in practice
On a production install syncing to Dolibarr, 45 orders were paid with French ANCV holiday vouchers
through a custom gateway. All 45 arrived as
DirectDebit, became card payments on the gateway bankaccount, and had to be re-entered by hand on the correct account — 8 319,56 € of manual work.
Thirteen of them were then destroyed on a later sync, because a payment the source cannot express is
also a payment the source does not declare — see #13 for how that happens, and
SplashSync/Dolibarr#25 for the target-side guard.
The change
Two symmetrical filters:
Symmetry is not cosmetic here.
setPaymentsFields()compares the encoded method with theincoming one, then writes back
decodePaymentMethod():With only the encode filter, a custom code mapped on the way out would come back as
otheron theway in and overwrite the order's real gateway — the fix would cause the damage it prevents.
The detection logic moves unchanged into
detectPaymentMethod()anddetectGateway(). Defaultbehaviour is byte-for-byte identical when no filter is registered. The
@SuppressWarningson theswitch follows it to its new home.
A site then needs a few lines:
This mirrors
splash_prepend_order_statuses, which the connector already exposes for order statuses,so the pattern should be familiar.
Alternative considered
Passing the raw gateway id through instead of falling back to
DirectDebitwould fix this withoutany configuration, and Dolibarr would resolve it. It is not proposed here because other targets may
not tolerate an unknown code, and the change would alter behaviour for every existing installation. A
filter is opt-in and cannot regress anyone.