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

Address
Description

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

Create payment session

post
/session

Create a payment session to initiate the checkout flow

Authorizations
AuthorizationstringRequired
Bearer authentication header of the form Bearer <token>.
Body
formLinkIdstringRequiredExample: jAY7k
clientIdstringOptionalExample: key_1432
Responses
200

Payment session created

application/json
post
/session
200

Payment session created

Get customer's payment in the given session

get
/payment
Authorizations
AuthorizationstringRequired
Bearer authentication header of the form Bearer <token>.
Query parameters
sessionIdstringRequired

Payment session ID

Example: id_124124
Responses
200

A payment associated with a given session, null if missing

application/json
get
/payment
200

A payment associated with a given session, null if missing

List payments

get
/payment/list
Authorizations
AuthorizationstringRequired
Bearer authentication header of the form Bearer <token>.
Query parameters
formIdstringRequired

Payment form ID

Example: jAY7k
limitnumberRequired

Limit the number of results

Example: 100
pagenumberRequired

Page number

Example: 3
sortstring · enumRequired

Sort direction (by "created")

Example: ascPossible values:
fromTimestampnumberRequired

From timestamp in milliseconds

Example: 1669839216188
tillTimestampnumberRequired

Till timestamp in milliseconds

Example: 1669839216188
Responses
200

List of payments filtered by the given parameters.

application/json
get
/payment/list
200

List of payments filtered by the given parameters.

Get customer balances

get
/balance
Authorizations
AuthorizationstringRequired
Bearer authentication header of the form Bearer <token>.
Query parameters
formLinkIdstringRequired

Payment form ID

Example: jAY7k
customerIdstringOptional

Filter by customer, pass an empty string to get the total balance

Example: user_123141
productIdstringOptional

Filter by product, pass an empty string to get the total balance

Example: product_123141
coinstringOptional

Filter by coin

Example: USD_MULTI_1
Responses
200

List of customer balances

application/json
get
/balance
200

List of customer balances

OpenAPI Spec

12KB
Open

Last updated

Was this helpful?