Comarch scripts
Reference of the four Comarch scripts, customer mapper, location mapper, installation customer updater and coupon mapper: handlers and examples.
Four scripts adjust the Comarch connector. The customer mapper and the location mapper add Comarch attributes to the pass data, the wallet installation customer updater decides what changes on the Comarch customer when a pass is installed or removed, and the coupon mapper adjusts, or skips, the benefit each Comarch coupon becomes. This page is the reference for extensions.comarch.customerMapper, extensions.comarch.locationMapper, extensions.comarch.walletInstallationCustomerUpdater and extensions.comarch.couponMapper. The connector is described on the Comarch extensibility page; the rules shared by every connector script are in Connector scripts.
Registration
Key
Slot file
Methods (required in bold)
extensions.comarch.customerMapper
comarch.customerMapper.js
MapFromComarch, MapTransactionBalanceFromComarch
extensions.comarch.locationMapper
comarch.locationMapper.js
MapFromComarch
extensions.comarch.walletInstallationCustomerUpdater
comarch.walletInstallationCustomerUpdater.js
Update
extensions.comarch.couponMapper
comarch.couponMapper.js
MapFromComarch
The slots are the Customer mapper, Location mapper, Wallet pass add/remove script and Coupon mapper scripts of the Advanced tab of the Comarch settings editor, and are read and written with GET and PUT /api/{tenantId}/admin/extensions/comarch/scripts. When no script is registered for a key, the default behavior applies. The Wallet pass add/remove script and Coupon mapper slots appear only while their setting is on, and switching Sync wallet attribute when a pass is added or removed off deletes the add/remove script file.
When it runs
customerMapper.MapFromComarch
After the Comarch customer is fetched and the default comarch.customer.* fields are written
customerMapper.MapTransactionBalanceFromComarch
After comarch.customer.waitingToBookPoints is written, only when Retrieve customer transaction balance is on. The raw balance is under debug.comarch.customer.customerTransactionBalanceInformation
locationMapper.MapFromComarch
After the store is fetched and the default comarch.store.* fields are written
walletInstallationCustomerUpdater
On every pass installation and removal, on every device, while the Comarch setting Sync wallet attribute when a pass is added or removed is on, with a fresh Comarch record. Passes without a Comarch customer id are skipped
couponMapper
For each coupon, at every pass creation and pass metadata update, while the Comarch setting Sync Comarch coupons is on. A used or cancelled coupon that never produced a benefit is skipped before the script is called
The customer mapper also runs on every refresh of a pass, including the refreshes started by the Kafka real-time updates, so it stays short.
Handlers
customerMapper
MapFromComarch
customer, account
nothing
Optional
Synchronous
customerMapper
MapTransactionBalanceFromComarch
{ Customer, Balance }, account
nothing
Optional
Synchronous
locationMapper
MapFromComarch
location, account
nothing
Optional
Synchronous
walletInstallationCustomerUpdater
Update
status, customer
a Customer with only the properties to change, or null
Optional
Synchronous
couponMapper
MapFromComarch
coupon, benefit
the benefit to sync, or null to skip the coupon
Required
Synchronous
Mappers.
customerandlocationare the raw Comarch objects, so any field of the Comarch payload can be used, not only the mapped ones.accountis the flat wallet account (see Data objects). The mappers changeaccountin place. The raw objects are visible for inspection underdebug.comarch.customeranddebug.comarch.store.Installation updater.
statushas camelCase members:device(0Apple,2Google),event(0installed,1removed),activeRegistrationCountandtotalRegistrationCount. Both counts are combined across platforms: the active count is the current number of installs including this change, and the total count is the lifetime number of installs, which never decreases. The returned customer is sent to Comarch as it is, not compared with the current record, so the update must be safe to repeat. Returningnull(or nothing) sends nothing. When the script is not registered, the write-back is skipped and logged at information level. A throw inUpdateis logged and the update is skipped.Coupon mapper.
couponhas members such asId,CouponNumber,Type,TypeName,Status(Iissued,Uused,Eexpired),StatusNameandAccountId. Returning the benefit syncs it. Returningnull, or nothing, skips the coupon, and a benefit that the script produced earlier for it is removed.
Errors and edge cases
No script registered: the default behavior applies. Without the installation updater, the install write-back is skipped.
The coupon mapper is missing while coupon sync is on: the call fails with
method MapFromComarch missing.The updater returns a customer with every property: all of them are sent. Return only what changes.
Example
The installation updater sets a WALLET attribute to Y while at least one device holds the pass, and to N otherwise. The attribute code and its values are placeholders: use the ones defined in the brand's Comarch configuration.
The coupon mapper skips the expired coupons (status E):
Common pitfalls
The updater result is not idempotent: it is sent as it is on every install and uninstall, on every device.
The coupon mapper forgets to return the benefit: returning nothing skips the coupon.
A handler is declared
async: the Comarch methods are synchronous, so the promise is not awaited.The slot's registration lines are still commented out.
Last updated

