aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Buchanan <jonathan.russ.buchanan@gmail.com>2020-07-16 17:03:07 -0400
committerJonathan Buchanan <jonathan.russ.buchanan@gmail.com>2020-07-16 17:03:07 -0400
commit6c04f551883da165fa90ae830ebd56642abca361 (patch)
tree694e835ff494786fa778a6534d70671ce1309f3c
parent90adbb36f71224fe4ae8ebace1bc091c4651734f (diff)
downloadmerchant-6c04f551883da165fa90ae830ebd56642abca361.tar.gz
merchant-6c04f551883da165fa90ae830ebd56642abca361.zip
fix #6430
-rw-r--r--src/backend/taler-merchant-httpd_private-get-orders-ID.c11
-rw-r--r--src/testing/test_merchant_api.c4
-rw-r--r--src/testing/testing_api_cmd_post_orders.c56
3 files changed, 33 insertions, 38 deletions
diff --git a/src/backend/taler-merchant-httpd_private-get-orders-ID.c b/src/backend/taler-merchant-httpd_private-get-orders-ID.c
index 87408fe5..de5cb980 100644
--- a/src/backend/taler-merchant-httpd_private-get-orders-ID.c
+++ b/src/backend/taler-merchant-httpd_private-get-orders-ID.c
@@ -825,6 +825,14 @@ TMH_private_get_orders_ID (const struct TMH_RequestHandler *rh,
825 hc->infix, 825 hc->infix,
826 &gorc->contract_terms, 826 &gorc->contract_terms,
827 &gorc->order_serial); 827 &gorc->order_serial);
828 if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs)
829 {
830 /* We don't have contract terms, but the order may still exist. */
831 qs = TMH_db->lookup_order (TMH_db->cls,
832 hc->instance->settings.id,
833 hc->infix,
834 &gorc->contract_terms);
835 }
828 if (0 > qs) 836 if (0 > qs)
829 { 837 {
830 /* single, read-only SQL statements should never cause 838 /* single, read-only SQL statements should never cause
@@ -906,7 +914,7 @@ TMH_private_get_orders_ID (const struct TMH_RequestHandler *rh,
906 gorc->session_id, 914 gorc->session_id,
907 &paid, 915 &paid,
908 &wired); 916 &wired);
909 if (0 >= qs) 917 if (0 > qs)
910 { 918 {
911 /* single, read-only SQL statements should never cause 919 /* single, read-only SQL statements should never cause
912 serialization problems, and the entry should exist as per above */ 920 serialization problems, and the entry should exist as per above */
@@ -916,6 +924,7 @@ TMH_private_get_orders_ID (const struct TMH_RequestHandler *rh,
916 TALER_EC_GET_ORDERS_DB_FETCH_PAYMENT_STATUS, 924 TALER_EC_GET_ORDERS_DB_FETCH_PAYMENT_STATUS,
917 "DB error fetching payment status"); 925 "DB error fetching payment status");
918 } 926 }
927 /* qs == 0: the order hasn't been claimed, but this is okay. */
919 if ((! paid) && 928 if ((! paid) &&
920 (NULL != gorc->session_id)) 929 (NULL != gorc->session_id))
921 { 930 {
diff --git a/src/testing/test_merchant_api.c b/src/testing/test_merchant_api.c
index 2d9e9266..1a074240 100644
--- a/src/testing/test_merchant_api.c
+++ b/src/testing/test_merchant_api.c
@@ -189,6 +189,10 @@ run (void *cls,
189 false, 189 false,
190 false, 190 false,
191 MHD_HTTP_OK), 191 MHD_HTTP_OK),
192 TALER_TESTING_cmd_merchant_purge_instance ("purge-default",
193 merchant_url,
194 "default",
195 MHD_HTTP_NO_CONTENT),
192 TALER_TESTING_cmd_end () 196 TALER_TESTING_cmd_end ()
193 }; 197 };
194 198
diff --git a/src/testing/testing_api_cmd_post_orders.c b/src/testing/testing_api_cmd_post_orders.c
index 8ae0babc..6195d99c 100644
--- a/src/testing/testing_api_cmd_post_orders.c
+++ b/src/testing/testing_api_cmd_post_orders.c
@@ -119,7 +119,6 @@ struct OrdersState
119}; 119};
120 120
121 121
122
123/** 122/**
124 * Offer internal data to other commands. 123 * Offer internal data to other commands.
125 * 124 *
@@ -538,46 +537,29 @@ make_order_json (const char *order_id,
538 const char *amount, 537 const char *amount,
539 char **order) 538 char **order)
540{ 539{
541 struct GNUNET_TIME_Absolute refund_deadline_round = refund_deadline; 540 struct GNUNET_TIME_Absolute refund = refund_deadline;
542 char rd_str[64]; 541 struct GNUNET_TIME_Absolute pay = pay_deadline;
543
544 struct GNUNET_TIME_Absolute pay_deadline_round = pay_deadline;
545 char pd_str[64];
546 542
547 GNUNET_TIME_round_abs (&refund_deadline_round); 543 json_t *contract_terms;
548 GNUNET_TIME_round_abs (&pay_deadline_round);
549 544
550 GNUNET_snprintf (rd_str, 545 GNUNET_TIME_round_abs (&refund);
551 64, 546 GNUNET_TIME_round_abs (&pay);
552 "{\"t_ms\":%llu}", 547
553 refund_deadline_round.abs_value_us / 1000LL); 548 contract_terms = json_pack (
554 if (GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us == pay_deadline.abs_value_us) 549 "{s:s, s:s, s:s, s:s, s:o, s:o}",
555 { 550 "summary", "merchant-lib testcase",
556 GNUNET_snprintf (pd_str, 551 "order_id", order_id,
557 64, 552 "amount", amount,
558 "{\"t_ms\":\"never\"}"); 553 "fulfillment_url", "https://example.com",
559 } 554 "refund_deadline", GNUNET_JSON_from_time_abs (refund_deadline),
560 else 555 "pay_deadline", GNUNET_JSON_from_time_abs (pay_deadline)
561 { 556 );
562 GNUNET_snprintf (pd_str, 557
563 64, 558 *order = json_dumps (contract_terms, 0);
564 "{\"t_ms\":%llu}", 559 json_decref (contract_terms);
565 pay_deadline_round.abs_value_us / 1000LL);
566 }
567 GNUNET_asprintf (order,
568 "{\"max_fee\":\"EUR:0.5\",\
569 \"order_id\":\"%s\",\
570 \"refund_deadline\":%s,\
571 \"pay_deadline\":%s,\
572 \"amount\":\"%s\",\
573 \"summary\":\"merchant-lib testcase\",\
574 \"fulfillment_url\":\"https://example.com/\"}",
575 order_id,
576 rd_str,
577 pd_str,
578 amount);
579} 560}
580 561
562
581/** 563/**
582 * Make the "proposal" command AVOIDING claiming the order. 564 * Make the "proposal" command AVOIDING claiming the order.
583 * 565 *