API Reference

Clients

Typescript / Javascript library

yarn add @repaya/client

Example project on GitHub

Quick Start
import { Client } from '@repaya/client';
import express from 'express';

const apiToken = process.env.REPAYA_API_TOKEN;  /* repaya API token */
const formId = process.env.REPAYA_FORM_ID;      /* repaya payment form id */

/* create repaya client for the ethereum mainnet */
const repaya = new Client(process.env.REPAYA_DOMAIN, apiToken);  

const app = express();

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

/* Initiate the checkout fow and redirect user to complete the payment */
app.post('/checkout', async (req, res) => {
    const userId = 'user_42';           /* replace with the one in your system */
    const productId = 'product_65291';  /* replace with the one in your system */

    /* create a payment session */
    const session = await repaya.sessions.create(formId, {
    	customer: { id: userId },
     	product: {
            id: productId,
            name: 'Awesome product'
      	},
      	price: {
            USD_MULTI_1: '5.0',
     	}
    });
  
    res.redirect(303, session.checkoutUrl);
});

/* Handle the customer after the checkout and validate payment status */
app.get('/after_checkout', async (req, res) => {
    const sessionId = req.query.session;

    const payment = await repaya.payments.getBySession(sessionId);
	
    if (!payment || payment.status !== 'completed') {
        res.redirect(303, '/error');
        return;
    }

    res.redirect(303, '/success');
})

const port = process.env.PORT
app.listen(port, () => console.log(`Running server on port ${port}`));

Endpoints

AddressDescription

https://repaya.io/api/public/1

Ethereum Mainnet

https://goerli.repaya.io/api/public/1

Goerli Ethereum Testnet

Authorization

Authorization is done via Bearer HTTP Authentication.

Provide your API Token within the corresponding header to get access to all API methods:

Authorization: Bearer <API_TOKEN>

Method

OpenAPI Spec

Last updated