merchant

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

commit a445ea311cd92de18b3a126b59db72896e69e3d3
parent e7e9b56abd9db5c0735ac48c1fac4b880f91e9dc
Author: bohdan-potuzhnyi <bohdan.potuzhnyi@gmail.com>
Date:   Sun, 13 Apr 2025 23:03:18 +0200

planning some staff for test of donau order pay

Diffstat:
Msrc/testing/testing_api_cmd_pay_order.c | 282+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------
1 file changed, 218 insertions(+), 64 deletions(-)

diff --git a/src/testing/testing_api_cmd_pay_order.c b/src/testing/testing_api_cmd_pay_order.c @@ -755,23 +755,15 @@ pay_run (void *cls, const char *ierror_name = NULL; unsigned int ierror_line = 0; - struct GNUNET_JSON_Specification ispec[] = { + struct GNUNET_JSON_Specification typespec[] = { GNUNET_JSON_spec_string ("type", &kind), - GNUNET_JSON_spec_string ("token_family_slug", - &slug), - GNUNET_JSON_spec_uint32 ("key_index", - &key_index), - GNUNET_JSON_spec_mark_optional ( - GNUNET_JSON_spec_uint32 ("count", - &count), - NULL), GNUNET_JSON_spec_end () }; if (GNUNET_OK != GNUNET_JSON_parse (output, - ispec, + typespec, &ierror_name, &ierror_line)) { @@ -784,64 +776,131 @@ pay_run (void *cls, TALER_TESTING_FAIL (is); } - if (0 != strcmp ("token", kind)) + if (0 == strcmp ("tax-receipt", kind)) { - continue; - } + const json_t *donau_urls; + + // For test we care only about the presence of it + struct GNUNET_JSON_Specification donauspec[] = { + GNUNET_JSON_spec_array_const ("donau_urls", + &donau_urls), + + GNUNET_JSON_spec_end () + }; + + if (GNUNET_OK != + GNUNET_JSON_parse (output, + donauspec, + &ierror_name, + &ierror_line)) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Parser failed on %s:%u for input `%s'\n", + ierror_name, + ierror_line, + json_dumps (output, + JSON_INDENT (2))); + TALER_TESTING_FAIL (is); + } + + #ifdef HAVE_DONAU_DONAU_SERVICE_H + //FIXME + //Theoretically everything is fine, and now we want to finish preparing the payment for the donau + #else /* HAVE_DONAU_DONAU_SERVICE_H */ + //Theoretically we have thought about paying without donau_url being selected, so could proceed... + // + #endif /* HAVE_DONAU_DONAU_SERVICE_H */ - GNUNET_array_grow (ps->issued_tokens, - ps->num_issued_tokens, - ps->num_issued_tokens + count); + } - for (unsigned int k = 0; k < count; k++) + if (0 == strcmp ("token", kind)) { - struct TALER_MERCHANT_PrivateTokenDetails *details = - &ps->issued_tokens[ps->num_issued_tokens - count + k]; - - if (GNUNET_OK != - find_token_public_key (token_families, - slug, - key_index, - &details->issue_pub)) - { - TALER_TESTING_FAIL (is); - } - - /* Only RSA is supported for now. */ - GNUNET_assert (GNUNET_CRYPTO_BSA_RSA == - details->issue_pub.public_key->cipher); - - TALER_token_blind_input_copy (&details->blinding_inputs, - TALER_token_blind_input_rsa_singleton () - ); - /* FIXME: Where to get details->blinding_inputs from? */ - TALER_token_use_setup_random (&details->master); - TALER_token_use_setup_priv (&details->master, - &details->blinding_inputs, - &details->token_priv); - TALER_token_use_blinding_secret_create (&details->master, - &details->blinding_inputs, - &details->blinding_secret); - GNUNET_CRYPTO_eddsa_key_get_public (&details->token_priv.private_key - , - &details->token_pub.public_key); - GNUNET_CRYPTO_hash (&details->token_pub.public_key, - sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey), - &details->h_token_pub.hash); - details->envelope.blinded_pub = GNUNET_CRYPTO_message_blind_to_sign - ( - details->issue_pub.public_key, - &details->blinding_secret, - NULL, /* FIXME: Add session nonce to support CS tokens */ - &details->h_token_pub.hash, - sizeof (details->h_token_pub.hash), - details->blinding_inputs.blinding_inputs); - - if (NULL == details->envelope.blinded_pub) - { - GNUNET_break (0); - TALER_TESTING_FAIL (is); - } + struct GNUNET_JSON_Specification ispec[] = { + GNUNET_JSON_spec_string ("token_family_slug", + &slug), + GNUNET_JSON_spec_uint32 ("key_index", + &key_index), + GNUNET_JSON_spec_mark_optional ( + GNUNET_JSON_spec_uint32 ("count", + &count), + NULL), + GNUNET_JSON_spec_end () + }; + + if (GNUNET_OK != + GNUNET_JSON_parse (output, + ispec, + &ierror_name, + &ierror_line)) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Parser failed on %s:%u for input `%s'\n", + ierror_name, + ierror_line, + json_dumps (output, + JSON_INDENT (2))); + TALER_TESTING_FAIL (is); + } + + if (0 != strcmp ("token", kind)) + { + continue; + } + + GNUNET_array_grow (ps->issued_tokens, + ps->num_issued_tokens, + ps->num_issued_tokens + count); + + for (unsigned int k = 0; k < count; k++) + { + struct TALER_MERCHANT_PrivateTokenDetails *details = + &ps->issued_tokens[ps->num_issued_tokens - count + k]; + + if (GNUNET_OK != + find_token_public_key (token_families, + slug, + key_index, + &details->issue_pub)) + { + TALER_TESTING_FAIL (is); + } + + /* Only RSA is supported for now. */ + GNUNET_assert (GNUNET_CRYPTO_BSA_RSA == + details->issue_pub.public_key->cipher); + + TALER_token_blind_input_copy (&details->blinding_inputs, + TALER_token_blind_input_rsa_singleton () + ); + /* FIXME: Where to get details->blinding_inputs from? */ + TALER_token_use_setup_random (&details->master); + TALER_token_use_setup_priv (&details->master, + &details->blinding_inputs, + &details->token_priv); + TALER_token_use_blinding_secret_create (&details->master, + &details->blinding_inputs, + &details->blinding_secret); + GNUNET_CRYPTO_eddsa_key_get_public (&details->token_priv.private_key + , + &details->token_pub.public_key); + GNUNET_CRYPTO_hash (&details->token_pub.public_key, + sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey), + &details->h_token_pub.hash); + details->envelope.blinded_pub = GNUNET_CRYPTO_message_blind_to_sign + ( + details->issue_pub.public_key, + &details->blinding_secret, + NULL, /* FIXME: Add session nonce to support CS tokens */ + &details->h_token_pub.hash, + sizeof (details->h_token_pub.hash), + details->blinding_inputs.blinding_inputs); + + if (NULL == details->envelope.blinded_pub) + { + GNUNET_break (0); + TALER_TESTING_FAIL (is); + } + } } } } @@ -1099,6 +1158,101 @@ TALER_TESTING_cmd_merchant_pay_order_choices (const char *label, } +//#ifdef HAVE_DONAU_DONAU_SERVICE_H +// +//struct MerchantDonauPayData +//{ +// /** +// * Donau URL. +// */ +// const char *donau_url; +// +// /** +// * Number of BUDIs to create or fetch. Example only. +// */ +// size_t num_budis; +// +// /** +// * BUDI keypairs used in the payment (blinded_udi + pubkey). +// */ +// struct DONAU_BlindedUniqueDonorIdentifierKeyPair *bkp; +// +// /** +// * Blinding secrets, if needed for each BUDI (CS vs. RSA). +// */ +// union GNUNET_CRYPTO_BlindingSecretP *blinding_secrets; +// +// /** +// * Hash of the salted donor tax id, if relevant. +// */ +// struct DONAU_HashDonorTaxId h_donor_tax_id; +// +// /** +// * Possibly store references to the Donau keys, or anything +// * else needed to blind or sign UDIs, etc. +// */ +// struct DONAU_Keys *donau_keys; +// +// /** +// * If using the CS approach, we might track how many +// * asynchronous calls are still pending, etc. +// */ +// unsigned int cs_pending; +// +//}; +// +////FIXME: Here I need a command which will parse the data from this system, and donau system +//// and will prepare all necessary data for the donau pay order +//static enum GNUNET_GenericReturnValue +//prepare_donau_data(){ +// +//}; +// +////FIXME: Maybe it make sense to have it here, to preload some data and +//// then proceed on the next steps +//struct TALER_TESTING_Command +//TALER_TESTING_cmd_merchant_pay_order_donau (const char *label, +// const char *merchant_url, +// unsigned int http_status, +// const char *proposal_reference, +// const char *coin_reference, +// const char *amount_with_fee, +// const char *amount_without_fee, +// const char *session_id, +// int choice_index) +//{ +// struct PayState *ps; +// +// struct MerchantDonauPayData *mdpd; +// +// //FIXME: Maybe we can fill the mdpd with some data inside +// // and then pass it to the pay order +// +// ps = GNUNET_new (struct PayState); +// ps->http_status = http_status; +// ps->proposal_reference = proposal_reference; +// ps->coin_reference = coin_reference; +// ps->merchant_url = merchant_url; +// ps->amount_with_fee = amount_with_fee; +// ps->amount_without_fee = amount_without_fee; +// ps->session_id = session_id; +// ps->token_reference = NULL; +// ps->choice_index = choice_index; +// { +// struct TALER_TESTING_Command cmd = { +// .cls = ps, +// .label = label, +// .run = &donau_pay_run, +// .cleanup = &pay_cleanup, +// .traits = &pay_traits +// }; +// +// return cmd; +// } +//} +//#endif /* HAVE_DONAU_DONAU_SERVICE_H */ + + struct TALER_TESTING_Command TALER_TESTING_cmd_merchant_pay_order (const char *label, const char *merchant_url,