diff options
Diffstat (limited to 'src/lib/exchange_api_refund.c')
-rw-r--r-- | src/lib/exchange_api_refund.c | 99 |
1 files changed, 51 insertions, 48 deletions
diff --git a/src/lib/exchange_api_refund.c b/src/lib/exchange_api_refund.c index 5ce0152d2..e8ae6b74a 100644 --- a/src/lib/exchange_api_refund.c +++ b/src/lib/exchange_api_refund.c | |||
@@ -96,7 +96,7 @@ verify_refund_signature_ok (const struct TALER_EXCHANGE_RefundHandle *rh, | |||
96 | struct GNUNET_JSON_Specification spec[] = { | 96 | struct GNUNET_JSON_Specification spec[] = { |
97 | GNUNET_JSON_spec_fixed_auto ("sig", &exchange_sig), | 97 | GNUNET_JSON_spec_fixed_auto ("sig", &exchange_sig), |
98 | GNUNET_JSON_spec_fixed_auto ("pub", exchange_pub), | 98 | GNUNET_JSON_spec_fixed_auto ("pub", exchange_pub), |
99 | GNUNET_JSON_spec_end() | 99 | GNUNET_JSON_spec_end () |
100 | }; | 100 | }; |
101 | 101 | ||
102 | if (GNUNET_OK != | 102 | if (GNUNET_OK != |
@@ -154,7 +154,7 @@ handle_refund_finished (void *cls, | |||
154 | case MHD_HTTP_OK: | 154 | case MHD_HTTP_OK: |
155 | if (GNUNET_OK != | 155 | if (GNUNET_OK != |
156 | verify_refund_signature_ok (rh, | 156 | verify_refund_signature_ok (rh, |
157 | j, | 157 | j, |
158 | &exchange_pub)) | 158 | &exchange_pub)) |
159 | { | 159 | { |
160 | GNUNET_break_op (0); | 160 | GNUNET_break_op (0); |
@@ -205,7 +205,7 @@ handle_refund_finished (void *cls, | |||
205 | } | 205 | } |
206 | rh->cb (rh->cb_cls, | 206 | rh->cb (rh->cb_cls, |
207 | response_code, | 207 | response_code, |
208 | TALER_JSON_get_error_code (j), | 208 | TALER_JSON_get_error_code (j), |
209 | ep, | 209 | ep, |
210 | j); | 210 | j); |
211 | TALER_EXCHANGE_refund_cancel (rh); | 211 | TALER_EXCHANGE_refund_cancel (rh); |
@@ -244,20 +244,20 @@ handle_refund_finished (void *cls, | |||
244 | */ | 244 | */ |
245 | struct TALER_EXCHANGE_RefundHandle * | 245 | struct TALER_EXCHANGE_RefundHandle * |
246 | TALER_EXCHANGE_refund (struct TALER_EXCHANGE_Handle *exchange, | 246 | TALER_EXCHANGE_refund (struct TALER_EXCHANGE_Handle *exchange, |
247 | const struct TALER_Amount *amount, | 247 | const struct TALER_Amount *amount, |
248 | const struct TALER_Amount *refund_fee, | 248 | const struct TALER_Amount *refund_fee, |
249 | const struct GNUNET_HashCode *h_contract_terms, | 249 | const struct GNUNET_HashCode *h_contract_terms, |
250 | const struct TALER_CoinSpendPublicKeyP *coin_pub, | 250 | const struct TALER_CoinSpendPublicKeyP *coin_pub, |
251 | uint64_t rtransaction_id, | 251 | uint64_t rtransaction_id, |
252 | const struct TALER_MerchantPrivateKeyP *merchant_priv, | 252 | const struct TALER_MerchantPrivateKeyP *merchant_priv, |
253 | TALER_EXCHANGE_RefundResultCallback cb, | 253 | TALER_EXCHANGE_RefundResultCallback cb, |
254 | void *cb_cls) | 254 | void *cb_cls) |
255 | { | 255 | { |
256 | struct TALER_RefundRequestPS rr; | 256 | struct TALER_RefundRequestPS rr; |
257 | struct TALER_MerchantSignatureP merchant_sig; | 257 | struct TALER_MerchantSignatureP merchant_sig; |
258 | 258 | ||
259 | GNUNET_assert (GNUNET_YES == | 259 | GNUNET_assert (GNUNET_YES == |
260 | TEAH_handle_is_ready (exchange)); | 260 | TEAH_handle_is_ready (exchange)); |
261 | rr.purpose.purpose = htonl (TALER_SIGNATURE_MERCHANT_REFUND); | 261 | rr.purpose.purpose = htonl (TALER_SIGNATURE_MERCHANT_REFUND); |
262 | rr.purpose.size = htonl (sizeof (struct TALER_RefundRequestPS)); | 262 | rr.purpose.size = htonl (sizeof (struct TALER_RefundRequestPS)); |
263 | rr.h_contract_terms = *h_contract_terms; | 263 | rr.h_contract_terms = *h_contract_terms; |
@@ -274,15 +274,15 @@ TALER_EXCHANGE_refund (struct TALER_EXCHANGE_Handle *exchange, | |||
274 | &rr.purpose, | 274 | &rr.purpose, |
275 | &merchant_sig.eddsa_sig)); | 275 | &merchant_sig.eddsa_sig)); |
276 | return TALER_EXCHANGE_refund2 (exchange, | 276 | return TALER_EXCHANGE_refund2 (exchange, |
277 | amount, | 277 | amount, |
278 | refund_fee, | 278 | refund_fee, |
279 | h_contract_terms, | 279 | h_contract_terms, |
280 | coin_pub, | 280 | coin_pub, |
281 | rtransaction_id, | 281 | rtransaction_id, |
282 | &rr.merchant, | 282 | &rr.merchant, |
283 | &merchant_sig, | 283 | &merchant_sig, |
284 | cb, | 284 | cb, |
285 | cb_cls); | 285 | cb_cls); |
286 | } | 286 | } |
287 | 287 | ||
288 | 288 | ||
@@ -319,33 +319,36 @@ TALER_EXCHANGE_refund (struct TALER_EXCHANGE_Handle *exchange, | |||
319 | */ | 319 | */ |
320 | struct TALER_EXCHANGE_RefundHandle * | 320 | struct TALER_EXCHANGE_RefundHandle * |
321 | TALER_EXCHANGE_refund2 (struct TALER_EXCHANGE_Handle *exchange, | 321 | TALER_EXCHANGE_refund2 (struct TALER_EXCHANGE_Handle *exchange, |
322 | const struct TALER_Amount *amount, | 322 | const struct TALER_Amount *amount, |
323 | const struct TALER_Amount *refund_fee, | 323 | const struct TALER_Amount *refund_fee, |
324 | const struct GNUNET_HashCode *h_contract_terms, | 324 | const struct GNUNET_HashCode *h_contract_terms, |
325 | const struct TALER_CoinSpendPublicKeyP *coin_pub, | 325 | const struct TALER_CoinSpendPublicKeyP *coin_pub, |
326 | uint64_t rtransaction_id, | 326 | uint64_t rtransaction_id, |
327 | const struct TALER_MerchantPublicKeyP *merchant_pub, | 327 | const struct TALER_MerchantPublicKeyP *merchant_pub, |
328 | const struct TALER_MerchantSignatureP *merchant_sig, | 328 | const struct TALER_MerchantSignatureP *merchant_sig, |
329 | TALER_EXCHANGE_RefundResultCallback cb, | 329 | TALER_EXCHANGE_RefundResultCallback cb, |
330 | void *cb_cls) | 330 | void *cb_cls) |
331 | { | 331 | { |
332 | struct TALER_EXCHANGE_RefundHandle *rh; | 332 | struct TALER_EXCHANGE_RefundHandle *rh; |
333 | struct GNUNET_CURL_Context *ctx; | 333 | struct GNUNET_CURL_Context *ctx; |
334 | json_t *refund_obj; | 334 | json_t *refund_obj; |
335 | CURL *eh; | 335 | CURL *eh; |
336 | 336 | ||
337 | refund_obj = json_pack ("{s:o, s:o," /* amount/fee */ | 337 | refund_obj = json_pack ("{s:o, s:o," /* amount/fee */ |
338 | " s:o, s:o," /* h_contract_terms, coin_pub */ | 338 | " s:o, s:o," /* h_contract_terms, coin_pub */ |
339 | " s:I," /* rtransaction id */ | 339 | " s:I," /* rtransaction id */ |
340 | " s:o, s:o}", /* merchant_pub, merchant_sig */ | 340 | " s:o, s:o}", /* merchant_pub, merchant_sig */ |
341 | "refund_amount", TALER_JSON_from_amount (amount), | 341 | "refund_amount", TALER_JSON_from_amount (amount), |
342 | "refund_fee", TALER_JSON_from_amount (refund_fee), | 342 | "refund_fee", TALER_JSON_from_amount (refund_fee), |
343 | "h_contract_terms", GNUNET_JSON_from_data_auto (h_contract_terms), | 343 | "h_contract_terms", GNUNET_JSON_from_data_auto ( |
344 | "coin_pub", GNUNET_JSON_from_data_auto (coin_pub), | 344 | h_contract_terms), |
345 | "rtransaction_id", (json_int_t) rtransaction_id, | 345 | "coin_pub", GNUNET_JSON_from_data_auto (coin_pub), |
346 | "merchant_pub", GNUNET_JSON_from_data_auto (merchant_pub), | 346 | "rtransaction_id", (json_int_t) rtransaction_id, |
347 | "merchant_sig", GNUNET_JSON_from_data_auto (merchant_sig) | 347 | "merchant_pub", GNUNET_JSON_from_data_auto ( |
348 | ); | 348 | merchant_pub), |
349 | "merchant_sig", GNUNET_JSON_from_data_auto ( | ||
350 | merchant_sig) | ||
351 | ); | ||
349 | if (NULL == refund_obj) | 352 | if (NULL == refund_obj) |
350 | { | 353 | { |
351 | GNUNET_break (0); | 354 | GNUNET_break (0); |
@@ -371,8 +374,8 @@ refund_obj = json_pack ("{s:o, s:o," /* amount/fee */ | |||
371 | eh = TEL_curl_easy_get (rh->url); | 374 | eh = TEL_curl_easy_get (rh->url); |
372 | if (GNUNET_OK != | 375 | if (GNUNET_OK != |
373 | TALER_curl_easy_post (&rh->ctx, | 376 | TALER_curl_easy_post (&rh->ctx, |
374 | eh, | 377 | eh, |
375 | refund_obj)) | 378 | refund_obj)) |
376 | { | 379 | { |
377 | GNUNET_break (0); | 380 | GNUNET_break (0); |
378 | curl_easy_cleanup (eh); | 381 | curl_easy_cleanup (eh); |
@@ -387,10 +390,10 @@ refund_obj = json_pack ("{s:o, s:o," /* amount/fee */ | |||
387 | rh->url); | 390 | rh->url); |
388 | ctx = TEAH_handle_to_context (exchange); | 391 | ctx = TEAH_handle_to_context (exchange); |
389 | rh->job = GNUNET_CURL_job_add2 (ctx, | 392 | rh->job = GNUNET_CURL_job_add2 (ctx, |
390 | eh, | 393 | eh, |
391 | rh->ctx.headers, | 394 | rh->ctx.headers, |
392 | &handle_refund_finished, | 395 | &handle_refund_finished, |
393 | rh); | 396 | rh); |
394 | return rh; | 397 | return rh; |
395 | } | 398 | } |
396 | 399 | ||