gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-merchant] 87/277: revise GET /private/orders API


From: gnunet
Subject: [taler-merchant] 87/277: revise GET /private/orders API
Date: Sun, 05 Jul 2020 20:50:00 +0200

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository merchant.

commit dbee9e5a7f8160b94b3b5242f2284b0dbb8b21d3
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sun May 3 20:17:36 2020 +0200

    revise GET /private/orders API
---
 src/backenddb/merchant-0001.sql      | 45 +++++++++++++++-----
 src/include/taler_merchant_service.h | 81 ++++++++++++++++++++++--------------
 src/lib/Makefile.am                  |  7 ++--
 src/testing/Makefile.am              |  9 ++--
 4 files changed, 93 insertions(+), 49 deletions(-)

diff --git a/src/backenddb/merchant-0001.sql b/src/backenddb/merchant-0001.sql
index e54e478..36eb67b 100644
--- a/src/backenddb/merchant-0001.sql
+++ b/src/backenddb/merchant-0001.sql
@@ -339,7 +339,7 @@ COMMENT ON TABLE merchant_refund_proofs
 
 -------------------- Wire transfers ---------------------------
 
-CREATE TABLE IF NOT EXISTS merchant_credits
+CREATE TABLE IF NOT EXISTS merchant_transfers
   (credit_serial BIGSERIAL PRIMARY KEY
   ,exchange_url VARCHAR NOT NULL
   ,wtid BYTEA CHECK (LENGTH(wtid)=32)
@@ -348,16 +348,19 @@ CREATE TABLE IF NOT EXISTS merchant_credits
   ,account_serial BIGINT NOT NULL
      REFERENCES merchant_accounts (account_serial) ON DELETE CASCADE
   ,verified BOOLEAN NOT NULL DEFAULT FALSE
+  ,confirmed BOOLEAN NOT NULL DEFAULT FALSE
   ,UNIQUE (wtid, exchange_url)
   );
-COMMENT ON TABLE merchant_credits
+COMMENT ON TABLE merchant_transfers
   IS 'table represents the information provided by the (trusted) merchant 
about incoming wire transfers';
-COMMENT ON COLUMN merchant_credits.verified
+COMMENT ON COLUMN merchant_transfers.verified
   IS 'true once we got an acceptable response from the exchange for this 
transfer';
+COMMENT ON COLUMN merchant_transfers.confirmed
+  IS 'true once the merchant confirmed that this transfer was received';
 
 CREATE TABLE IF NOT EXISTS merchant_transfer_signatures
   (credit_serial BIGINT PRIMARY KEY
-     REFERENCES merchant_credits (credit_serial) ON DELETE CASCADE
+     REFERENCES merchant_transfers (credit_serial) ON DELETE CASCADE
   ,account_serial BIGINT NOT NULL
      REFERENCES merchant_accounts (account_serial) ON DELETE CASCADE
   ,signkey_serial BIGINT NOT NULL
@@ -367,12 +370,14 @@ CREATE TABLE IF NOT EXISTS merchant_transfer_signatures
   );
 COMMENT ON TABLE merchant_transfer_signatures
   IS 'table represents the main information returned from the /transfer 
request to the exchange.';
+COMMENT ON COLUMN merchant_transfer_signatures.execution_time
+  IS 'Execution time as claimed by the exchange, roughly matches time seen by 
merchant';
 
-CREATE TABLE IF NOT EXISTS merchant_transfer_by_coin
+CREATE TABLE IF NOT EXISTS merchant_transfer_to_coin
   (deposit_serial BIGINT UNIQUE NOT NULL
      REFERENCES merchant_deposits (deposit_serial) ON DELETE CASCADE
   ,credit_serial BIGINT NOT NULL
-     REFERENCES merchant_credits (credit_serial) ON DELETE CASCADE
+     REFERENCES merchant_transfers (credit_serial) ON DELETE CASCADE
   ,offset_in_exchange_list INT8 NOT NULL
   ,exchange_deposit_value_val INT8 NOT NULL
   ,exchange_deposit_value_frac INT4 NOT NULL
@@ -380,15 +385,33 @@ CREATE TABLE IF NOT EXISTS merchant_transfer_by_coin
   ,exchange_deposit_fee_frac INT4 NOT NULL
   );
 CREATE INDEX IF NOT EXISTS merchant_transfers_by_credit
-  ON merchant_transfer_by_coin
+  ON merchant_transfer_to_coin
   (credit_serial);
-COMMENT ON TABLE merchant_transfer_by_coin
-  IS 'Mapping of deposits to wire transfers and vice versa';
-COMMENT ON COLUMN merchant_transfer_by_coin.exchange_deposit_value_val
+COMMENT ON TABLE merchant_transfer_to_coin
+  IS 'Mapping of (credit) transfers to (deposited) coins';
+COMMENT ON COLUMN merchant_transfer_to_coin.exchange_deposit_value_val
   IS 'Deposit value as claimed by the exchange, should match our values in 
merchant_deposits minus refunds';
-COMMENT ON COLUMN merchant_transfer_by_coin.exchange_deposit_fee_val
+COMMENT ON COLUMN merchant_transfer_to_coin.exchange_deposit_fee_val
   IS 'Deposit value as claimed by the exchange, should match our values in 
merchant_deposits';
 
+CREATE TABLE IF NOT EXISTS merchant_deposit_to_transfer
+  (deposit_serial BIGINT NOT NULL
+     REFERENCES merchant_deposits (deposit_serial) ON DELETE CASCADE
+  ,coin_contribution_value_val INT8 NOT NULL
+  ,coin_contribution_value_frac INT4 NOT NULL
+  ,credit_serial BIGINT NOT NULL
+     REFERENCES merchant_transfers (credit_serial)
+  ,execution_time INT8 NOT NULL
+  ,signkey_serial BIGINT NOT NULL
+     REFERENCES merchant_exchange_signing_keys (signkey_serial) ON DELETE 
CASCADE
+  ,exchange_sig BYTEA NOT NULL CHECK (LENGTH(exchange_sig)=64)
+  ,UNIQUE(coin_pub,wtid)
+);
+COMMENT ON TABLE merchant_deposit_to_transfer
+  IS 'Mapping of deposits to (possibly unconfirmed) wire transfers';
+COMMENT ON COLUMN merchant_deposit_to_transfer.execution_time
+  IS 'Execution time as claimed by the exchange, roughly matches time seen by 
merchant';
+
 
 -------------------------- Tipping ---------------------------
 
diff --git a/src/include/taler_merchant_service.h 
b/src/include/taler_merchant_service.h
index cfed743..170e627 100644
--- a/src/include/taler_merchant_service.h
+++ b/src/include/taler_merchant_service.h
@@ -1483,6 +1483,45 @@ struct TALER_MERCHANT_WireTransfer
 };
 
 
+/**
+ * Details about a conflicting response returned by the exchange.
+ */
+struct TALER_MERCHANT_WireConflict
+{
+
+  /**
+   * Error code explaining the nature of the conflict. Can either be that
+   * @e coin_pub is not (or with a different amount) included in @e
+   * wtid_claim despite @e deposit_claim saying it should be, or that the
+   * amounts in @e wtid_claim do not add up.
+   */
+  enum TALER_ErrorCode code;
+
+  /**
+   * Human-readable error description.
+   */
+  const char *hint;
+
+  /**
+   * Public key of the coin involved.
+   */
+  struct TALER_CoinSpendPublicKeyP coin_pub;
+
+  /**
+   * A claim by the exchange about the transactions associated
+   * with a given wire transfer.
+   */
+  struct TALER_EXCHANGE_TransferData wtid_claim;
+
+  /**
+   * A claim by the exchange that the given transaction is included
+   * in the above WTID.
+   */
+  struct TALER_EXCHANGE_DepositData deposit_claim;
+
+};
+
+
 /**
  * Details about the status of an order.
  */
@@ -1521,14 +1560,14 @@ struct TALER_MERCHANT_OrderStatusResponse
 
       /**
        * Array of wire transfers made for this payment to the
-       * merchant by the exchange. Of length @e wt_len.
+       * merchant by the exchange. Of length @e wts_len.
        */
-      struct TALER_MERCHANT_WireTransfer *wt;
+      struct TALER_MERCHANT_WireTransfer *wts;
 
       /**
        * Length of the @e wt array.
        */
-      unsigned int wt_len;
+      unsigned int wts_len;
 
     } paid;
 
@@ -1558,42 +1597,22 @@ struct TALER_MERCHANT_OrderStatusResponse
     struct
     {
 
-      // FIXME: we probably should return an ARRAY of these,
-      // as there could be multiple errors involving multiple
-      // coins. Also, we should compute the losses and
-      // return those! => need specification update first!
-
-      /**
-       * Error code explaining the nature of the conflict. Can either be that
-       * @e coin_pub is not (or with a different amount) included in @e
-       * wtid_claim despite @e deposit_claim saying it should be, or that the
-       * amounts in @e wtid_claim do not add up.
-       */
-      enum TALER_ErrorCode code;
-
-      /**
-       * Human-readable error description.
-       */
-      const char *hint;
-
       /**
-       * Public key of the coin involved.
+       * Length of the @e conflicts array.
        */
-      struct TALER_CoinSpendPublicKeyP coin_pub;
+      unsigned int num_conficts;
 
       /**
-       * A claim by the exchange about the transactions associated
-       * with a given wire transfer.
+       * Array of conflicting information returned by the exchange
+       * concerning the payments made for this order.
        */
-      // FIXME: should update exchange API first to define the struct!
-      /* struct TALER_EXCHANGE_TransferData * */ void *wtid_claim;
+      struct TALER_MERCHANT_WireConflict *conflicts;
 
       /**
-       * A claim by the exchange that the given transaction is included
-       * in the above WTID.
+       * Losses we believe to have suffered as a result from
+       * the @e conflicts (in total).
        */
-      // FIXME: should update exchange API first to define the struct!
-      /* struct TALER_EXCHANGE_DepositData * */ void *deposit_claim;
+      struct TALER_Amount total_loss;
 
     } conflict;
 
diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am
index b1cd054..96ee166 100644
--- a/src/lib/Makefile.am
+++ b/src/lib/Makefile.am
@@ -34,15 +34,16 @@ libtalermerchant_la_SOURCES = \
   merchant_api_post_order_pay.c \
   merchant_api_post_order_refund.c \
  \
-  merchant_api_get_order.c \
-  merchant_api_get_order2.c \
-  merchant_api_get_order3.c \
   merchant_api_tip_authorize.c \
   merchant_api_tip_pickup.c \
   merchant_api_tip_pickup2.c \
   merchant_api_tip_query.c \
   merchant_api_track_transaction.c \
   merchant_api_track_transfer.c
+#  merchant_api_get_order.c \
+#  merchant_api_get_order2.c \
+#  merchant_api_get_order3.c
+
 libtalermerchant_la_LIBADD = \
   -ltalerexchange \
   -ltalercurl \
diff --git a/src/testing/Makefile.am b/src/testing/Makefile.am
index 43c0dd8..2b3386e 100644
--- a/src/testing/Makefile.am
+++ b/src/testing/Makefile.am
@@ -32,10 +32,6 @@ libtalermerchanttesting_la_SOURCES = \
   testing_api_cmd_patch_product.c \
   testing_api_cmd_refund_order.c \
    \
-  testing_api_cmd_check_payment.c \
-  testing_api_cmd_history.c \
-  testing_api_cmd_poll_payment.c \
-  testing_api_cmd_refund_lookup.c \
   testing_api_cmd_rewind.c \
   testing_api_cmd_tip_authorize.c \
   testing_api_cmd_tip_pickup.c \
@@ -49,6 +45,11 @@ libtalermerchanttesting_la_SOURCES = \
   testing_api_trait_planchet.c \
   testing_api_trait_refund_entry.c
 
+#  testing_api_cmd_history.c \
+#  testing_api_cmd_check_payment.c \
+#  testing_api_cmd_poll_payment.c \
+#  testing_api_cmd_refund_lookup.c
+
 libtalermerchanttesting_la_LIBADD = \
   $(top_srcdir)/src/lib/libtalermerchant.la \
   -ltalerexchange \

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]