diff options
Diffstat (limited to 'src/lib/exchange_api_refund.c')
-rw-r--r-- | src/lib/exchange_api_refund.c | 67 |
1 files changed, 12 insertions, 55 deletions
diff --git a/src/lib/exchange_api_refund.c b/src/lib/exchange_api_refund.c index 2ac612db5..f83a2985a 100644 --- a/src/lib/exchange_api_refund.c +++ b/src/lib/exchange_api_refund.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of TALER | 2 | This file is part of TALER |
3 | Copyright (C) 2014-2020 Taler Systems SA | 3 | Copyright (C) 2014-2021 Taler Systems SA |
4 | 4 | ||
5 | TALER is free software; you can redistribute it and/or modify it under the | 5 | TALER is free software; you can redistribute it and/or modify it under the |
6 | terms of the GNU General Public License as published by the Free Software | 6 | terms of the GNU General Public License as published by the Free Software |
@@ -635,35 +635,6 @@ handle_refund_finished (void *cls, | |||
635 | } | 635 | } |
636 | 636 | ||
637 | 637 | ||
638 | /** | ||
639 | * Submit a refund request to the exchange and get the exchange's | ||
640 | * response. This API is used by a merchant. Note that | ||
641 | * while we return the response verbatim to the caller for further | ||
642 | * processing, we do already verify that the response is well-formed | ||
643 | * (i.e. that signatures included in the response are all valid). If | ||
644 | * the exchange's reply is not well-formed, we return an HTTP status code | ||
645 | * of zero to @a cb. | ||
646 | * | ||
647 | * The @a exchange must be ready to operate (i.e. have | ||
648 | * finished processing the /keys reply). If this check fails, we do | ||
649 | * NOT initiate the transaction with the exchange and instead return NULL. | ||
650 | * | ||
651 | * @param exchange the exchange handle; the exchange must be ready to operate | ||
652 | * @param amount the amount to be refunded; must be larger than the refund fee | ||
653 | * (as that fee is still being subtracted), and smaller than the amount | ||
654 | * (with deposit fee) of the original deposit contribution of this coin | ||
655 | * @param h_contract_terms hash of the contact of the merchant with the customer that is being refunded | ||
656 | * @param coin_pub coin’s public key of the coin from the original deposit operation | ||
657 | * @param rtransaction_id transaction id for the transaction between merchant and customer (of refunding operation); | ||
658 | * this is needed as we may first do a partial refund and later a full refund. If both | ||
659 | * refunds are also over the same amount, we need the @a rtransaction_id to make the disjoint | ||
660 | * refund requests different (as requests are idempotent and otherwise the 2nd refund might not work). | ||
661 | * @param merchant_priv the private key of the merchant, used to generate signature for refund request | ||
662 | * @param cb the callback to call when a reply for this request is available | ||
663 | * @param cb_cls closure for the above callback | ||
664 | * @return a handle for this request; NULL if the inputs are invalid (i.e. | ||
665 | * signatures fail to verify). In this case, the callback is not called. | ||
666 | */ | ||
667 | struct TALER_EXCHANGE_RefundHandle * | 638 | struct TALER_EXCHANGE_RefundHandle * |
668 | TALER_EXCHANGE_refund (struct TALER_EXCHANGE_Handle *exchange, | 639 | TALER_EXCHANGE_refund (struct TALER_EXCHANGE_Handle *exchange, |
669 | const struct TALER_Amount *amount, | 640 | const struct TALER_Amount *amount, |
@@ -714,25 +685,17 @@ TALER_EXCHANGE_refund (struct TALER_EXCHANGE_Handle *exchange, | |||
714 | "/coins/%s/refund", | 685 | "/coins/%s/refund", |
715 | pub_str); | 686 | pub_str); |
716 | } | 687 | } |
717 | refund_obj = json_pack ("{s:o," /* amount */ | 688 | refund_obj = GNUNET_JSON_PACK ( |
718 | " s:o," /* h_contract_terms */ | 689 | TALER_JSON_pack_amount ("refund_amount", |
719 | " s:I," /* rtransaction id */ | 690 | amount), |
720 | " s:o, s:o}", /* merchant_pub, merchant_sig */ | 691 | GNUNET_JSON_pack_data_auto ("h_contract_terms", |
721 | "refund_amount", TALER_JSON_from_amount (amount), | 692 | h_contract_terms), |
722 | "h_contract_terms", GNUNET_JSON_from_data_auto ( | 693 | GNUNET_JSON_pack_uint64 ("rtransaction_id", |
723 | h_contract_terms), | 694 | rtransaction_id), |
724 | "rtransaction_id", (json_int_t) rtransaction_id, | 695 | GNUNET_JSON_pack_data_auto ("merchant_pub", |
725 | "merchant_pub", GNUNET_JSON_from_data_auto ( | 696 | &rr.merchant), |
726 | &rr.merchant), | 697 | GNUNET_JSON_pack_data_auto ("merchant_sig", |
727 | "merchant_sig", GNUNET_JSON_from_data_auto ( | 698 | &merchant_sig)); |
728 | &merchant_sig) | ||
729 | ); | ||
730 | if (NULL == refund_obj) | ||
731 | { | ||
732 | GNUNET_break (0); | ||
733 | return NULL; | ||
734 | } | ||
735 | |||
736 | rh = GNUNET_new (struct TALER_EXCHANGE_RefundHandle); | 699 | rh = GNUNET_new (struct TALER_EXCHANGE_RefundHandle); |
737 | rh->exchange = exchange; | 700 | rh->exchange = exchange; |
738 | rh->cb = cb; | 701 | rh->cb = cb; |
@@ -783,12 +746,6 @@ TALER_EXCHANGE_refund (struct TALER_EXCHANGE_Handle *exchange, | |||
783 | } | 746 | } |
784 | 747 | ||
785 | 748 | ||
786 | /** | ||
787 | * Cancel a refund permission request. This function cannot be used | ||
788 | * on a request handle if a response is already served for it. | ||
789 | * | ||
790 | * @param refund the refund permission request handle | ||
791 | */ | ||
792 | void | 749 | void |
793 | TALER_EXCHANGE_refund_cancel (struct TALER_EXCHANGE_RefundHandle *refund) | 750 | TALER_EXCHANGE_refund_cancel (struct TALER_EXCHANGE_RefundHandle *refund) |
794 | { | 751 | { |