Make payment request retrieval key an opaque 32-bit hash.
[?]
Feb 25, 2017, 9:42 PM
4FDQGIXN3Z4J55DILCSI5EOLIIA7R5CADTGFMW5X7N7MH6JIMBWACDependencies
- [2]
AL37SVTCImplement payments service endpoints. - [3]
GCVQD44VCreate amends endpoint, switch to UUID primary keys - [4]
DFOBMSAOInitial work on payments API - [5]
Y3LIJ5USAdd handler for CreatePaymentRequest - [6]
Q5X5RYQLstylish-haskell reformatting - [7]
SEWTRB6SImplement payment request creation functions. - [8]
QADKFHARAdds CreatePayment handler implementation. - [9]
WAIX6AGNAdd event serialization for PaymentRequest & Payment - [10]
HALRDT2FAdded initial auction create route. - [11]
2XQD6KKKAdd invitation logic and clean up DBProg error handling. - [12]
ASF3UPJLAdd auction creation and bid handlers - [13]
RN7EI6INUpdate database layer to use CreditTo - [14]
O227CEAVAdds storage of original event JSON for some DBOp constructors. - [15]
HMDM3B55Implement core of payments/billing infrastructure. - [16]
JFOEOFGAstylish-haskell formatting. - [17]
IZEVQF62Work in progress replacing sqlite with postgres. - [*]
64C6AWH6Rename Ananke -> Quixotic, project reboot. - [*]
NEDDHXUKReformat via stylish-haskell - [*]
W35DDBFYFactor common JSON conversions up into client lib module. - [*]
BROSTG5KBeginning of modularization of server. - [*]
ADMKQQGCInitial empty Snap project.
Change contents
- edit in aftok.cabal at line 41
, blake2 - edit in lib/Aftok/Database/PostgreSQL.hs at line 9
import qualified Crypto.Hash.BLAKE2.BLAKE2b as B2import Crypto.Random.Types (MonadRandom, getRandomBytes) - replacement in lib/Aftok/Database/PostgreSQL.hs at line 26
import Network.Haskoin.Crypto (addrToBase58)import Network.Haskoin.Crypto (addrToBase58, encodeBase58Check) - edit in lib/Aftok/Database/PostgreSQL.hs at line 47
instance MonadRandom QDBM wheregetRandomBytes = QDBM . lift . lift . getRandomBytes - edit in lib/Aftok/Database/PostgreSQL.hs at line 51
- edit in lib/Aftok/Database/PostgreSQL.hs at line 486
keyBytes <- getRandomBytes 64let prBytes = req ^. (paymentRequest . to (runPut . encodeMessage))urlKey = decodeUtf8 . encodeBase58Check $ B2.hash 32 keyBytes prBytes - replacement in lib/Aftok/Database/PostgreSQL.hs at line 491
\(subscription_id, event_id, request_data, request_time, billing_date) \\VALUES (?, ?, ?, ?, ?) RETURNING id"\(subscription_id, event_id, request_data, url_key, request_time, billing_date) \\VALUES (?, ?, ?, ?, ?, ?) RETURNING id" - replacement in lib/Aftok/Database/PostgreSQL.hs at line 495
, req ^. (paymentRequest . to (runPut . encodeMessage)), prBytes, urlKey - replacement in lib/Aftok/Database/PostgreSQL.hs at line 501
pgEval (FindPaymentRequest rid) =pgEval (FindPaymentRequest (PaymentKey k)) = - replacement in lib/Aftok/Database/PostgreSQL.hs at line 505
\WHERE id = ?"(Only (rid ^. _PaymentRequestId))\WHERE url_key = ?"(Only k) - replacement in lib/Aftok/Database/PostgreSQL.hs at line 516
let rowp :: RowParser (PaymentRequestId, PaymentRequest, B.Subscription, B.Billable)rowp = (,,,) <$> idParser PaymentRequestIdlet rowp :: RowParser (PaymentKey, PaymentRequest, B.Subscription, B.Billable)rowp = (,,,) <$> (PaymentKey <$> field) - replacement in lib/Aftok/Database/PostgreSQL.hs at line 522
"SELECT id, \"SELECT r.url_key, \ - edit in lib/Aftok/Database.hs at line 60
FindPaymentRequest :: PaymentRequestId -> DBOp (Maybe PaymentRequest) - edit in lib/Aftok/Database.hs at line 62
FindPaymentRequest :: PaymentKey -> DBOp (Maybe PaymentRequest) - edit in lib/Aftok/Database.hs at line 205
findPaymentRequest :: (MonadDB m) => PaymentKey -> m (Maybe PaymentRequest)findPaymentRequest = liftdb . FindPaymentRequest - replacement in lib/Aftok/Json.hs at line 235
[ ["payment_request_id" .= idJSON _PaymentRequestId (view _1 r)][ ["payment_request_id" .= view (_1 . _PaymentKey) r] - edit in lib/Aftok/Payments/Types.hs at line 19
import Network.Haskoin.Crypto (decodeBase58Check) - edit in lib/Aftok/Payments/Types.hs at line 28
newtype PaymentKey = PaymentKey Text deriving (Eq)makePrisms ''PaymentKey - replacement in lib/Aftok/Payments/Types.hs at line 51
type BillDetail = (PaymentRequestId, PaymentRequest, Subscription, Billable)type BillDetail = (PaymentKey, PaymentRequest, Subscription, Billable) - edit in lib/Aftok/Payments/Types.hs at line 63[3.2572]
parsePaymentKey :: ByteString -> Maybe PaymentKeyparsePaymentKey bs = (PaymentKey . decodeUtf8) <$> decodeBase58Check bs - replacement in server/Aftok/Snaplet/Payments.hs at line 5
import Control.Lens (view, _1, _2)import Control.Lens (view) - edit in server/Aftok/Snaplet/Payments.hs at line 13
import Aftok.Database - replacement in server/Aftok/Snaplet/Payments.hs at line 27
uid <- requireUserIdsid <- requireId "subscriptionId" SubscriptionIdrid <- requireId "paymentRequestId" PaymentRequestIdnow <- liftIO $ C.getCurrentTimerequests <- snapEval $ findPayableRequests uid sid nowlet prMay = fmap (view (_2 . paymentRequest)) . headMay $ filter ((==) rid . view _1) requestsmaybe (snapError 404 $ "Outstanding payment request not found for id " <> tshow rid) pure prMaypkBytes <- requireParam "paymentRequestKey"pkey <- maybe(snapError 400 $ "parameter paymentRequestKey is formatted incorrectly.") pure(parsePaymentKey pkBytes)prMay <- snapEval $ findPaymentRequest pkeymaybe (snapError 404 $ "Outstanding payment request not found for key " <> (view _PaymentKey pkey))(pure . view paymentRequest)prMay - edit in server/Aftok/Snaplet.hs at line 64
requireParam :: MonadSnap m => Text -> m ByteStringrequireParam name = domaybeBytes <- getParam (encodeUtf8 name)maybe (snapError 400 $ "Parameter "<> tshow name <>" is required") pure maybeBytes - replacement in server/Aftok/Snaplet.hs at line 74
maybeBytes <- getParam (encodeUtf8 name)case maybeBytes ofNothing -> snapError 400 $ "Parameter "<> tshow name <>" is required"Just bytes -> either(const . snapError 400 $ "Value of parameter "<> tshow name <>" could not be parsed to a valid value.")pure(parseOnly parser bytes)bytes <- requireParam nameeither(const . snapError 400 $ "Value of parameter "<> tshow name <>" could not be parsed to a valid value.")pure(parseOnly parser bytes) - replacement in server/Main.hs at line 87
, ("subscriptions/:subscriptionId/payment_requests/:paymentRequestId", paymentRequestRoute), ("pay/:paymentRequestKey", paymentRequestRoute)