@requestnetwork/payments

0.3.0 • Public • Published

Payment Components

This package contains a plug and play front end component that any developer can include in its website.

Trying it out

Demo

Usage

Server (with express)

  1. Create project
yarn init
  • Install dependencies
yarn add express body-parser dotenv
yarn add @requestnetwork/payments-server
  • Create a server.js file
const express = require('express');
const bodyParser = require('body-parser');
require('dotenv').config();
const request = require('@requestnetwork/payments-server')(process.env.API_KEY);

const app = express();

app.use(bodyParser.json());
app.use(express.static('public'));

app.post('/request', request.handler(process.env.ETH_ADDRESS));

app.use(function(err, req, res, next) {
  res.status(500);
  res.render('error', { error: err });
});

const listener = app.listen(process.env.PORT, function() {
  console.log('Your app is listening on port ' + listener.address().port);
});
  • Create a .env file, and fill in your data

    You can get your API Key by creating a free Request Account

# Your Request Accounts API key
API_KEY=xxxx-xxxx-xxxx-xxxx
# The wallet where you want to receive the money
ETH_ADDRESS=0x000000YOUR0ADDRESS
  • create public/index.html

Add the Request Payments button

<div
  id="request-payment"
  data-amount="7"
  data-currency="EUR"
  data-endpoint="/request"
  data-style-button-variant="dark"
></div>
  • Import the library and run it
<script src="https://unpkg.com/@requestnetwork/payments@0.2.0-alpha.5/dist/payments.iife.production.js"></script>

<script>
  RequestPayments.init('#request-payment');
</script>
  • Run!

node server.js

Readme

Keywords

none

Package Sidebar

Install

npm i @requestnetwork/payments

Weekly Downloads

0

Version

0.3.0

License

MIT

Unpacked Size

4.38 kB

Total Files

2

Last publish

Collaborators

  • rodrigopavezi-request
  • mantisclone-requestnetwork
  • stef.req
  • aimensahnoun
  • benjlevesque
  • request-bot
  • adamdowson
  • yomarion