Bitcoin Payments In Your Web App

The Anypay Platform Makes It Super Easy To Profit By Bitcoin In Your App Or Website

Include the Anypay.js browser SDK in your website

<script src="https://unpkg.com/@anypayinc/widget/anypay.min.js"></script>

Then request payment to one or more recipients, for one or more coins including BTC, BCH, BSV, LTC, DASH. Your app will be automatically notified when payment is complete.

anypay.collectPayment({
accountId: '1177',
amount: 2.00
})
.once('paid', () => {
console.log('Invoice paid');
setTimeout(() => {
anypay.close();
}, 2000);
})
<script>
let invoice = anypay.newPayment({
template: [{
currency: 'DASH',
to: [{
currency: 'USD',
amount: 150,
address: 'XhEh7yEzbJtViSrmJEiJ73CVp1C37j8eW7'
}, {
currency: 'USD',
amount: 10,
address: 'XnEw2KjfLVAy1hSXMFWLCcod5X7rLM581p'
}]
}],
options: {
webhook: 'https://paypow.com/anypay/webhooks/payments',
redirect: 'https://paypow.com/anypay//payments'
}
})
invoice.once('paid', paidInvoice => {
// the invoice was paid, guaranteed perfectly correct!
anypay.close() // close iframe popup
})
</script>

Requesting Payment Directly From Anypay Payments API

const ANYPAY_API_SECRET = 'YOUR_API_KEY_HERE'
const http = require('superagent')
const requestJSON = {
template: [{
currency: 'DASH',
to: [{
currency: 'USD',
amount: 150,
address: 'XhEh7yEzbJtViSrmJEiJ73CVp1C37j8eW7'
}, {
currency: 'USD',
amount: 10,
address: 'XnEw2KjfLVAy1hSXMFWLCcod5X7rLM581p'
}]
}],
options: {
webhook: 'https://paypow.com/anypay/webhooks/payments',
redirect: 'https://paypow.com/anypay//payments'
}
}
let response = await http
.post('https://api.anypayinc.com/r')
.send(requestJSON)
.auth(ANYPAY_API_KEY, '')

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.

import { app } from 'anypay'
anypay = app(process.env.ANYPAY_API_SECRET)
let bill = 15
let tip = 3
let dashOption = {
currency: 'DASH',
to: [{
currency: 'USD',
amount: bill,
address: 'XhEh7yEzbJtViSrmJEiJ73CVp1C37j8eW7'
}, {
currency: 'USD',
amount: tip,
address: 'XnEw2KjfLVAy1hSXMFWLCcod5X7rLM581p'
}]
}
let bitcoincashOption = {
currency: 'BCH',
to: [{
currency: 'USD',
amount: bill,
address: 'bitcoincash:qztlw4ft8euq9wvzk27hh6lxtac2z4clay0w8v79zm'
}, {
currency: 'USD',
amount: tip,
address: 'bitcoincash:qp3cjuygakccjvq4k3ge3jjfmcalhz8a2sq2e0yum3'
}]
}
let request = await anypay.request([
dashOption, bitcoincashOption
], {
webhook: 'https://paypow.com/anypay/webhooks/payments',
redirect: 'https://paypow.com/anypay/webhooks/payments'
})
console.log(request)