Node.js SDK
Requesting Payment with Node.js
In this example we request payment in either DASH or BCH. Each payment request requires two different outputs one for five dollars and one for one dollar.
1
import { app } from 'anypay'
2
3
anypay = app(process.env.ANYPAY_API_SECRET)
4
5
let bill = 15
6
let tip = 3
7
8
let dashOption = {
9
currency: 'DASH',
10
to: [{
11
currency: 'USD',
12
amount: bill,
13
address: 'XhEh7yEzbJtViSrmJEiJ73CVp1C37j8eW7'
14
}, {
15
currency: 'USD',
16
amount: tip,
17
address: 'XnEw2KjfLVAy1hSXMFWLCcod5X7rLM581p'
18
}]
19
}
20
21
let bitcoincashOption = {
22
currency: 'BCH',
23
to: [{
24
currency: 'USD',
25
amount: bill,
26
address: 'bitcoincash:qztlw4ft8euq9wvzk27hh6lxtac2z4clay0w8v79zm'
27
}, {
28
currency: 'USD',
29
amount: tip,
30
address: 'bitcoincash:qp3cjuygakccjvq4k3ge3jjfmcalhz8a2sq2e0yum3'
31
}]
32
}
33
34
let request = await anypay.request([
35
dashOption, bitcoincashOption
36
], {
37
webhook: 'https://paypow.com/anypay/webhooks/payments',
38
redirect: 'https://paypow.com/anypay/webhooks/payments'
39
})
40
41
console.log(request)
42
Copied!
Last modified 8mo ago
Copy link