summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lib/Makefile.am1
-rw-r--r--src/lib/merchant_api_get_order.c371
-rw-r--r--src/lib/merchant_api_merchant_get_order.c304
3 files changed, 162 insertions, 514 deletions
diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am
index df339048..9c02f332 100644
--- a/src/lib/Makefile.am
+++ b/src/lib/Makefile.am
@@ -28,6 +28,7 @@ libtalermerchant_la_SOURCES = \
merchant_api_get_reserves.c \
merchant_api_get_transfers.c \
merchant_api_lock_product.c \
+ merchant_api_merchant_get_order.c \
merchant_api_patch_instance.c \
merchant_api_patch_product.c \
merchant_api_post_instances.c \
diff --git a/src/lib/merchant_api_get_order.c b/src/lib/merchant_api_get_order.c
deleted file mode 100644
index c056c784..00000000
--- a/src/lib/merchant_api_get_order.c
+++ /dev/null
@@ -1,371 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2014-2020 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 published by the Free Software
- Foundation; either version 2.1, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License along with
- TALER; see the file COPYING.LGPL. If not, see
- <http://www.gnu.org/licenses/>
-*/
-/**
- * @file lib/merchant_api_refund.c
- * @brief Implementation of the /refund POST and GET
- * @author Christian Grothoff
- * @author Marcello Stanisci
- */
-#include "platform.h"
-#include <curl/curl.h>
-#include <jansson.h>
-#include <microhttpd.h> /* just for HTTP status codes */
-#include <gnunet/gnunet_util_lib.h>
-#include <gnunet/gnunet_curl_lib.h>
-#include "taler_merchant_service.h"
-#include <taler/taler_json_lib.h>
-#include <taler/taler_signatures.h>
-#include <taler/taler_curl_lib.h>
-
-
-/**
- * Handle to the refund lookup operation.
- */
-struct TALER_MERCHANT_RefundLookupOperation
-{
- /**
- * URL of the request, includes parameters
- */
- char *url;
-
- /**
- * Handle of the request
- */
- struct GNUNET_CURL_Job *job;
-
- /**
- * Function to call with the response
- */
- TALER_MERCHANT_RefundLookupCallback cb;
-
- /**
- * Closure for cb
- */
- void *cb_cls;
-
- /**
- * Reference to the execution context
- */
- struct GNUNET_CURL_Context *ctx;
-
-};
-
-
-/**
- * Cancel a /refund lookup operation
- *
- * @param rlo operation to cancel
- */
-void
-TALER_MERCHANT_refund_lookup_cancel (
- struct TALER_MERCHANT_RefundLookupOperation *rlo)
-{
- if (NULL != rlo->job)
- {
- GNUNET_CURL_job_cancel (rlo->job);
- rlo->job = NULL;
- }
- GNUNET_free (rlo->url);
- GNUNET_free (rlo);
-}
-
-
-/**
- * Check that the @a reply to the @a rlo is valid
- *
- * @param rlo lookup operation
- * @param reply JSON reply to verify
- * @return #TALER_EC_NONE if @a reply is well-formed
- */
-static enum TALER_ErrorCode
-check_refund_result (struct TALER_MERCHANT_RefundLookupOperation *rlo,
- const json_t *reply)
-{
- json_t *refunds;
- unsigned int num_refunds;
- struct GNUNET_HashCode h_contract_terms;
- struct TALER_MerchantPublicKeyP merchant_pub;
- struct GNUNET_JSON_Specification spec[] = {
- GNUNET_JSON_spec_json ("refunds", &refunds),
- GNUNET_JSON_spec_fixed_auto ("h_contract_terms", &h_contract_terms),
- GNUNET_JSON_spec_fixed_auto ("merchant_pub", &merchant_pub),
- GNUNET_JSON_spec_end ()
- };
-
- if (GNUNET_OK !=
- GNUNET_JSON_parse (reply,
- spec,
- NULL, NULL))
- {
- GNUNET_break_op (0);
- return TALER_EC_REFUND_LOOKUP_INVALID_RESPONSE;
- }
- num_refunds = json_array_size (refunds);
- {
- struct TALER_MERCHANT_RefundDetail rds[GNUNET_NZL (num_refunds)];
- json_t *ercp[GNUNET_NZL (num_refunds)];
-
- memset (rds,
- 0,
- sizeof (rds));
- memset (ercp,
- 0,
- sizeof (ercp));
- for (unsigned int i = 0; i<num_refunds; i++)
- {
- struct TALER_MERCHANT_RefundDetail *rd = &rds[i];
- json_t *refund = json_array_get (refunds, i);
- uint32_t hs;
- struct GNUNET_JSON_Specification spec_detail[] = {
- GNUNET_JSON_spec_fixed_auto ("coin_pub",
- &rd->coin_pub),
- TALER_JSON_spec_amount ("refund_amount",
- &rd->refund_amount),
- TALER_JSON_spec_amount ("refund_fee",
- &rd->refund_fee),
- GNUNET_JSON_spec_uint32 ("exchange_http_status",
- &hs),
- GNUNET_JSON_spec_uint64 ("rtransaction_id",
- &rd->rtransaction_id),
- GNUNET_JSON_spec_end ()
- };
-
- if (GNUNET_OK !=
- GNUNET_JSON_parse (refund,
- spec_detail,
- NULL, NULL))
- {
- GNUNET_break_op (0);
- GNUNET_JSON_parse_free (spec);
- return TALER_EC_REFUND_LOOKUP_INVALID_RESPONSE;
- }
- rd->hr.http_status = (unsigned int) hs;
- }
-
- for (unsigned int i = 0; i<num_refunds; i++)
- {
- struct TALER_MERCHANT_RefundDetail *rd = &rds[i];
- json_t *refund = json_array_get (refunds, i);
-
- if (MHD_HTTP_OK == rd->hr.http_status)
- {
- struct GNUNET_JSON_Specification spec_detail[] = {
- GNUNET_JSON_spec_fixed_auto ("exchange_pub",
- &rd->exchange_pub),
- GNUNET_JSON_spec_fixed_auto ("exchange_sig",
- &rd->exchange_sig),
- GNUNET_JSON_spec_end ()
- };
-
- if (GNUNET_OK !=
- GNUNET_JSON_parse (refund,
- spec_detail,
- NULL, NULL))
- {
- GNUNET_break_op (0);
- for (unsigned int j = 0; j<i; j++)
- if (NULL != ercp[j])
- json_decref (ercp[j]);
- GNUNET_JSON_parse_free (spec);
- return TALER_EC_REFUND_LOOKUP_INVALID_RESPONSE;
- }
- /* verify exchange sig (we should not trust the merchant) */
- {
- struct TALER_RefundConfirmationPS depconf = {
- .purpose.size = htonl (sizeof (depconf)),
- .purpose.purpose = htonl (TALER_SIGNATURE_EXCHANGE_CONFIRM_REFUND),
- .h_contract_terms = h_contract_terms,
- .coin_pub = rd->coin_pub,
- .merchant = merchant_pub,
- .rtransaction_id = GNUNET_htonll (rd->rtransaction_id)
- };
-
- TALER_amount_hton (&depconf.refund_amount,
- &rd->refund_amount);
- TALER_amount_hton (&depconf.refund_fee,
- &rd->refund_fee);
- if (GNUNET_OK !=
- GNUNET_CRYPTO_eddsa_verify (
- TALER_SIGNATURE_EXCHANGE_CONFIRM_REFUND,
- &depconf,
- &rd->exchange_sig.eddsa_signature,
- &rd->exchange_pub.eddsa_pub))
- {
- /* While the *exchange* signature is invalid, we do blame the
- merchant here, because the merchant should have checked and
- sent us an error code (with exchange HTTP status code 0) instead
- of claiming that the exchange yielded a good response. *///
- GNUNET_break_op (0);
- GNUNET_JSON_parse_free (spec);
- return TALER_EC_REFUND_LOOKUP_INVALID_RESPONSE;
- }
- }
- }
- else
- {
- uint32_t ec;
- struct GNUNET_JSON_Specification spec_detail[] = {
- GNUNET_JSON_spec_uint32 ("exchange_code",
- &ec),
- GNUNET_JSON_spec_end ()
- };
-
- if (GNUNET_OK !=
- GNUNET_JSON_parse (refund,
- spec_detail,
- NULL, NULL))
- {
- GNUNET_break_op (0);
- rd->hr.ec = TALER_EC_INVALID;
- }
- ercp[i] = json_incref (json_object_get (refund,
- "exchange_reply"));
- rd->hr.reply = ercp[i];
- }
- }
- {
- struct TALER_MERCHANT_HttpResponse hr = {
- .http_status = MHD_HTTP_OK,
- .reply = reply
- };
- rlo->cb (rlo->cb_cls,
- &hr,
- &h_contract_terms,
- &merchant_pub,
- num_refunds,
- rds);
- }
- for (unsigned int j = 0; j<num_refunds; j++)
- if (NULL != ercp[j])
- json_decref (ercp[j]);
- }
- GNUNET_JSON_parse_free (spec);
- return TALER_EC_NONE;
-}
-
-
-/**
- * Process GET /refund response
- *
- * @param cls a `struct TALER_MERCHANT_RefundLookupOperation *`
- * @param response_code HTTP status, 0 for HTTP failure
- * @param response a `const json_t *` with the JSON of the HTTP body
- */
-static void
-handle_refund_lookup_finished (void *cls,
- long response_code,
- const void *response)
-{
- struct TALER_MERCHANT_RefundLookupOperation *rlo = cls;
- const json_t *json = response;
- struct TALER_MERCHANT_HttpResponse hr = {
- .http_status = (unsigned int) response_code,
- .reply = json
- };
-
- rlo->job = NULL;
- switch (response_code)
- {
- case 0:
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Backend didn't even return from GET /refund\n");
- hr.ec = TALER_EC_INVALID_RESPONSE;
- break;
- case MHD_HTTP_OK:
- if (TALER_EC_NONE ==
- (hr.ec = check_refund_result (rlo,
- json)))
- {
- TALER_MERCHANT_refund_lookup_cancel (rlo);
- return;
- }
- /* failure, report! */
- hr.http_status = 0;
- break;
- case MHD_HTTP_NOT_FOUND:
- hr.ec = TALER_JSON_get_error_code (json);
- hr.hint = TALER_JSON_get_error_hint (json);
- break;
- default:
- GNUNET_break_op (0); /* unexpected status code */
- hr.ec = TALER_JSON_get_error_code (json);
- hr.hint = TALER_JSON_get_error_hint (json);
- break;
- }
- rlo->cb (rlo->cb_cls,
- &hr,
- NULL,
- NULL,
- 0,
- NULL);
- TALER_MERCHANT_refund_lookup_cancel (rlo);
-}
-
-
-/**
- * Does a GET /refund.
- *
- * @param ctx execution context
- * @param backend_url base URL of the merchant backend
- * @param order_id order id used to perform the lookup
- * @param cb callback which will work the response gotten from the backend
- * @param cb_cls closure to pass to the callback
- * @return handle for this operation, NULL upon errors
- */
-struct TALER_MERCHANT_RefundLookupOperation *
-TALER_MERCHANT_refund_lookup (struct GNUNET_CURL_Context *ctx,
- const char *backend_url,
- const char *order_id,
- TALER_MERCHANT_RefundLookupCallback cb,
- void *cb_cls)
-{
- struct TALER_MERCHANT_RefundLookupOperation *rlo;
- CURL *eh;
-
- rlo = GNUNET_new (struct TALER_MERCHANT_RefundLookupOperation);
- rlo->ctx = ctx;
- rlo->cb = cb;
- rlo->cb_cls = cb_cls;
- rlo->url = TALER_url_join (backend_url,
- "refund",
- "order_id",
- order_id,
- NULL);
- eh = curl_easy_init ();
- if (CURLE_OK != curl_easy_setopt (eh,
- CURLOPT_URL,
- rlo->url))
- {
- GNUNET_break (0);
- GNUNET_free (rlo->url);
- GNUNET_free (rlo);
- return NULL;
- }
- rlo->job = GNUNET_CURL_job_add (ctx,
- eh,
- GNUNET_NO,
- handle_refund_lookup_finished,
- rlo);
- if (NULL == rlo->job)
- {
- GNUNET_free (rlo->url);
- GNUNET_free (rlo);
- GNUNET_break (0);
- return NULL;
- }
- return rlo;
-}
diff --git a/src/lib/merchant_api_merchant_get_order.c b/src/lib/merchant_api_merchant_get_order.c
index 6b0190af..279376d3 100644
--- a/src/lib/merchant_api_merchant_get_order.c
+++ b/src/lib/merchant_api_merchant_get_order.c
@@ -15,8 +15,8 @@
<http://www.gnu.org/licenses/>
*/
/**
- * @file lib/merchant_api_poll_payment.c
- * @brief Implementation of the /poll-payment GET request
+ * @file lib/merchant_api_merchant_get_order.c
+ * @brief Implementation of the GET /private/orders/$ORDER request
* @author Christian Grothoff
* @author Marcello Stanisci
* @author Florian Dold
@@ -33,9 +33,9 @@
/**
- * @brief A poll payment operation handle
+ * @brief A GET /private/orders/$ORDER handle
*/
-struct TALER_MERCHANT_PollPaymentOperation
+struct TALER_MERCHANT_OrderMerchantGetHandle
{
/**
@@ -51,7 +51,7 @@ struct TALER_MERCHANT_PollPaymentOperation
/**
* Function to call with the result.
*/
- TALER_MERCHANT_PollPaymentCallback cb;
+ TALER_MERCHANT_OrderMerchantGetCallback cb;
/**
* Closure for @a cb.
@@ -66,18 +66,20 @@ struct TALER_MERCHANT_PollPaymentOperation
/**
- * Function called when we're done processing the GET /poll-payment request.
+ * Function called when we're done processing the GET /private/orders/$ORDER
+ * request.
*
- * @param cls the `struct TALER_MERCHANT_PollPaymentOperation`
+ * @param cls the `struct TALER_MERCHANT_OrderMerchantGetHandle`
* @param response_code HTTP response code, 0 on error
* @param json response body, should be NULL
*/
static void
-handle_poll_payment_finished (void *cls,
- long response_code,
- const void *response)
+handle_merchant_order_get_finished (void *cls,
+ long response_code,
+ const void *response)
{
- struct TALER_MERCHANT_PollPaymentOperation *cpo = cls;
+ struct TALER_MERCHANT_OrderMerchantGetHandle *omgh = cls;
+#if FIXME
struct TALER_Amount refund_amount = { 0 };
const json_t *json = response;
const json_t *refunded;
@@ -91,20 +93,20 @@ handle_poll_payment_finished (void *cls,
GNUNET_JSON_spec_end ()
};
- cpo->job = NULL;
+ omgh->job = NULL;
switch (response_code)
{
case MHD_HTTP_NOT_FOUND:
hr.ec = TALER_JSON_get_error_code (json);
hr.hint = TALER_JSON_get_error_hint (json);
- cpo->cb (cpo->cb_cls,
- &hr,
- GNUNET_NO,
- GNUNET_NO,
- NULL,
- NULL);
- TALER_MERCHANT_poll_payment_cancel (cpo);
+ omgh->cb (omgh->cb_cls,
+ &hr,
+ GNUNET_NO,
+ GNUNET_NO,
+ NULL,
+ NULL);
+ TALER_MERCHANT_merchant_order_get_cancel (omgh);
return;
case MHD_HTTP_OK:
/* see below */
@@ -117,13 +119,13 @@ handle_poll_payment_finished (void *cls,
(unsigned int) response_code,
(int) hr.ec);
GNUNET_break_op (0);
- cpo->cb (cpo->cb_cls,
- &hr,
- GNUNET_SYSERR,
- GNUNET_SYSERR,
- NULL,
- NULL);
- TALER_MERCHANT_poll_payment_cancel (cpo);
+ omgh->cb (omgh->cb_cls,
+ &hr,
+ GNUNET_SYSERR,
+ GNUNET_SYSERR,
+ NULL,
+ NULL);
+ TALER_MERCHANT_merchant_order_get_cancel (omgh);
return;
}
@@ -138,24 +140,24 @@ handle_poll_payment_finished (void *cls,
"no taler_pay_uri in unpaid poll-payment response\n");
GNUNET_break_op (0);
hr.http_status = 0;
- hr.ec = TALER_EC_POLL_PAYMENT_REPLY_MALFORMED;
- cpo->cb (cpo->cb_cls,
- &hr,
- GNUNET_SYSERR,
- GNUNET_SYSERR,
- NULL,
- NULL);
+ hr.ec = TALER_EC_MERCHANT_ORDER_GET_REPLY_MALFORMED;
+ omgh->cb (omgh->cb_cls,
+ &hr,
+ GNUNET_SYSERR,
+ GNUNET_SYSERR,
+ NULL,
+ NULL);
}
else
{
- cpo->cb (cpo->cb_cls,
- &hr,
- GNUNET_NO,
- GNUNET_NO,
- NULL,
- taler_pay_uri);
+ omgh->cb (omgh->cb_cls,
+ &hr,
+ GNUNET_NO,
+ GNUNET_NO,
+ NULL,
+ taler_pay_uri);
}
- TALER_MERCHANT_poll_payment_cancel (cpo);
+ TALER_MERCHANT_merchant_order_get_cancel (omgh);
return;
}
@@ -171,155 +173,171 @@ handle_poll_payment_finished (void *cls,
"poll payment failed to parse JSON\n");
GNUNET_break_op (0);
hr.http_status = 0;
- hr.ec = TALER_EC_POLL_PAYMENT_REPLY_MALFORMED;
- cpo->cb (cpo->cb_cls,
- &hr,
- GNUNET_SYSERR,
- GNUNET_SYSERR,
- NULL,
- NULL);
- TALER_MERCHANT_poll_payment_cancel (cpo);
+ hr.ec = TALER_EC_MERCHANT_ORDER_GET_REPLY_MALFORMED;
+ omgh->cb (omgh->cb_cls,
+ &hr,
+ GNUNET_SYSERR,
+ GNUNET_SYSERR,
+ NULL,
+ NULL);
+ TALER_MERCHANT_merchant_order_get_cancel (omgh);
return;
}
- cpo->cb (cpo->cb_cls,
- &hr,
- GNUNET_YES,
- (json_true () == refunded),
- (json_true () == refunded) ? &refund_amount : NULL,
- NULL);
- TALER_MERCHANT_poll_payment_cancel (cpo);
+ omgh->cb (omgh->cb_cls,
+ &hr,
+ GNUNET_YES,
+ (json_true () == refunded),
+ (json_true () == refunded) ? &refund_amount : NULL,
+ NULL);
+#endif
+ TALER_MERCHANT_merchant_order_get_cancel (omgh);
}
/**
- * Issue a /poll-payment request to the backend. Polls the status
- * of a payment.
+ * Checks the status of a payment. Issue a GET /private/orders/$ID request to
+ * the backend.
*
* @param ctx execution context
* @param backend_url base URL of the merchant backend
* @param order_id order id to identify the payment
- * @param h_contract hash of the contract for @a order_id
- * @param session_id sesion id for the payment (or NULL if the payment is not bound to a session)
+ * @param session_id sesion id for the payment (or NULL if the check is not
+ * bound to a session)
+ * @param transfer if true, obtain the wire transfer status from the exhcange.
+ * Otherwise, the wire transfer status MAY be returned if it is available.
* @param timeout timeout to use in long polling (how long may the server wait to reply
* before generating an unpaid response). Note that this is just provided to
* the server, we as client will block until the response comes back or until
- * #TALER_MERCHANT_poll_payment_cancel() is called.
- * @param min_refund long poll for the service to approve a refund exceeding this value;
- * use NULL to not wait for any refund (only for payment). Only makes sense
- * with a non-zero @a timeout.
- * @param poll_payment_cb callback which will work the response gotten from the backend
- * @param poll_payment_cb_cls closure to pass to @a poll_payment_cb
+ * #TALER_MERCHANT_order_get_cancel() is called.
+ * @param cb callback which will work the response gotten from the backend
+ * @param cb_cls closure to pass to @a cb
* @return handle for this operation, NULL upon errors
*/
-struct TALER_MERCHANT_PollPaymentOperation *
-TALER_MERCHANT_poll_payment (
- struct GNUNET_CURL_Context *ctx,
- const char *backend_url,
- const char *order_id,
- const struct GNUNET_HashCode *h_contract,
- const char *session_id,
- struct GNUNET_TIME_Relative timeout,
- const struct TALER_Amount *min_refund,
- TALER_MERCHANT_PollPaymentCallback poll_payment_cb,
- void *poll_payment_cb_cls)
+struct TALER_MERCHANT_OrderMerchantGetHandle *
+TALER_MERCHANT_merchant_order_get (struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ const char *order_id,
+ const char *session_id,
+ bool transfer,
+ struct GNUNET_TIME_Relative timeout,
+ TALER_MERCHANT_OrderMerchantGetCallback cb,
+ void *cb_cls)
{
- struct TALER_MERCHANT_PollPaymentOperation *cpo;
- CURL *eh;
- char *h_contract_s;
- char *timeout_s;
- unsigned int ts;
+ struct TALER_MERCHANT_OrderMerchantGetHandle *omgh;
+ unsigned long long tms;
long tlong;
GNUNET_assert (NULL != backend_url);
GNUNET_assert (NULL != order_id);
- h_contract_s = GNUNET_STRINGS_data_to_string_alloc (h_contract,
- sizeof (*h_contract));
- ts = (unsigned int) (timeout.rel_value_us
- / GNUNET_TIME_UNIT_SECONDS.rel_value_us);
+ tms = (unsigned long long) (timeout.rel_value_us
+ / GNUNET_TIME_UNIT_MILLISECONDS.rel_value_us);
/* set curl timeout to *our* long poll timeout plus one minute
(for network latency and processing delays) */
tlong = (long) (GNUNET_TIME_relative_add (timeout,
GNUNET_TIME_UNIT_MINUTES).
rel_value_us
/ GNUNET_TIME_UNIT_MILLISECONDS.rel_value_us);
- GNUNET_asprintf (&timeout_s,
- "%u",
- ts);
- cpo = GNUNET_new (struct TALER_MERCHANT_PollPaymentOperation);
- cpo->ctx = ctx;
- cpo->cb = poll_payment_cb;
- cpo->cb_cls = poll_payment_cb_cls;
- cpo->url = TALER_url_join (backend_url,
- "public/poll-payment",
- "order_id", order_id,
- "session_id", session_id,
- "h_contract", h_contract_s,
- (0 != ts) ? "timeout" : NULL,
- timeout_s,
- (NULL != min_refund) ? "refund" : NULL,
- (NULL != min_refund) ? TALER_amount2s (
- min_refund) : NULL,
- NULL);
- GNUNET_free (h_contract_s);
- GNUNET_free (timeout_s);
- if (NULL == cpo->url)
+ omgh = GNUNET_new (struct TALER_MERCHANT_OrderMerchantGetHandle);
+ omgh->ctx = ctx;
+ omgh->cb = cb;
+ omgh->cb_cls = cb_cls;
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Could not construct request URL.\n");
- GNUNET_free (cpo);
- return NULL;
+ char *path;
+ char timeout_ms[32];
+
+ GNUNET_snprintf (timeout_ms,
+ sizeof (timeout_ms),
+ "%llu",
+ tms);
+ GNUNET_asprintf (&path,
+ "orders/%s",
+ order_id);
+ omgh->url = TALER_url_join (backend_url,
+ path,
+ "session_id", session_id,
+ "transfer", transfer ? "YES" : "NO",
+ (0 != tms) ? "timeout_ms" : NULL,
+ timeout_ms,
+ NULL);
}
- eh = curl_easy_init ();
- if (CURLE_OK != curl_easy_setopt (eh,
- CURLOPT_URL,
- cpo->url))
+ if (NULL == omgh->url)
{
- GNUNET_break (0);
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Could not construct request URL.\n");
+ GNUNET_free (omgh);
return NULL;
}
- if (CURLE_OK != curl_easy_setopt (eh,
- CURLOPT_TIMEOUT_MS,
- tlong))
+
{
- GNUNET_break (0);
- return NULL;
- }
+ CURL *eh;
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "polling payment from %s\n",
- cpo->url);
+ eh = curl_easy_init ();
+ if (NULL == eh)
+ {
+ GNUNET_break (0);
+ GNUNET_free (omgh->url);
+ GNUNET_free (omgh);
+ return NULL;
+ }
+ if (CURLE_OK != curl_easy_setopt (eh,
+ CURLOPT_URL,
+ omgh->url))
+ {
+ GNUNET_break (0);
+ curl_easy_cleanup (eh);
+ GNUNET_free (omgh->url);
+ GNUNET_free (omgh);
+ return NULL;
+ }
+ if (CURLE_OK != curl_easy_setopt (eh,
+ CURLOPT_TIMEOUT_MS,
+ tlong))
+ {
+ GNUNET_break (0);
+ curl_easy_cleanup (eh);
+ GNUNET_free (omgh->url);
+ GNUNET_free (omgh);
+ return NULL;
+ }
- if (NULL == (cpo->job = GNUNET_CURL_job_add (ctx,
- eh,
- GNUNET_YES,
- &handle_poll_payment_finished,
- cpo)))
- {
- GNUNET_break (0);
- return NULL;
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Getting order status from %s\n",
+ omgh->url);
+ if (NULL == (omgh->job =
+ GNUNET_CURL_job_add (ctx,
+ eh,
+ GNUNET_YES,
+ &handle_merchant_order_get_finished,
+ omgh)))
+ {
+ GNUNET_break (0);
+ GNUNET_free (omgh->url);
+ GNUNET_free (omgh);
+ return NULL;
+ }
}
- return cpo;
+ return omgh;
}
/**
- * Cancel a GET /poll-payment request.
+ * Cancel a GET /private/orders/$ORDER request.
*
- * @param cph handle to the request to be canceled
+ * @param omgh handle to the request to be canceled
*/
void
-TALER_MERCHANT_poll_payment_cancel (
- struct TALER_MERCHANT_PollPaymentOperation *cph)
+TALER_MERCHANT_merchant_order_get_cancel (
+ struct TALER_MERCHANT_OrderMerchantGetHandle *omgh)
{
- if (NULL != cph->job)
+ if (NULL != omgh->job)
{
- GNUNET_CURL_job_cancel (cph->job);
- cph->job = NULL;
+ GNUNET_CURL_job_cancel (omgh->job);
+ omgh->job = NULL;
}
- GNUNET_free (cph->url);
- GNUNET_free (cph);
+ GNUNET_free (omgh->url);
+ GNUNET_free (omgh);
}
-/* end of merchant_api_poll_payment.c */
+/* end of merchant_api_merchant_get_order.c */