Add retrieval/storage of current exchange rate data to payment recording.
[?]
Feb 26, 2017, 4:17 AM
WZFQDWW4XK6M4A4PQ7WQJUTZUPRGQR7V7ZVZY5ZTL5AMGIFMHB2QCDependencies
- [2]
BSIUHCGFAdd payment response handler. - [3]
AL37SVTCImplement payments service endpoints. - [4]
64C6AWH6Rename Ananke -> Quixotic, project reboot. - [5]
LAROLAYUWIP - [6]
O5FVTOM6Undo JSON silliness, enable a couple more routes. - [7]
Q5X5RYQLstylish-haskell reformatting - [8]
MJ6R42RCUtility methods for reading key & cert data. - [9]
WZUHEZSBStart of migration back toward snap. - [10]
OBFPJS2GProject successfully builds and tests under nix. - [11]
HMDM3B55Implement core of payments/billing infrastructure. - [12]
GCVQD44VCreate amends endpoint, switch to UUID primary keys - [13]
QADKFHARAdds CreatePayment handler implementation. - [14]
Z7KS5XHHVery WIP. Wow. - [15]
JFOEOFGAstylish-haskell formatting. - [16]
EZQG2APBUpdate task list. - [17]
Y3LIJ5USAdd handler for CreatePaymentRequest - [18]
QMRKFEPGRefactor QDB to use a free monad algebra instead. - [19]
AVDFWICBMore musings for the TASKS file. - [20]
373LXH2XAdd MAYBE.md, update task list. - [21]
W35DDBFYFactor common JSON conversions up into client lib module. - [22]
6L5BK5EHUse generic SMTP rather than Sendmail-specific mail client. - [23]
SEWTRB6SImplement payment request creation functions. - [24]
ZP62WC47Begin conversion to build with stack. - [25]
ASF3UPJLAdd auction creation and bid handlers - [26]
WAIX6AGNAdd event serialization for PaymentRequest & Payment - [27]
NEDDHXUKReformat via stylish-haskell - [28]
BROSTG5KBeginning of modularization of server. - [29]
DFOBMSAOInitial work on payments API - [30]
IZEVQF62Work in progress replacing sqlite with postgres. - [31]
A6HKMINBAttempting to improve JSON handling. - [32]
5XFJNUAZStart of addition of project infrastructure. - [33]
4IQVQL4TAdded client for payouts endpoint. - [34]
2Y2QZFVFSwitch to more modern cabal2nix-based workflow. - [35]
7KZP4RHZSwitch from Data.Time to Data.Thyme - [36]
V2VDN77HEnable postgres configuration via environment variable for Heroku. - [37]
RPAJLHMTChange to use UUIDs instead of ints for primary keys. - [38]
M4KM76DGMerge branch 'stackify' - [39]
2XQD6KKKAdd invitation logic and clean up DBProg error handling. - [40]
O227CEAVAdds storage of original event JSON for some DBOp constructors. - [41]
TCOAKCGGCompleted conversion to snap. - [42]
4U7F3CPITHE GREAT RENAMING OF THINGS! - [43]
4FDQGIXNMake payment request retrieval key an opaque 32-bit hash. - [44]
PBD7LZYQPostgres & auth are beginning to function. - [45]
POX3UAMTEnabling logging of time to contributor/project accounts - [46]
5W5M56VJMove library code to 'lib' - [47]
KEP5WUFJConvert project to stack-based build. - [48]
HE3JTXO3Added client call to payouts. - [49]
HALRDT2FAdded initial auction create route. - [*]
EKI57EJRAdd alternative implementation of auction winner determination. - [*]
ADMKQQGCInitial empty Snap project.
Change contents
- replacement in TASKS.md at line 63
* Payouts* Use the BIP-70 Bitcoin Payment Protocol to create payment requests.* Record requested payments* Migrate to servant-snap? https://github.com/haskell-servant/servant-snap - replacement in TASKS.md at line 75
to correctly report capital gains, in much the same fasion as is done forto correctly report capital gains, in much the same fashion as is done for - edit in aftok.cabal at line 26
Aftok.Client - edit in aftok.cabal at line 61
, lens-aeson - edit in aftok.cabal at line 77
, wreq - replacement in aftok.cabal at line 155
--, HsOpenSSL, HsOpenSSL, http-client, http-client-openssl - edit in aftok.cabal at line 161
--, MonadCatchIO-transformers - edit in aftok.cabal at line 165
--, resource-pool-catchio - edit in aftok.cabal at line 174
, wreq - file deletion: Client.hs Client.hs
{-# LANGUAGE NoImplicitPrelude #-}{-# LANGUAGE OverloadedStrings #-}{-# LANGUAGE ScopedTypeVariables #-}module Aftok.Client whereimport ClassyPreludeimport Control.Lensimport Data.Aeson.Typesimport qualified Data.Configurator as Cimport qualified Data.Configurator.Types as CTimport Network.Wreqimport Aftok.Jsonimport Aftok.TimeLogdata QCConfig = QCConfig{ aftokUrl :: String} deriving ShowparseQCConfig :: CT.Config -> IO QCConfigparseQCConfig cfg =QCConfig <$> C.require cfg "aftokUrl"currentPayouts :: QCConfig -> IO PayoutscurrentPayouts cfg = doresp <- get (aftokUrl cfg <> "payouts")valueResponse <- asValue respeither fail pure (parseEither parsePayoutsJSON $ valueResponse ^. responseBody) - edit in lib/Aftok/Database/PostgreSQL.hs at line 191
<*> field - replacement in lib/Aftok/Database/PostgreSQL.hs at line 538
\(payment_request_id, event_id, payment_data, payment_date) \\(payment_request_id, event_id, payment_data, payment_date, exchange_rates) \ - edit in lib/Aftok/Database/PostgreSQL.hs at line 544
, p ^. exchangeRates - replacement in lib/Aftok/Json.hs at line 222
[ "subscription_id" .= (r ^. (subscription . B._SubscriptionId . to tshow)), "payment_request_protobuf_64" .= (r ^. (paymentRequest . to (decodeUtf8 . B64.encode . runPut . encodeMessage))), "payment_request_time" .= (r ^. paymentRequestTime), "billing_date" .= (r ^. (billingDate . to showGregorian))[ "subscription_id" .=view (subscription . B._SubscriptionId . to tshow) r, "payment_request_protobuf_64" .=view (paymentRequest . to (decodeUtf8 . B64.encode . runPut . encodeMessage)) r, "url_key" .= view (paymentKey . _PaymentKey) r, "payment_request_time" .= view paymentRequestTime r, "billing_date" .= view (billingDate . to showGregorian) r - edit in lib/Aftok/Payments/Types.hs at line 13
import Data.Aeson (Value) - replacement in lib/Aftok/Payments/Types.hs at line 46
{ _request :: r, _payment :: P.Payment, _paymentDate :: C.UTCTime{ _request :: r, _payment :: P.Payment, _paymentDate :: C.UTCTime, _exchangeRates :: Maybe Value - replacement in lib/Aftok/Payments.hs at line 113
-- TODO: maybe-- TODO: maybe make pkey a function of subscription, billable, bday - replacement in server/Aftok/QConfig.hs at line 42[3.289]→[3.5199:5232](∅→∅),[3.5232]→[3.315:356](∅→∅),[3.315]→[3.315:356](∅→∅),[3.356]→[3.5233:5274](∅→∅)
{ network :: BT.Network, signingKeyFile :: System.IO.FilePath, certsFile :: System.IO.FilePath{ network :: BT.Network, signingKeyFile :: System.IO.FilePath, certsFile :: System.IO.FilePath, exchangeRateServiceURI :: String - edit in server/Aftok/QConfig.hs at line 78
<*> C.require cfg "exchangeRateServiceURI" - edit in server/Aftok/Snaplet/Payments.hs at line 1
{-# LANGUAGE TypeApplications #-} - replacement in server/Aftok/Snaplet/Payments.hs at line 11
import Control.Lens (view, _1, _2)import Control.Lens (view, _1, _2, _Right, _Left, preview, (&), (.~)) - edit in server/Aftok/Snaplet/Payments.hs at line 16
import Network.HTTP.Client.OpenSSLimport Network.HTTP.Client (defaultManagerSettings, managerResponseTimeout, HttpException)import Network.Wreq (asValue, responseBody, defaults, manager, getWith)import OpenSSL.Session (context) - replacement in server/Aftok/Snaplet/Payments.hs at line 21
import Snap.Core (readRequestBody)import Snap.Core (readRequestBody, logError) - edit in server/Aftok/Snaplet/Payments.hs at line 28
import Aftok.QConfig as QC - replacement in server/Aftok/Snaplet/Payments.hs at line 43
paymentResponseHandler :: S.Handler App App PaymentIdpaymentResponseHandler = dopaymentResponseHandler :: QC.BillingConfig -> S.Handler App App PaymentIdpaymentResponseHandler cfg = do - replacement in server/Aftok/Snaplet/Payments.hs at line 52
snapEval . liftdb . CreatePayment $ Payment (view _1 preq) pmnt nowlet opts = defaults & manager .~ Left (opensslManagerSettings context)& manager .~ Left (defaultManagerSettings { managerResponseTimeout = Just 10000 } )exchResp <- liftIO . try $ asValue =<< (withOpenSSL $ getWith opts (exchangeRateServiceURI cfg))_ <- traverse (logError . encodeUtf8 . tshow @ HttpException) (preview _Left exchResp)let newPayment = Payment (view _1 preq) pmnt now (preview (_Right . responseBody) exchResp)snapEval . liftdb $ CreatePayment newPayment - replacement in server/Main.hs at line 63
<|> (void $ method POST paymentResponseHandler)<|> (void . method POST . paymentResponseHandler $ billingConfig cfg)