summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
Diffstat (limited to 'src/include')
-rw-r--r--src/include/taler_error_codes.h84
-rw-r--r--src/include/taler_exchange_service.h44
-rw-r--r--src/include/taler_exchangedb_plugin.h44
-rw-r--r--src/include/taler_signatures.h31
4 files changed, 170 insertions, 33 deletions
diff --git a/src/include/taler_error_codes.h b/src/include/taler_error_codes.h
index 2d0c8325a..d90bd4f30 100644
--- a/src/include/taler_error_codes.h
+++ b/src/include/taler_error_codes.h
@@ -1001,6 +1001,7 @@ enum TALER_ErrorCode
TALER_EC_PAY_REFUND_DEADLINE_PAST_WIRE_TRANSFER_DEADLINE = 2114,
/**
+
* The request fails to provide coins for the payment.
* This response is provided with HTTP status code
* MHD_HTTP_BAD_REQUEST.
@@ -1503,67 +1504,84 @@ enum TALER_ErrorCode
/* *************** Taler BANK/FAKEBANK error codes *************** */
/**
- * Authentication failed for an unspecified request.
- * To return when the view name is not available, or
- * no specific error code is defined yet.
+ * The request cannot be served because the client failed to
+ * login. To be returned along HTTP 401 Unauthorized.
+ */
+ TALER_EC_BANK_REJECT_LOGIN_FAILED = 5312,
+
+ /**
+ * The transaction cannot be rejected becasue it does not exist
+ * at the bank. To be returned along HTTP 404 Not Found.
+ */
+ TALER_EC_BANK_REJECT_TRANSACTION_NOT_FOUND = 5301,
+
+ /**
+ * The client does not own the account credited by the transaction
+ * which is to be rejected, so it has no rights do reject it. To be
+ * returned along HTTP 403 Forbidden.
+ */
+ TALER_EC_BANK_REJECT_NO_RIGHTS = 5313,
+
+ /**
+ * The POSTed JSON at /reject was invalid. To be returned along
+ * HTTP 400 Bad Request.
*/
- TALER_EC_BANK_NOT_AUTHORIZED = 5000,
+ TALER_EC_BANK_REJECT_JSON_INVALID = 5306,
/**
- * The bank could not find the bank account specified
- * in the request. Returned with a status code of MHD_HTTP_NOT_FOUND.
+ * A URL parameter for /history was missing. To be returned along
+ * HTTP 400 Bad Request.
*/
- TALER_EC_BANK_UNKNOWN_ACCOUNT = 5001,
+ TALER_EC_BANK_HISTORY_PARAMETER_MISSING = 5208,
/**
- * Authentication failed for the /admin/add/incoming request.
- * Returned with a status code of MHD_HTTP_FORBIDDEN.
+ * A URL parameter for /history was malformed. To be returned along
+ * HTTP 400 Bad Request.
*/
- TALER_EC_BANK_TRANSFER_NOT_AUHTORIZED = 5100,
+ TALER_EC_BANK_HISTORY_PARAMETER_MALFORMED = 5209,
/**
- * The wire transfer cannot be done because the debitor would
- * reach a unallowed debit.
+ * The client failed to login for /history. To be returned along
+ * HTTP 401 Unauthorized.
*/
- TALER_EC_BANK_TRANSFER_DEBIT = 5101,
+ TALER_EC_BANK_HISTORY_LOGIN_FAILED = 5212,
/**
- * The wire transfer cannot be done because the credit and
- * debit account are the same.
+ * The bank had trouble obtaining a valid HTTP response. To be returned
+ * along status code 0.
*/
- TALER_EC_BANK_TRANSFER_SAME_ACCOUNT = 5102,
+ TALER_EC_BANK_HISTORY_HTTP_FAILURE = 5213,
/**
- * Authentication failed for the /history request.
- * Returned with a status code of MHD_HTTP_FORBIDDEN.
+ * The debit account for /admin/add/incoming is not known to the
+ * bank. To be returned along HTTP 404 Not Found.
*/
- TALER_EC_BANK_HISTORY_NOT_AUHTORIZED = 5200,
+ TALER_EC_BANK_ADD_INCOMING_UNKNOWN_ACCOUNT = 5100,
/**
- * The bank library had trouble obtaining a valid
- * HTTP response.
- * Returned with a status code of 0.
+ * The client specified the same bank account for both the credit
+ * and the debit account. The bank will not accomplish this operation.
+ * To be returned along HTTP 403 Forbidden.
*/
- TALER_EC_BANK_HISTORY_HTTP_FAILURE = 5201,
+ TALER_EC_BANK_ADD_INCOMING_SAME_ACCOUNT = 5102,
/**
- * The bank could not find the wire transfer that was supposed to
- * be rejected.
- * Returned with a status code of MHD_HTTP_NOT_FOUND.
+ * The operation would put the client in a debit situation which is
+ * forbidden to them. To return along HTTP 403 Forbidden.
*/
- TALER_EC_BANK_REJECT_NOT_FOUND = 5300,
+ TALER_EC_BANK_ADD_INCOMING_UNALLOWED_DEBIT = 5103,
/**
- * Authentication failed for the /reject request.
- * Returned with a status code of MHD_HTTP_FORBIDDEN.
+ * The client POSTed an invalid JSON. To be returned along HTTP
+ * 400 Bad Request.
*/
- TALER_EC_BANK_REJECT_NOT_AUTHORIZED = 5301,
+ TALER_EC_BANK_ADD_INCOMING_JSON_INVALID = 5106,
/**
- * The client wants to reject a transaction where they are
- * not the _credit_ party, impossible!
+ * The client failed to login for /admin/add/incoming. To be returned
+ * along HTTP 401 Unauthorized.
*/
- TALER_EC_BANK_REJECT_NO_RIGHTS = 5302,
+ TALER_EC_BANK_ADD_INCOMING_LOGIN_FAILED = 5112,
/**
* End of error code range.
diff --git a/src/include/taler_exchange_service.h b/src/include/taler_exchange_service.h
index da39a179f..f1af114cb 100644
--- a/src/include/taler_exchange_service.h
+++ b/src/include/taler_exchange_service.h
@@ -717,6 +717,50 @@ TALER_EXCHANGE_refund (struct TALER_EXCHANGE_Handle *exchange,
/**
+ * Submit a refund request to the exchange and get the exchange's
+ * response. This API is used by a merchant. Note that
+ * while we return the response verbatim to the caller for further
+ * processing, we do already verify that the response is well-formed
+ * (i.e. that signatures included in the response are all valid). If
+ * the exchange's reply is not well-formed, we return an HTTP status code
+ * of zero to @a cb.
+ *
+ * The @a exchange must be ready to operate (i.e. have
+ * finished processing the /keys reply). If this check fails, we do
+ * NOT initiate the transaction with the exchange and instead return NULL.
+ *
+ * @param exchange the exchange handle; the exchange must be ready to operate
+ * @param amount the amount to be refunded; must be larger than the refund fee
+ * (as that fee is still being subtracted), and smaller than the amount
+ * (with deposit fee) of the original deposit contribution of this coin
+ * @param refund_fee fee applicable to this coin for the refund
+ * @param h_contract_terms hash of the contact of the merchant with the customer that is being refunded
+ * @param coin_pub coin’s public key of the coin from the original deposit operation
+ * @param rtransaction_id transaction id for the transaction between merchant and customer (of refunding operation);
+ * this is needed as we may first do a partial refund and later a full refund. If both
+ * refunds are also over the same amount, we need the @a rtransaction_id to make the disjoint
+ * refund requests different (as requests are idempotent and otherwise the 2nd refund might not work).
+ * @param merchant_pub public key of the merchant
+ * @param merchant_sig signature affirming the refund from the merchant
+ * @param cb the callback to call when a reply for this request is available
+ * @param cb_cls closure for the above callback
+ * @return a handle for this request; NULL if the inputs are invalid (i.e.
+ * signatures fail to verify). In this case, the callback is not called.
+ */
+struct TALER_EXCHANGE_RefundHandle *
+TALER_EXCHANGE_refund2 (struct TALER_EXCHANGE_Handle *exchange,
+ const struct TALER_Amount *amount,
+ const struct TALER_Amount *refund_fee,
+ const struct GNUNET_HashCode *h_contract_terms,
+ const struct TALER_CoinSpendPublicKeyP *coin_pub,
+ uint64_t rtransaction_id,
+ const struct TALER_MerchantPublicKeyP *merchant_pub,
+ const struct TALER_MerchantSignatureP *merchant_sig,
+ TALER_EXCHANGE_RefundResultCallback cb,
+ void *cb_cls);
+
+
+/**
* Cancel a refund permission request. This function cannot be used
* on a request handle if a response is already served for it. If
* this function is called, the refund may or may not have happened.
diff --git a/src/include/taler_exchangedb_plugin.h b/src/include/taler_exchangedb_plugin.h
index e64b0ad4c..ae38856a3 100644
--- a/src/include/taler_exchangedb_plugin.h
+++ b/src/include/taler_exchangedb_plugin.h
@@ -733,6 +733,29 @@ typedef int
/**
+ * Callback invoked with information about refunds applicable
+ * to a particular coin.
+ *
+ * @param cls closure
+ * @param merchant_pub public key of merchant who authorized refund
+ * @param merchant_sig signature of merchant authorizing refund
+ * @param h_contract hash of contract being refunded
+ * @param rtransaction_id refund transaction ID
+ * @param amount_with_fee amount being refunded
+ * @param refund_fee fee the exchange keeps for the refund processing
+ * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop
+ */
+typedef int
+(*TALER_EXCHANGEDB_RefundCoinCallback)(void *cls,
+ const struct TALER_MerchantPublicKeyP *merchant_pub,
+ const struct TALER_MerchantSignatureP *merchant_sig,
+ const struct GNUNET_HashCode *h_contract,
+ uint64_t rtransaction_id,
+ const struct TALER_Amount *amount_with_fee,
+ const struct TALER_Amount *refund_fee);
+
+
+/**
* Information about a coin that was revealed to the exchange
* during /refresh/reveal.
*/
@@ -1358,6 +1381,23 @@ struct TALER_EXCHANGEDB_Plugin
struct TALER_EXCHANGEDB_Session *session,
const struct TALER_EXCHANGEDB_Refund *refund);
+ /**
+ * Select refunds by @a coin_pub.
+ *
+ * @param cls closure of plugin
+ * @param session database handle to use
+ * @param coin_pub coin to get refunds for
+ * @param cb function to call for each refund found
+ * @param cb_cls closure for @a cb
+ * @return query result status
+ */
+ enum GNUNET_DB_QueryStatus
+ (*select_refunds_by_coin)(void *cls,
+ struct TALER_EXCHANGEDB_Session *session,
+ const struct TALER_CoinSpendPublicKeyP *coin_pub,
+ TALER_EXCHANGEDB_RefundCoinCallback cb,
+ void *cb_cls);
+
/**
* Mark a deposit as tiny, thereby declaring that it cannot be
@@ -1658,6 +1698,7 @@ struct TALER_EXCHANGEDB_Plugin
* @param start_date when does the fee go into effect
* @param end_date when does the fee end being valid
* @param wire_fee how high is the wire transfer fee
+ * @param closing_fee how high is the closing fee
* @param master_sig signature over the above by the exchange master key
* @return transaction status code
*/
@@ -1668,6 +1709,7 @@ struct TALER_EXCHANGEDB_Plugin
struct GNUNET_TIME_Absolute start_date,
struct GNUNET_TIME_Absolute end_date,
const struct TALER_Amount *wire_fee,
+ const struct TALER_Amount *closing_fee,
const struct TALER_MasterSignatureP *master_sig);
@@ -1681,6 +1723,7 @@ struct TALER_EXCHANGEDB_Plugin
* @param[out] start_date when does the fee go into effect
* @param[out] end_date when does the fee end being valid
* @param[out] wire_fee how high is the wire transfer fee
+ * @param[out] closing_fee how high is the closing fee
* @param[out] master_sig signature over the above by the exchange master key
* @return query status of the transaction
*/
@@ -1692,6 +1735,7 @@ struct TALER_EXCHANGEDB_Plugin
struct GNUNET_TIME_Absolute *start_date,
struct GNUNET_TIME_Absolute *end_date,
struct TALER_Amount *wire_fee,
+ struct TALER_Amount *closing_fee,
struct TALER_MasterSignatureP *master_sig);
diff --git a/src/include/taler_signatures.h b/src/include/taler_signatures.h
index 6355303a0..c281d21fd 100644
--- a/src/include/taler_signatures.h
+++ b/src/include/taler_signatures.h
@@ -178,6 +178,12 @@
*/
#define TALER_SIGNATURE_MERCHANT_REFUND_OK 1105
+/**
+ * Signature where the merchant confirms that the user replayed
+ * a payment for a browser session.
+ */
+#define TALER_SIGNATURE_MERCHANT_PAY_SESSION 1106
+
/*********************/
/* Wallet signatures */
@@ -1291,6 +1297,31 @@ struct TALER_MerchantRefundConfirmationPS
};
+/**
+ * Used by the merchant to confirm to the frontend that
+ * the user did a payment replay with the current browser session.
+ */
+struct TALER_MerchantPaySessionSigPS
+{
+ /**
+ * Set to #TALER_SIGNATURE_MERCHANT_PAY_SESSION.
+ */
+ struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
+
+ /**
+ * Hashed order id.
+ * Hashed without the 0-termination.
+ */
+ struct GNUNET_HashCode h_order_id GNUNET_PACKED;
+
+ /**
+ * Hashed session id.
+ * Hashed without the 0-termination.
+ */
+ struct GNUNET_HashCode h_session_id GNUNET_PACKED;
+
+};
+
GNUNET_NETWORK_STRUCT_END
#endif