These docs are intended for a developer audience.
Deposit forms Rebilly Instruments integration
This topic describes how to embed a Rebilly deposit into your website, or checkout flow, using the Rebilly Instruments JavaScript library.
This example describes how to retrieve a customer JWT from a backend endpoint, and how to use that with the Rebilly Instruments JavaScript library to integrate a deposit experience into your frontend.
1. Obtain IDs and a secret API key
- Obtain your organization ID and website ID:
- In the left navigation bar, click Settings .
- In the Management section, click My organization & websites.
- In the Organization details section, note the ID value.
- In the Website section, note the ID value. For more information, see Organizations and websites.
- Obtain your secret API key:
- In the left navigation bar, click Automations .
- In the Development section, click API keys.
- Optionally, if you have not created a secret key:
- In top right of the screen, click Add API.
- In the API key type section, select Secret, then complete the form and click Save API key.
- Go back to the API Keys page.
- Select a secret key and copy the Key value.
2. Set up Rebilly Instruments
In this step you will implement a basic Rebilly Instruments set up. This step describes the server and client side implementation — both must be configured.
Initial setup
Set up an express node app for authenticating the client.
Install dependencies
Import dependencies, this may change from implementation to implementation. This example is for an app that uses Node.js and express.
Initialize Rebilly JS SDK
Setup Rebilly JS SDK. The secret key is required for the API calls that will be executed later.
Configure the endpoint
This step describes the basic endpoint used for customer authentication.
Post /authenticate
You can use any endpoint. In this example it is called authenticate
.
Rebilly passwordless login
In the request body, provide a customerId
. Then, provide that value along with mode: "passwordless"
to rebilly.customerAuthentication.login
.
Rebilly exchange token
Use the token provided by the passwordless login and exchange it for a JWT that will be used by Rebilly Instruments within the client.
ACL scope data
In the scope
object, provide your organization ID.
ACL permissions data
In the permissions
array, provide operation IDs for all actions that will be used in the Rebilly Instruments client.
ACL customClaims data
In the customClaims
object, provide your website ID.
Set endpoint response
Finally, respond with the JWT token that is provided by the token exchange.
- Node.js
1const express = require('express');2const env = require('dotenv').config();3const bodyParser = require('body-parser');4const RebillyAPI = require('rebilly-js-sdk').default;56const {7 parsed: {8 REBILLY_API_KEY = null,9 REBILLY_WEBSITE_ID = null,10 REBILLY_ORGANIZATION_ID = null,11 }12} = env;1314const rebilly = RebillyAPI({15 sandbox: true,16 apiKey: REBILLY_API_KEY,17});1819const app = express();20app.use(bodyParser.json());21app.use(bodyParser.urlencoded({ extended: true }));22app.use(express.static('public'));2324app.post('/authenticate', async function (req, res) {25 const {customerId} = req.body;2627 const data = {28 mode: "passwordless",29 customerId30 };31 const { fields: login } =32 await rebilly.customerAuthentication.login({33 data34 });3536 const { fields: exchangeToken } =37 await rebilly.customerAuthentication.exchangeToken({38 token: login.token,39 data: {40 acl: [41 {42 scope: {43 organizationId: [REBILLY_ORGANIZATION_ID],44 },45 permissions: [46 "PostToken",47 "PostDigitalWalletValidation",48 "StorefrontGetAccount",49 "StorefrontPatchAccount",50 "StorefrontPostPayment",51 "StorefrontGetTransactionCollection",52 "StorefrontGetTransaction",53 "StorefrontGetPaymentInstrumentCollection",54 "StorefrontPostPaymentInstrument",55 "StorefrontGetPaymentInstrument",56 "StorefrontPatchPaymentInstrument",57 "StorefrontPostPaymentInstrumentDeactivation",58 "StorefrontGetWebsite",59 "StorefrontGetInvoiceCollection",60 "StorefrontGetInvoice",61 "StorefrontGetProductCollection",62 "StorefrontGetProduct",63 "StorefrontPostReadyToPay",64 "StorefrontPostReadyToPayout"65 "StorefrontGetPaymentInstrumentSetup",66 "StorefrontPostPaymentInstrumentSetup",67 "StorefrontGetDepositRequest",68 "StorefrontGetDepositStrategy",69 "StorefrontGetPayoutRequest",70 "StorefrontGetPayoutRequestCollection",71 "StorefrontPatchPayoutRequest"72 ]73 }74 ],75 customClaims: {76 websiteId: REBILLY_WEBSITE_ID77 }78 }79 });8081 res.send({token: exchangeToken.token});82});8384const server = app.listen(8080, function () {85 const host = server.address().address86 const port = server.address().port8788 console.log("Example app listening at http://%s:%s", host, port)89});