Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PaymentServer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Administrator
PaymentServer
Commits
be4e9543
Commit
be4e9543
authored
5 years ago
by
Ramakrishnan Muthukrishnan
Browse files
Options
Downloads
Patches
Plain Diff
WIP: initial implementation that calls stripe charge API (incomplete)
parent
ded42e07
No related branches found
Branches containing commit
No related tags found
1 merge request
!30
Expose a browser facing API for charge
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/PaymentServer/Processors/Stripe.hs
+12
-5
12 additions, 5 deletions
src/PaymentServer/Processors/Stripe.hs
with
12 additions
and
5 deletions
src/PaymentServer/Processors/Stripe.hs
+
12
−
5
View file @
be4e9543
...
@@ -58,7 +58,9 @@ import PaymentServer.Persistence
...
@@ -58,7 +58,9 @@ import PaymentServer.Persistence
)
)
import
Web.Stripe.Charge
import
Web.Stripe.Charge
(
createCharge
(
createCharge
,
chargeId
,
Amount
(
..
)
,
Amount
(
..
)
,
TokenId
(
..
)
)
)
import
Web.Stripe.Client
import
Web.Stripe.Client
(
StripeConfig
(
..
)
(
StripeConfig
(
..
)
...
@@ -66,6 +68,7 @@ import Web.Stripe.Client
...
@@ -66,6 +68,7 @@ import Web.Stripe.Client
)
)
import
Web.Stripe
import
Web.Stripe
(
stripe
(
stripe
,
(
-&-
)
)
)
data
Acknowledgement
=
Ok
data
Acknowledgement
=
Ok
...
@@ -86,8 +89,8 @@ getVoucher (MetaData (("Voucher", value):xs)) = Just value
...
@@ -86,8 +89,8 @@ getVoucher (MetaData (("Voucher", value):xs)) = Just value
getVoucher
(
MetaData
(
x
:
xs
))
=
getVoucher
(
MetaData
xs
)
getVoucher
(
MetaData
(
x
:
xs
))
=
getVoucher
(
MetaData
xs
)
stripeServer
::
VoucherDatabase
d
=>
d
->
ByteString
->
Server
StripeAPI
stripeServer
::
VoucherDatabase
d
=>
d
->
ByteString
->
Server
StripeAPI
stripeServer
d
key
=
(
webhook
d
)
stripeServer
d
key
=
webhook
d
:<|>
(
charge
d
key
)
:<|>
charge
d
key
-- | Process charge succeeded events
-- | Process charge succeeded events
webhook
::
VoucherDatabase
d
=>
d
->
Event
->
Handler
Acknowledgement
webhook
::
VoucherDatabase
d
=>
d
->
Event
->
Handler
Acknowledgement
...
@@ -132,10 +135,14 @@ instance FromJSON Charges where
...
@@ -132,10 +135,14 @@ instance FromJSON Charges where
v
.:
"currency"
v
.:
"currency"
parseJSON
_
=
mzero
parseJSON
_
=
mzero
-- | call the stripe Charge API (with token, voucher in metadata, amount, currency etc
-- and if the Charge is okay, then return set the voucher as "paid" in the database.
charge
::
VoucherDatabase
d
=>
d
->
ByteString
->
Charges
->
Handler
Acknowledgement
charge
::
VoucherDatabase
d
=>
d
->
ByteString
->
Charges
->
Handler
Acknowledgement
charge
d
key
(
Charges
token
voucher
amount
currency
)
=
do
charge
d
key
(
Charges
token
voucher
amount
currency
)
=
do
-- call the stripe Charge API (with token, voucher in metadata, amount, currency etc
-- and if the Charge is okay, then return set the voucher as "paid" in the database.
let
config
=
StripeConfig
(
StripeKey
key
)
Nothing
let
config
=
StripeConfig
(
StripeKey
key
)
Nothing
result
<-
liftIO
$
stripe
config
$
createCharge
(
Amount
amount
)
(
read
(
unpack
currency
))
tokenId
=
TokenId
token
result
<-
liftIO
$
stripe
config
$
createCharge
(
Amount
amount
)
(
read
(
unpack
currency
))
-&-
tokenId
-&-
MetaData
[(
"Voucher"
,
voucher
)]
return
Ok
return
Ok
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment