Skip to content

Instantly share code, notes, and snippets.

@owenkellogg
Last active May 15, 2019 13:41
Show Gist options
  • Save owenkellogg/cba9251e02a765d3362dfbc6199012bc to your computer and use it in GitHub Desktop.
Save owenkellogg/cba9251e02a765d3362dfbc6199012bc to your computer and use it in GitHub Desktop.

Authentication

use http basic auth to authenticate requests to generate invoices

where the username is your access token and the password an empty string.

Generating Invoices

Send the amount in terms of USD, and the currency you want to collect being BCH, DASH, ZEC, etc.

curl -X POST https://api.anypay.global/invoices \
  -u myAccessToken: \
  -d webhook_url=https://webhooks.coil.com/anypay \
  -d amount=1 \
  -d currency=DASH

Getting Invoice Info

GET https://api.anypay.global/invoices/{uid}

Webhooks

Given a webhook_url the invoice data will be posted to your url when payment is complete.

Websockets

Your app can subscribe to notifications of payment via websockets:

var socket = socketIO('wss://ws.anypay.global', {
  transports: ['websocket']
});

socket.on('connect', function () {
  socket.emit('subscribe', {invoice: invoice.uid});
});

socket.on('invoice:paid', function (data) {
  // handle invoice data
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment