new: [opensem] add `paybox-system` relation

This commit is contained in:
Valentin Lab
2025-10-02 05:21:57 +02:00
parent 6e3060f734
commit 000bf3f594
3 changed files with 79 additions and 0 deletions

View File

@@ -8,3 +8,12 @@ and ~yarn.lock~ to ensure reproducible build.
We provide the resulting production ready application files in a We provide the resulting production ready application files in a
~tar.xz~. ~tar.xz~.
* Charm usage
Please note that =paylib-system= relation is required and no
auto-summon exists. It won't auto-pair neither as no charm currently
provides this relation.
So you need to explicitly express this relation to a =stub= service.

View File

@@ -0,0 +1,62 @@
#!/bin/bash
. lib/common
set -e
test=$(relation-get test 2>/dev/null) || true
site=$(relation-get site) || {
err "The 'site' option is required."
exit 1
}
rank=$(relation-get rank) || {
err "The 'rank' option is required."
exit 1
}
id=$(relation-get id) || {
err "The 'id' option is required."
exit 1
}
hmac_key=$(relation-get hmac-key) || {
err "The 'hmac-key' option is required."
exit 1
}
[ -n "$test" ] && opensem:config-set PAYBOX_TEST "$test"
opensem:config-set PAYBOX_SITE "$site"
opensem:config-set PAYBOX_RANK "$rank"
opensem:config-set PAYBOX_ID "$id"
opensem:config-set PAYBOX_HMAC_KEY "$hmac_key"
paybox_url="http://www1.paybox.com/wp-content/uploads/2014/03/pubkey.pem"
paybox_pubkey_path="$SERVICE_DATASTORE/var/lib/opensem/paybox/pubkey.pem"
if ! [ -f "$paybox_pubkey_path" ]; then
mkdir -p "${paybox_pubkey_path%/*}"
if ! curl -sSL "$paybox_url" -o "$paybox_pubkey_path"; then
err "Failed to download Paybox public key from $paybox_url"
exit 1
fi
fi
## and create the mount point also:
paybox_mount_dir="$SERVICE_CONFIGSTORE/opt/apps/$SERVICE_NAME/storage/paybox"
if ! [ -d "$paybox_mount_dir" ]; then
mkdir -p "$paybox_mount_dir" || {
err "Could not create directory $paybox_mount_dir"
exit 1
}
fi
php_fpm_service=$(service:traverse "$SERVICE_NAME":php-fpm) || {
err "Could not find php-fpm service for $SERVICE_NAME"
exit 1
}
config-add "
services:
$php_fpm_service:
volumes:
- $SERVICE_DATASTORE/var/lib/opensem/paybox:/opt/apps/$SERVICE_NAME/storage/paybox:ro
"

View File

@@ -74,3 +74,11 @@ uses:
solves: solves:
unmanaged-logs: "in docker logs" unmanaged-logs: "in docker logs"
#default-options: #default-options:
paybox-system:
#constraint: required | recommended | optional
#auto: pair | summon | none ## default: pair
constraint: required
auto: pair
solves:
missing-payment: "credit card payment"
#default-options: