merchant

Merchant backend to process payments, run by merchants
Log | Files | Refs | Submodules | README | LICENSE

commit d9cf9ee80fe28e01aa94c604c34e411b51a0d7ff
parent aa49fde2615f1b27cf1af765963bc1953fb11d0b
Author: Christian Grothoff <grothoff@gnunet.org>
Date:   Mon, 14 Jul 2025 13:00:57 +0200

add doco_ units for donau that are separate from coin_s

Diffstat:
Msrc/testing/test_merchant_api-rsa.conf | 68++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/testing/testing_api_cmd_pay_order.c | 135+++++++++++++++++++++++++++++++++++++++++--------------------------------------
2 files changed, 138 insertions(+), 65 deletions(-)

diff --git a/src/testing/test_merchant_api-rsa.conf b/src/testing/test_merchant_api-rsa.conf @@ -48,3 +48,71 @@ fee_refresh = EUR:0.03 fee_refund = EUR:0.01 rsa_keysize = 1024 CIPHER = RSA + + +# Sections starting with "doco_" specify which denominations +# the donau should support (and their respective fee structure) +[doco_eur_ct_1] +value = EUR:0.01 +duration_withdraw = 1 year +anchor_round = 1 year +duration_spend = 2 years +duration_legal = 3 years +fee_withdraw = EUR:0.00 +fee_deposit = EUR:0.00 +fee_refresh = EUR:0.01 +fee_refund = EUR:0.01 +CIPHER = RSA +rsa_keysize = 1024 + +[doco_eur_ct_10] +value = EUR:0.10 +duration_withdraw = 1 year +anchor_round = 1 year +duration_spend = 2 years +duration_legal = 3 years +fee_withdraw = EUR:0.01 +fee_deposit = EUR:0.01 +fee_refresh = EUR:0.03 +fee_refund = EUR:0.01 +CIPHER = RSA +rsa_keysize = 1024 + +[doco_eur_1] +value = EUR:1 +duration_withdraw = 1 year +anchor_round = 1 year +duration_spend = 2 years +duration_legal = 3 years +fee_withdraw = EUR:0.01 +fee_deposit = EUR:0.01 +fee_refresh = EUR:0.03 +fee_refund = EUR:0.01 +CIPHER = RSA +rsa_keysize = 1024 + +[doco_eur_5] +value = EUR:5 +duration_withdraw = 1 year +anchor_round = 1 year +duration_spend = 2 years +duration_legal = 3 years +fee_withdraw = EUR:0.01 +fee_deposit = EUR:0.01 +fee_refresh = EUR:0.03 +fee_refund = EUR:0.01 +CIPHER = RSA +rsa_keysize = 1024 + +[doco_eur_10] +value = EUR:10 +duration_withdraw = 1 year +anchor_round = 1 year +duration_spend = 2 years +duration_legal = 3 years +fee_withdraw = EUR:0.01 +fee_deposit = EUR:0.01 +fee_refresh = EUR:0.03 +fee_refund = EUR:0.01 +CIPHER = RSA +rsa_keysize = 1024 diff --git a/src/testing/testing_api_cmd_pay_order.c b/src/testing/testing_api_cmd_pay_order.c @@ -91,7 +91,7 @@ struct MerchantDonauPayData /** * Charity private key */ - //struct DONAU_CharityPrivateKeyP charity_priv; + // struct DONAU_CharityPrivateKeyP charity_priv; /** * Number of BUDIs to create or fetch. Example only. @@ -155,7 +155,7 @@ prepare_donau_data (struct TALER_TESTING_Interpreter *is, { const struct TALER_TESTING_Command *charity_post_cmd; const unsigned long long *charity_id; - //const struct DONAU_CharityPrivateKeyP *charity_priv; + // const struct DONAU_CharityPrivateKeyP *charity_priv; charity_post_cmd = TALER_TESTING_interpreter_lookup_command (is, ss-> @@ -164,16 +164,16 @@ prepare_donau_data (struct TALER_TESTING_Interpreter *is, if (GNUNET_OK != TALER_TESTING_get_trait_charity_id (charity_post_cmd, &charity_id) // Well as the charity_priv, doesn't seem to be used anywhere, I think we can skip it... - //|| - //GNUNET_OK != TALER_TESTING_get_trait_charity_priv (charity_post_cmd, + // || + // GNUNET_OK != TALER_TESTING_get_trait_charity_priv (charity_post_cmd, // &charity_priv) - ) + ) { GNUNET_break (0); return GNUNET_SYSERR; } ss->charity_id = (uint64_t) *(charity_id); - //ss->charity_priv = *(charity_priv); + // ss->charity_priv = *(charity_priv); } /* Get donau keys from trait */ @@ -254,6 +254,7 @@ prepare_donau_data (struct TALER_TESTING_Interpreter *is, ss->alg_values[cnt] = alg_values; break; case GNUNET_CRYPTO_BSA_CS: + GNUNET_assert (0); // FIXME: BUG-#### Cs support missing/broken for donau // FUCK THIS CS CASE // struct CSR_Data *csr_data = GNUNET_new (struct CSR_Data); // TALER_cs_withdraw_nonce_derive ( // FIXME: write new method @@ -280,29 +281,29 @@ prepare_donau_data (struct TALER_TESTING_Interpreter *is, } } - { + { + json_t *budikeypairs = json_array (); - json_t *budikeypairs = json_array (); - GNUNET_assert (NULL != budikeypairs); + GNUNET_assert (NULL != budikeypairs); + for (size_t i = 0; i < ss->num_bkps; i++) + { + /* One object per BKP, identical layout to parse_json_bkp() */ + json_t *budikeypair = GNUNET_JSON_PACK ( + /* donation-unit hash (binary) */ + GNUNET_JSON_pack_data_auto ("h_donation_unit_pub", + &ss->bkps[i].h_donation_unit_pub), + /* blinded UDI structure (cipher-aware helper does the heavy lifting) */ + DONAU_JSON_pack_blinded_donation_identifier ("blinded_udi", + &ss->bkps[i].blinded_udi) + ); + + /* steal the reference into the array */ + GNUNET_assert (0 == json_array_append_new (budikeypairs, budikeypair)); + } - for (size_t i = 0; i < ss->num_bkps; i++) - { - /* One object per BKP, identical layout to parse_json_bkp() */ - json_t *budikeypair = GNUNET_JSON_PACK ( - /* donation-unit hash (binary) */ - GNUNET_JSON_pack_data_auto ("h_donation_unit_pub", - &ss->bkps[i].h_donation_unit_pub), - /* blinded UDI structure (cipher-aware helper does the heavy lifting) */ - DONAU_JSON_pack_blinded_donation_identifier ("blinded_udi", - &ss->bkps[i].blinded_udi)); - - /* steal the reference into the array */ - GNUNET_assert (0 == json_array_append_new (budikeypairs, budikeypair)); + ss->budis_json = budikeypairs; } - ss->budis_json = budikeypairs; - } - } return GNUNET_OK; @@ -1084,7 +1085,7 @@ pay_run (void *cls, #ifdef HAVE_DONAU_DONAU_SERVICE_H if ( (NULL == donau_urls) || - (0 == json_array_size (donau_urls)) ) + (0 == json_array_size (donau_urls)) ) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No donau_urls found in output\n"); @@ -1103,9 +1104,10 @@ pay_run (void *cls, if (ps->donau_data.charity_reference != NULL) { - if (GNUNET_OK != prepare_donau_data(is, &ps->donau_data)) { - TALER_TESTING_FAIL(is); - return; + if (GNUNET_OK != prepare_donau_data (is, &ps->donau_data)) + { + TALER_TESTING_FAIL (is); + return; } } #else /* HAVE_DONAU_DONAU_SERVICE_H */ @@ -1280,7 +1282,7 @@ pay_run (void *cls, TALER_TESTING_FAIL (is); ps->h_contract_terms = *h_proposal; - //old logic + // old logic // { // ps->oph = TALER_MERCHANT_order_pay ( // TALER_TESTING_interpreter_get_context (is), @@ -1328,38 +1330,41 @@ pay_run (void *cls, size_t oi = 0; #define ADD(_opt) opts[oi++] = (_opt) - ADD (TALER_MERCHANT_ORDER_PAY_OPTION_MERCHANT_URL (ps->merchant_url)); - ADD (TALER_MERCHANT_ORDER_PAY_OPTION_ORDER_ID (order_id)); - if (NULL != ps->session_id) - ADD (TALER_MERCHANT_ORDER_PAY_OPTION_SESSION_ID (ps->session_id)); - ADD (TALER_MERCHANT_ORDER_PAY_OPTION_H_CONTRACT (h_proposal)); - if (ps->choice_index >= 0) - ADD (TALER_MERCHANT_ORDER_PAY_OPTION_CHOICE_INDEX(ps->choice_index)); - ADD (TALER_MERCHANT_ORDER_PAY_OPTION_AMOUNT (&ps->total_amount)); - ADD (TALER_MERCHANT_ORDER_PAY_OPTION_MAX_FEE (&max_fee)); - ADD (TALER_MERCHANT_ORDER_PAY_OPTION_MERCHANT_PUB (&merchant_pub)); - ADD (TALER_MERCHANT_ORDER_PAY_OPTION_TIMESTAMP (timestamp)); - ADD (TALER_MERCHANT_ORDER_PAY_OPTION_REFUND_DEADLINE(refund_deadline)); - ADD (TALER_MERCHANT_ORDER_PAY_OPTION_PAY_DEADLINE (pay_deadline)); - ADD (TALER_MERCHANT_ORDER_PAY_OPTION_H_WIRE (&h_wire)); - ADD (TALER_MERCHANT_ORDER_PAY_OPTION_COINS (npay_coins, - pay_coins)); - if (len_use_tokens > 0) - ADD (TALER_MERCHANT_ORDER_PAY_OPTION_INPUT_TOKENS(len_use_tokens, - use_tokens)); - if (len_output_tokens > 0) - ADD (TALER_MERCHANT_ORDER_PAY_OPTION_OUTPUT_TOKENS(len_output_tokens, - output_tokens)); + ADD (TALER_MERCHANT_ORDER_PAY_OPTION_MERCHANT_URL (ps->merchant_url)); + ADD (TALER_MERCHANT_ORDER_PAY_OPTION_ORDER_ID (order_id)); + if (NULL != ps->session_id) + ADD (TALER_MERCHANT_ORDER_PAY_OPTION_SESSION_ID (ps->session_id)); + ADD (TALER_MERCHANT_ORDER_PAY_OPTION_H_CONTRACT (h_proposal)); + if (ps->choice_index >= 0) + ADD (TALER_MERCHANT_ORDER_PAY_OPTION_CHOICE_INDEX (ps->choice_index)); + ADD (TALER_MERCHANT_ORDER_PAY_OPTION_AMOUNT (&ps->total_amount)); + ADD (TALER_MERCHANT_ORDER_PAY_OPTION_MAX_FEE (&max_fee)); + ADD (TALER_MERCHANT_ORDER_PAY_OPTION_MERCHANT_PUB (&merchant_pub)); + ADD (TALER_MERCHANT_ORDER_PAY_OPTION_TIMESTAMP (timestamp)); + ADD (TALER_MERCHANT_ORDER_PAY_OPTION_REFUND_DEADLINE (refund_deadline)); + ADD (TALER_MERCHANT_ORDER_PAY_OPTION_PAY_DEADLINE (pay_deadline)); + ADD (TALER_MERCHANT_ORDER_PAY_OPTION_H_WIRE (&h_wire)); + ADD (TALER_MERCHANT_ORDER_PAY_OPTION_COINS (npay_coins, + pay_coins)); + if (len_use_tokens > 0) + ADD (TALER_MERCHANT_ORDER_PAY_OPTION_INPUT_TOKENS (len_use_tokens, + use_tokens)); + if (len_output_tokens > 0) + ADD (TALER_MERCHANT_ORDER_PAY_OPTION_OUTPUT_TOKENS (len_output_tokens, + output_tokens)); #ifdef HAVE_DONAU_DONAU_SERVICE_H - if (ps->donau_data.charity_reference) { - ADD (TALER_MERCHANT_ORDER_PAY_OPTION_DONAU_URL (ps->donau_data.donau_url)); - ADD (TALER_MERCHANT_ORDER_PAY_OPTION_DONAU_YEAR (ps->donau_data.year)); - ADD (TALER_MERCHANT_ORDER_PAY_OPTION_DONAU_BUDIS(ps->donau_data.budis_json)); - } + if (ps->donau_data.charity_reference) + { + ADD (TALER_MERCHANT_ORDER_PAY_OPTION_DONAU_URL (ps->donau_data.donau_url) + ); + ADD (TALER_MERCHANT_ORDER_PAY_OPTION_DONAU_YEAR (ps->donau_data.year)); + ADD (TALER_MERCHANT_ORDER_PAY_OPTION_DONAU_BUDIS (ps->donau_data. + budis_json)); + } #endif - ADD (TALER_MERCHANT_ORDER_PAY_OPTION_TERMINATE ()); + ADD (TALER_MERCHANT_ORDER_PAY_OPTION_TERMINATE ()); #undef ADD if (TALER_MERCHANT_OPOEC_OK != @@ -1377,13 +1382,13 @@ pay_run (void *cls, npay_coins, 0); - GNUNET_array_grow(use_tokens, - len_use_tokens, - 0); + GNUNET_array_grow (use_tokens, + len_use_tokens, + 0); - GNUNET_array_grow(output_tokens, - len_output_tokens, - 0); + GNUNET_array_grow (output_tokens, + len_output_tokens, + 0); } @@ -1405,7 +1410,7 @@ pay_cleanup (void *cls, "Command `%s' did not complete.\n", TALER_TESTING_interpreter_get_current_label ( ps->is)); - //TALER_MERCHANT_order_pay_cancel (ps->oph); + // TALER_MERCHANT_order_pay_cancel (ps->oph); TALER_MERCHANT_order_pay_cancel1 (ps->oph); }