Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
Wazen Shbair
EcoReceipt
Commits
6a87f77e
You need to sign in or sign up before continuing.
Commit
6a87f77e
authored
Jul 15, 2020
by
wazen shbair
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update payment server
parent
adbe6ede
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
4 deletions
+51
-4
eco-receipt/ripple/.DS_Store
eco-receipt/ripple/.DS_Store
+0
-0
eco-receipt/ripple/payment_server.js
eco-receipt/ripple/payment_server.js
+51
-4
No files found.
eco-receipt/ripple/.DS_Store
View file @
6a87f77e
No preview for this file type
eco-receipt/ripple/payment_server.js
View file @
6a87f77e
...
@@ -44,6 +44,8 @@ app.get('/payment_service/account/info', async (req,res)=>{
...
@@ -44,6 +44,8 @@ app.get('/payment_service/account/info', async (req,res)=>{
app
.
post
(
'
/payment_service/transfer
'
,
async
(
req
,
res
)
=>
{
app
.
post
(
'
/payment_service/transfer
'
,
async
(
req
,
res
)
=>
{
var
destinationAccount
=
req
.
body
.
destinationAccount
;
var
destinationAccount
=
req
.
body
.
destinationAccount
;
var
amount
=
req
.
body
.
amount
var
amount
=
req
.
body
.
amount
var
store_name
=
req
.
body
.
store_name
var
rewards
=
req
.
body
.
rewards
const
instructions
=
{
maxLedgerVersionOffset
:
5
};
const
instructions
=
{
maxLedgerVersionOffset
:
5
};
const
payment
=
{
const
payment
=
{
...
@@ -60,7 +62,12 @@ app.post('/payment_service/transfer', async (req,res)=>{
...
@@ -60,7 +62,12 @@ app.post('/payment_service/transfer', async (req,res)=>{
value
:
String
(
amount
),
value
:
String
(
amount
),
currency
:
'
XRP
'
currency
:
'
XRP
'
}
}
}
},
memos
:
[
{
"
data
"
:
store_name
+
"
*
"
+
rewards
},
]
};
};
function
quit
(
message
)
{
function
quit
(
message
)
{
res
.
json
({
'
msg
'
:
message
})
res
.
json
({
'
msg
'
:
message
})
...
@@ -73,7 +80,6 @@ app.post('/payment_service/transfer', async (req,res)=>{
...
@@ -73,7 +80,6 @@ app.post('/payment_service/transfer', async (req,res)=>{
}
}
api
.
preparePayment
(
masterAccount
,
payment
,
instructions
).
then
(
prepared
=>
{
api
.
preparePayment
(
masterAccount
,
payment
,
instructions
).
then
(
prepared
=>
{
console
.
log
(
'
Payment transaction prepared...
'
);
console
.
log
(
'
Payment transaction prepared...
'
);
const
{
signedTransaction
}
=
api
.
sign
(
prepared
.
txJSON
,
masterAccountSecret
);
const
{
signedTransaction
}
=
api
.
sign
(
prepared
.
txJSON
,
masterAccountSecret
);
...
@@ -126,7 +132,48 @@ app.get('/payment_service/account/new_address', (req,res)=>{
...
@@ -126,7 +132,48 @@ app.get('/payment_service/account/new_address', (req,res)=>{
});
});
})
})
//--------------------------------------------------
// Get rewards points
//--------------------------------------------------
app
.
get
(
'
/payment_service/account/rewards_points
'
,
async
(
req
,
res
)
=>
{
var
account
=
req
.
body
.
account
;
console
.
log
(
account
)
const
options
=
{
earliestFirst
:
true
,
minLedgerVersion
:
8828630
}
function
quit
(
message
)
{
var
o
=
{}
// empty Object
var
key
=
'
rewards points
'
;
o
[
key
]
=
[];
// empty Array, which you can push() values into
var
jsonString
=
""
;
message
.
forEach
(
element
=>
{
var
data
=
element
.
specification
.
memos
[
0
].
data
.
split
(
"
*
"
)
jsonString
=
"
{
\"
store_name
\"
:
\"
"
+
data
[
0
]
+
"
\"
}
"
;
var
jsonObj
=
JSON
.
parse
(
jsonString
);
jsonObj
.
rewards_points
=
data
[
1
]
o
[
key
].
push
(
jsonObj
)
});
res
.
json
(
o
)
}
function
fail
(
message
)
{
console
.
error
(
message
);
res
.
json
({
'
msg
'
:
message
})
}
await
api
.
getTransactions
(
account
,
options
).
then
(
quit
,
fail
)
})
function
splitStr
(
str
)
{
var
string
=
str
.
split
(
"
:
"
);
return
"
{
\"
"
+
string
[
0
]
+
"
\"
:
\"
"
+
string
[
1
]
+
"
\"
}
"
}
app
.
listen
(
6000
)
app
.
listen
(
6000
)
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment