campingmontagut/deploy/decode_base64url.sql
jordi fita mas ff6750fbea Handle payment notifications from Redsys
I have to basically do the reverse of signing the request to verify that
the notification comes from them.  Lots of code just for that.

I return the changed status from the PL/pgSQL function because i will
need to email customers when a payment is completed, and i need to know
when.
2024-02-13 02:38:38 +01:00

23 lines
550 B
PL/PgSQL

-- Deploy camper:decode_base64url to pg
-- requires: roles
-- requires: schema_camper
begin;
set search_path to camper, public;
create or replace function decode_base64url(encoded text) returns bytea as
$$
select decode(translate(encoded, '-_', '+/'), 'base64');
$$
language sql
immutable
;
revoke execute on function decode_base64url(text) from public;
grant execute on function decode_base64url(text) to guest;
grant execute on function decode_base64url(text) to employee;
grant execute on function decode_base64url(text) to admin;
commit;