From e002253231d1179332e725a2694fdbd8676203ae Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Mon, 11 Sep 2023 15:32:48 +0200 Subject: add wallet_data support to merchant --- src/backenddb/merchant-0001.sql | 2 +- src/include/taler_merchant_service.h | 12 ++++++++++-- src/lib/merchant_api_post_order_paid.c | 4 ++++ src/lib/merchant_api_post_order_pay.c | 9 ++++++++- src/testing/testing_api_cmd_pay_order.c | 1 + src/testing/testing_api_cmd_post_orders_paid.c | 1 + 6 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/backenddb/merchant-0001.sql b/src/backenddb/merchant-0001.sql index d1ce432e..4e2b0639 100644 --- a/src/backenddb/merchant-0001.sql +++ b/src/backenddb/merchant-0001.sql @@ -316,7 +316,7 @@ CREATE TABLE IF NOT EXISTS merchant_contract_terms REFERENCES merchant_instances (merchant_serial) ON DELETE CASCADE ,order_id TEXT NOT NULL ,contract_terms BYTEA NOT NULL - ,wallet_data BYTEA DEFAULT NULL + ,wallet_data TEXT DEFAULT NULL ,h_contract_terms BYTEA NOT NULL CHECK (LENGTH(h_contract_terms)=64) ,creation_time INT8 NOT NULL ,pay_deadline INT8 NOT NULL diff --git a/src/include/taler_merchant_service.h b/src/include/taler_merchant_service.h index ef7a46ed..6d79d45e 100644 --- a/src/include/taler_merchant_service.h +++ b/src/include/taler_merchant_service.h @@ -919,12 +919,14 @@ struct TALER_MERCHANT_AccountsPostResponse /** * Details depending on HTTP status. */ - union { + union + { /** * Details returned on #MHD_HTTP_OK. */ - struct { + struct + { /** * Hash of @e payto_uri and @e salt. @@ -2876,6 +2878,7 @@ struct TALER_MERCHANT_PaidCoin * @param merchant_url base URL of the merchant * @param order_id which order should be paid * @param session_id session to pay for, or NULL for none + * @param wallet_data inputs from the wallet for the contract, NULL for none * @param num_coins length of the @a coins array * @param coins array of coins to pay with * @param pay_cb the callback to call when a reply for this request is available @@ -2888,6 +2891,7 @@ TALER_MERCHANT_order_pay_frontend ( const char *merchant_url, const char *order_id, const char *session_id, + const json_t *wallet_data, unsigned int num_coins, const struct TALER_MERCHANT_PaidCoin coins[static num_coins], TALER_MERCHANT_OrderPayCallback pay_cb, @@ -2952,6 +2956,7 @@ struct TALER_MERCHANT_PayCoin * @param merchant_url base URL of the merchant * @param session_id session to pay for, or NULL for none * @param h_contract hash of the contact of the merchant with the customer + * @param wallet_data inputs from the wallet for the contract, NULL for none * @param amount total value of the contract to be paid to the merchant * @param max_fee maximum fee covered by the merchant (according to the contract) * @param merchant_pub the public key of the merchant (used to identify the merchant for refund requests) @@ -2973,6 +2978,7 @@ TALER_MERCHANT_order_pay ( const char *merchant_url, const char *session_id, const struct TALER_PrivateContractHashP *h_contract, + const json_t *wallet_data, const struct TALER_Amount *amount, const struct TALER_Amount *max_fee, const struct TALER_MerchantPublicKeyP *merchant_pub, @@ -3060,6 +3066,7 @@ typedef void * @param order_id which order should be paid * @param session_id session to pay for, or NULL for none * @param h_contract_terms hash of the contract terms + * @param wallet_data_hash inputs from the wallet for the contract, NULL for none * @param merchant_sig signature from the merchant * affirming payment, or NULL on errors * @param paid_cb the callback to call when a reply for this request is available @@ -3073,6 +3080,7 @@ TALER_MERCHANT_order_paid ( const char *order_id, const char *session_id, const struct TALER_PrivateContractHashP *h_contract_terms, + const struct GNUNET_HashCode *wallet_data_hash, const struct TALER_MerchantSignatureP *merchant_sig, TALER_MERCHANT_OrderPaidCallback paid_cb, void *paid_cb_cls); diff --git a/src/lib/merchant_api_post_order_paid.c b/src/lib/merchant_api_post_order_paid.c index a483ba41..785d956f 100644 --- a/src/lib/merchant_api_post_order_paid.c +++ b/src/lib/merchant_api_post_order_paid.c @@ -188,6 +188,7 @@ TALER_MERCHANT_order_paid ( const char *order_id, const char *session_id, const struct TALER_PrivateContractHashP *h_contract_terms, + const struct GNUNET_HashCode *wallet_data_hash, const struct TALER_MerchantSignatureP *merchant_sig, TALER_MERCHANT_OrderPaidCallback paid_cb, void *paid_cb_cls) @@ -200,6 +201,9 @@ TALER_MERCHANT_order_paid ( merchant_sig), GNUNET_JSON_pack_data_auto ("h_contract", h_contract_terms), + GNUNET_JSON_pack_allow_null ( + GNUNET_JSON_pack_data_auto ("wallet_data_hash", + wallet_data_hash)), GNUNET_JSON_pack_string ("session_id", session_id)); oph = GNUNET_new (struct TALER_MERCHANT_OrderPaidHandle); diff --git a/src/lib/merchant_api_post_order_pay.c b/src/lib/merchant_api_post_order_pay.c index 24c1cf61..fc2e9a29 100644 --- a/src/lib/merchant_api_post_order_pay.c +++ b/src/lib/merchant_api_post_order_pay.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2014-2021 Taler Systems SA + Copyright (C) 2014-2023 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -576,6 +576,7 @@ TALER_MERCHANT_order_pay_frontend ( const char *merchant_url, const char *order_id, const char *session_id, + const json_t *wallet_data, unsigned int num_coins, const struct TALER_MERCHANT_PaidCoin coins[static num_coins], TALER_MERCHANT_OrderPayCallback pay_cb, @@ -665,6 +666,9 @@ TALER_MERCHANT_order_pay_frontend ( pay_obj = GNUNET_JSON_PACK ( GNUNET_JSON_pack_array_steal ("coins", j_coins), + GNUNET_JSON_pack_allow_null ( + GNUNET_JSON_pack_object_incref ("wallet_data", + (json_t *) wallet_data)), GNUNET_JSON_pack_allow_null ( GNUNET_JSON_pack_string ("session_id", session_id))); @@ -728,6 +732,7 @@ TALER_MERCHANT_order_pay ( const char *merchant_url, const char *session_id, const struct TALER_PrivateContractHashP *h_contract_terms, + const json_t *wallet_data, const struct TALER_Amount *amount, const struct TALER_Amount *max_fee, const struct TALER_MerchantPublicKeyP *merchant_pub, @@ -776,6 +781,7 @@ TALER_MERCHANT_order_pay ( &fee, h_wire, h_contract_terms, + NULL /* FIXME: compute using wallet_data */, coin->h_age_commitment, NULL /* h_extensions! */, &h_denom_pub, @@ -800,6 +806,7 @@ TALER_MERCHANT_order_pay ( merchant_url, order_id, session_id, + wallet_data, num_coins, pc, pay_cb, diff --git a/src/testing/testing_api_cmd_pay_order.c b/src/testing/testing_api_cmd_pay_order.c index efc94a80..0b84c8a6 100644 --- a/src/testing/testing_api_cmd_pay_order.c +++ b/src/testing/testing_api_cmd_pay_order.c @@ -438,6 +438,7 @@ pay_run (void *cls, ps->merchant_url, ps->session_id, h_proposal, + NULL, &ps->total_amount, &max_fee, &merchant_pub, diff --git a/src/testing/testing_api_cmd_post_orders_paid.c b/src/testing/testing_api_cmd_post_orders_paid.c index a7b8c47e..fd6d2892 100644 --- a/src/testing/testing_api_cmd_post_orders_paid.c +++ b/src/testing/testing_api_cmd_post_orders_paid.c @@ -185,6 +185,7 @@ paid_run (void *cls, order_id, ops->session_id, h_contract_terms, + NULL, merchant_sig, &paid_cb, ops); -- cgit v1.2.3