repaya.io Documentation
AppSupport
  • Introduction
  • Pricing
  • Supported Countries
  • Docs
    • Getting Started
    • Guides
      • Invoice
      • Donation Form
      • Online Store
      • Subscription
      • Deposit Flow
    • Supported Coins
    • API Reference
  • Contacts
  • Legal
    • Privacy Policy
    • Terms of Use
Powered by GitBook
On this page

Was this helpful?

  1. Docs

API Reference

PreviousSupported CoinsNextContacts

Last updated 1 year ago

Was this helpful?

Clients

Typescript / Javascript

yarn add @repaya/client

Example project on

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 HTTP Authentication.

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

Authorization: Bearer <API_TOKEN>

Method

OpenAPI Spec

library
GitHub
Bearer
12KB
api.yml

Get customer's payment in the given session

get
Authorizations
Query parameters
sessionIdstringRequired

Payment session ID

Example: id_124124
Responses
200
A payment associated with a given session, null if missing
application/json
get
GET /api/public/1/payment HTTP/1.1
Host: repaya.io
Authorization: Bearer YOUR_SECRET_TOKEN
Accept: */*
200

A payment associated with a given session, null if missing

{
  "id": "pid_3251",
  "customer": {
    "id": "user_123141",
    "data": "text"
  },
  "product": {
    "id": "product_123141",
    "name": "Awesome product",
    "data": "text"
  },
  "sender": "0x0000000000000000000000000000000000000000",
  "receiver": "0x0000000000000000000000000000000000000000",
  "amount": "15.0",
  "paidAmount": "5.0",
  "status": "pending",
  "coin": {
    "code": "USD_MULTI_1",
    "name": "USD Stablecoins"
  }
}

List payments

get
Authorizations
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
GET /api/public/1/payment/list HTTP/1.1
Host: repaya.io
Authorization: Bearer YOUR_SECRET_TOKEN
Accept: */*
200

List of payments filtered by the given parameters.

[
  {
    "id": "pid_3251",
    "customer": {
      "id": "user_123141",
      "data": "text"
    },
    "product": {
      "id": "product_123141",
      "name": "Awesome product",
      "data": "text"
    },
    "sender": "0x0000000000000000000000000000000000000000",
    "receiver": "0x0000000000000000000000000000000000000000",
    "amount": "15.0",
    "paidAmount": "5.0",
    "status": "pending",
    "coin": {
      "code": "USD_MULTI_1",
      "name": "USD Stablecoins"
    }
  }
]

Get customer balances

get
Authorizations
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
GET /api/public/1/balance HTTP/1.1
Host: repaya.io
Authorization: Bearer YOUR_SECRET_TOKEN
Accept: */*
200

List of customer balances

[
  {
    "customerId": "user_123141",
    "productId": "product_123141",
    "balance": "123.08",
    "coin": {
      "code": "USD_MULTI_1",
      "name": "USD Stablecoins"
    }
  }
]
  • Clients
  • Endpoints
  • Authorization
  • Method
  • POSTCreate payment session
  • GETGet customer's payment in the given session
  • GETList payments
  • GETGet customer balances

Create payment session

post

Create a payment session to initiate the checkout flow

Authorizations
Body
formLinkIdstringRequiredExample: jAY7k
clientIdstringOptionalExample: key_1432
Responses
200
Payment session created
application/json
post
POST /api/public/1/session HTTP/1.1
Host: repaya.io
Authorization: Bearer YOUR_SECRET_TOKEN
Content-Type: application/json
Accept: */*
Content-Length: 194

{
  "formLinkId": "jAY7k",
  "customer": {
    "id": "user_123141",
    "data": "text"
  },
  "product": {
    "id": "product_123141",
    "name": "Awesome product",
    "data": "text"
  },
  "price": {
    "USD_MULTI_1": "15.0"
  },
  "clientId": "key_1432"
}
200

Payment session created

{
  "checkoutUrl": "https://repaya.io/checkout/id_124124",
  "id": "id_124124",
  "formLinkId": "jAY7k",
  "receiver": "0x0000000000000000000000000000000000000000",
  "customer": {
    "id": "user_123141"
  },
  "product": {
    "id": "product_123141",
    "name": "Awesome product"
  },
  "price": {
    "USD_MULTI_1": "15.0"
  },
  "clientId": "key_1432"
}