diff options
Diffstat (limited to 'src/backend/taler-merchant-httpd_contract.c')
-rw-r--r-- | src/backend/taler-merchant-httpd_contract.c | 182 |
1 files changed, 0 insertions, 182 deletions
diff --git a/src/backend/taler-merchant-httpd_contract.c b/src/backend/taler-merchant-httpd_contract.c index f850f94d..38c82e70 100644 --- a/src/backend/taler-merchant-httpd_contract.c +++ b/src/backend/taler-merchant-httpd_contract.c @@ -45,185 +45,3 @@ TMH_string_to_contract_output_type (const char *str) return TALER_MCOT_INVALID; } - -enum GNUNET_GenericReturnValue -TMH_serialize_contract (const struct TALER_MerchantContract *contract, - const struct TMH_MerchantInstance *instance, - json_t *exchanges, - json_t **out) -{ - if (TALER_MCV_V0 == contract->version) - { - return TMH_serialize_contract_v0 (contract, instance, exchanges, out); - } - - if (TALER_MCV_V1 == contract->version) - { - return TMH_serialize_contract_v1 (contract, instance, exchanges, out); - } - - GNUNET_break (0); - return GNUNET_SYSERR; -} - -enum GNUNET_GenericReturnValue -TMH_serialize_contract_v0 (const struct TALER_MerchantContract *contract, - const struct TMH_MerchantInstance *instance, - json_t *exchanges, - json_t **out) -{ - json_t *merchant; - - { - merchant = GNUNET_JSON_PACK ( - GNUNET_JSON_pack_string ("name", - instance->settings.name), - GNUNET_JSON_pack_allow_null ( - GNUNET_JSON_pack_string ("website", - instance->settings.website)), - GNUNET_JSON_pack_allow_null ( - GNUNET_JSON_pack_string ("email", - instance->settings.email)), - GNUNET_JSON_pack_allow_null ( - GNUNET_JSON_pack_string ("logo", - instance->settings.logo))); - GNUNET_assert (NULL != merchant); - { - json_t *loca; - - /* Handle merchant address */ - loca = instance->settings.address; - if (NULL != loca) - { - loca = json_deep_copy (loca); - GNUNET_assert (NULL != loca); - GNUNET_assert (0 == - json_object_set_new (merchant, - "address", - loca)); - } - } - { - json_t *juri; - - /* Handle merchant jurisdiction */ - juri = instance->settings.jurisdiction; - if (NULL != juri) - { - juri = json_deep_copy (juri); - GNUNET_assert (NULL != juri); - GNUNET_assert (0 == - json_object_set_new (merchant, - "jurisdiction", - juri)); - } - } - } - - if (1 != contract->choices_len || NULL == contract->choices) - { - GNUNET_break (0); - return GNUNET_SYSERR; - } - - if (1 != contract->limits_len || NULL == contract->limits) - { - GNUNET_break (0); - return GNUNET_SYSERR; - } - - struct TALER_MerchantContractChoice *choice = contract->choices; - - *out = GNUNET_JSON_PACK ( - GNUNET_JSON_pack_string ("summary", - choice->summary), - GNUNET_JSON_pack_allow_null ( - GNUNET_JSON_pack_object_incref ("summary_i18n", - choice->summary_i18n)), - GNUNET_JSON_pack_allow_null ( - GNUNET_JSON_pack_string ("public_reorder_url", - contract->public_reorder_url)), - GNUNET_JSON_pack_allow_null ( - GNUNET_JSON_pack_string ("fulfillment_message", - choice->fulfillment_message)), - GNUNET_JSON_pack_allow_null ( - GNUNET_JSON_pack_object_incref ("fulfillment_message_i18n", - choice->fulfillment_message_i18n)), - GNUNET_JSON_pack_allow_null ( - GNUNET_JSON_pack_string ("fulfillment_url", - choice->fulfillment_url)), - GNUNET_JSON_pack_array_incref ("products", - choice->products), - GNUNET_JSON_pack_data_auto ("h_wire", - &contract->limits->h_wire), - GNUNET_JSON_pack_string ("wire_method", - contract->limits->wire_method), - GNUNET_JSON_pack_string ("order_id", - contract->order_id), - GNUNET_JSON_pack_timestamp ("timestamp", - contract->timestamp), - GNUNET_JSON_pack_timestamp ("pay_deadline", - contract->pay_deadline), - GNUNET_JSON_pack_timestamp ("wire_transfer_deadline", - contract->wire_deadline), - GNUNET_JSON_pack_allow_null ( - GNUNET_JSON_pack_timestamp ("delivery_date", - contract->delivery_date)), - GNUNET_JSON_pack_allow_null ( - GNUNET_JSON_pack_object_incref ("delivery_location", - contract->delivery_location)), - GNUNET_JSON_pack_string ("merchant_base_url", - contract->merchant_base_url), - GNUNET_JSON_pack_object_incref ("merchant", - merchant), - GNUNET_JSON_pack_data_auto ("merchant_pub", - &instance->merchant_pub), - GNUNET_JSON_pack_array_incref ("exchanges", - exchanges), - TALER_JSON_pack_amount ("max_fee", - &contract->limits->max_fee), - TALER_JSON_pack_amount ("amount", - &contract->brutto), - GNUNET_JSON_pack_allow_null ( - GNUNET_JSON_pack_object_incref ("extra", - (json_t *) contract->extra)) - ); - - /* Pack does not work here, because it doesn't set zero-values for timestamps */ - GNUNET_assert (0 == - json_object_set_new (*out, - "refund_deadline", - GNUNET_JSON_from_timestamp ( - contract->refund_deadline))); - GNUNET_log ( - GNUNET_ERROR_TYPE_INFO, - "Refund deadline for contact is %llu\n", - (unsigned long long) contract->refund_deadline.abs_time.abs_value_us); - GNUNET_log ( - GNUNET_ERROR_TYPE_INFO, - "Wallet timestamp for contact is %llu\n", - (unsigned long long) contract->timestamp.abs_time.abs_value_us); - - /* Pack does not work here, because it sets zero-values for relative times */ - /* auto_refund should only be set if it is not 0 */ - if (! GNUNET_TIME_relative_is_zero (contract->auto_refund)) - { - GNUNET_assert (0 == - json_object_set_new (*out, - "auto_refund", - GNUNET_JSON_from_time_rel ( - contract->auto_refund))); - } - - return GNUNET_OK; -} - -enum GNUNET_GenericReturnValue -TMH_serialize_contract_v1 (const struct TALER_MerchantContract *contract, - const struct TMH_MerchantInstance *instance, - json_t *exchanges, - json_t **out) -{ - // TODO: Implement v1 serializer - return GNUNET_SYSERR; -} |